Commit 2947a916 authored by weinig@apple.com's avatar weinig@apple.com

JavaScriptCore:

2008-07-06  Sam Weinig  <sam@webkit.org>

        Reviewed by Cameron Zwarich.

        Second step in broad cleanup effort.

        [ File list elided ]

WebCore:

2008-07-06  Sam Weinig  <sam@webkit.org>

        Reviewed by Cameron Zwarich.

        Add #include for kjs/protect.h.

        * xml/XMLHttpRequest.cpp:
        (WebCore::XMLHttpRequest::loadRequestAsynchronously):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35027 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e875c5bb
2008-07-06 Sam Weinig <sam@webkit.org>
Reviewed by Cameron Zwarich.
Second step in broad cleanup effort.
[ File list elided ]
2008-07-05 Sam Weinig <sam@webkit.org>
Reviewed by Cameron Zwarich.
......@@ -170,8 +170,8 @@ __ZN3KJS6JSCell3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
__ZN3KJS6JSCell3putEPNS_9ExecStateEjPNS_7JSValueE
__ZN3KJS6JSCell9getObjectEv
__ZN3KJS6JSCellnwEmPNS_9ExecStateE
__ZN3KJS6JSLock12DropAllLocksC1Eb
__ZN3KJS6JSLock12DropAllLocksC1EPNS_9ExecStateE
__ZN3KJS6JSLock12DropAllLocksC1Eb
__ZN3KJS6JSLock12DropAllLocksD1Ev
__ZN3KJS6JSLock14registerThreadEv
__ZN3KJS6JSLock4lockEb
......@@ -210,7 +210,7 @@ __ZN3KJS8JSObject12lookupSetterEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj
__ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
__ZN3KJS8JSObject17putDirectFunctionEPNS_16InternalFunctionEi
__ZN3KJS8JSObject17putDirectFunctionEPNS_16InternalFunctionEj
__ZN3KJS8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEj
__ZN3KJS8JSObject17putWithAttributesEPNS_9ExecStateEjPNS_7JSValueEj
__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
......
......@@ -76,7 +76,7 @@ bool JSActivation::getOwnPropertySlot(ExecState* exec, const Identifier& propert
// We don't call through to JSObject because there's no way to give an
// activation object getter properties or a prototype.
ASSERT(!_prop.hasGetterSetterProperties());
ASSERT(!m_propertyMap.hasGetterSetterProperties());
ASSERT(prototype() == jsNull());
return false;
}
......@@ -89,8 +89,8 @@ void JSActivation::put(ExecState*, const Identifier& propertyName, JSValue* valu
// We don't call through to JSObject because __proto__ and getter/setter
// properties are non-standard extensions that other implementations do not
// expose in the activation object.
ASSERT(!_prop.hasGetterSetterProperties());
_prop.put(propertyName, value, 0, true);
ASSERT(!m_propertyMap.hasGetterSetterProperties());
m_propertyMap.put(propertyName, value, 0, true);
}
// FIXME: Make this function honor ReadOnly (const) and DontEnum
......@@ -102,8 +102,8 @@ void JSActivation::putWithAttributes(ExecState*, const Identifier& propertyName,
// We don't call through to JSObject because __proto__ and getter/setter
// properties are non-standard extensions that other implementations do not
// expose in the activation object.
ASSERT(!_prop.hasGetterSetterProperties());
_prop.put(propertyName, value, attributes, true);
ASSERT(!m_propertyMap.hasGetterSetterProperties());
m_propertyMap.put(propertyName, value, attributes, true);
}
bool JSActivation::deleteProperty(ExecState* exec, const Identifier& propertyName)
......
......@@ -90,7 +90,7 @@ namespace KJS {
static JSGlobalData*& sharedInstanceInternal();
struct DataInstance {
DataInstance() : m_data(0) {}
DataInstance() : m_data(0) { }
~DataInstance() { delete m_data; }
operator JSGlobalData*&() { return m_data; }
......
......@@ -176,7 +176,7 @@ void JSGlobalObject::reset(JSValue* prototype)
// which would be wasteful -- or uninitialized pointers -- which would be
// dangerous. (The allocations below may cause a GC.)
_prop.clear();
m_propertyMap.clear();
symbolTable().clear();
setRegisterArray(0, 0);
......
// -*- c-basic-offset: 4 -*-
/*
* Copyright (C) 2007 Eric Seidel <eric@webkit.org>
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
......@@ -20,8 +19,8 @@
*
*/
#ifndef KJS_GlobalObject_h
#define KJS_GlobalObject_h
#ifndef JSGlobalObject_h
#define JSGlobalObject_h
#include "JSGlobalData.h"
#include "JSVariableObject.h"
......@@ -296,4 +295,4 @@ namespace KJS {
} // namespace KJS
#endif // KJS_GlobalObject_h
#endif // JSGlobalObject_h
This diff is collapsed.
// -*- mode: c++; c-basic-offset: 4 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 2005 Apple Computer, Inc.
* Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -210,4 +208,4 @@ JSLock::DropAllLocks::~DropAllLocks()
#endif // USE(MULTIPLE_THREADS)
}
} // namespace KJS
// -*- mode: c++; c-basic-offset: 4 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 2005 Apple Computer, Inc.
* Copyright (C) 2005, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -54,7 +52,7 @@ namespace KJS {
class JSLock : Noncopyable {
public:
JSLock(ExecState* exec);
JSLock(ExecState*);
JSLock(bool lockingForReal)
: m_lockingForReal(lockingForReal)
......
......@@ -44,7 +44,7 @@ namespace KJS {
}
private:
// JSValue methods
// JSValue methods
virtual JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&);
virtual bool toBoolean(ExecState*) const;
......
......@@ -41,33 +41,33 @@ JSValue* JSNumberCell::toPrimitive(ExecState*, JSType) const
bool JSNumberCell::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
{
number = val;
number = m_value;
value = this;
return true;
}
bool JSNumberCell::toBoolean(ExecState *) const
bool JSNumberCell::toBoolean(ExecState*) const
{
return val < 0.0 || val > 0.0; // false for NaN
return m_value < 0.0 || m_value > 0.0; // false for NaN
}
double JSNumberCell::toNumber(ExecState *) const
double JSNumberCell::toNumber(ExecState*) const
{
return val;
return m_value;
}
UString JSNumberCell::toString(ExecState*) const
{
if (val == 0.0) // +0.0 or -0.0
if (m_value == 0.0) // +0.0 or -0.0
return "0";
return UString::from(val);
return UString::from(m_value);
}
UString JSNumberCell::toThisString(ExecState*) const
{
if (val == 0.0) // +0.0 or -0.0
if (m_value == 0.0) // +0.0 or -0.0
return "0";
return UString::from(val);
return UString::from(m_value);
}
JSObject* JSNumberCell::toObject(ExecState* exec) const
......@@ -82,23 +82,23 @@ JSObject* JSNumberCell::toThisObject(ExecState* exec) const
bool JSNumberCell::getUInt32(uint32_t& uint32) const
{
uint32 = static_cast<uint32_t>(val);
return uint32 == val;
uint32 = static_cast<uint32_t>(m_value);
return uint32 == m_value;
}
bool JSNumberCell::getTruncatedInt32(int32_t& int32) const
{
if (!(val >= -2147483648.0 && val < 2147483648.0))
if (!(m_value >= -2147483648.0 && m_value < 2147483648.0))
return false;
int32 = static_cast<int32_t>(val);
int32 = static_cast<int32_t>(m_value);
return true;
}
bool JSNumberCell::getTruncatedUInt32(uint32_t& uint32) const
{
if (!(val >= 0.0 && val < 4294967296.0))
if (!(m_value >= 0.0 && m_value < 4294967296.0))
return false;
uint32 = static_cast<uint32_t>(val);
uint32 = static_cast<uint32_t>(m_value);
return true;
}
......
......@@ -34,127 +34,125 @@
namespace KJS {
class ExecState;
class Identifier;
class JSCell;
class JSObject;
class JSString;
class PropertySlot;
struct ClassInfo;
struct Instruction;
class JSNumberCell : public JSCell {
friend JSValue* jsNumberCell(ExecState*, double);
public:
double value() const { return val; }
virtual JSType type() const;
virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
virtual bool toBoolean(ExecState*) const;
virtual double toNumber(ExecState*) const;
virtual UString toString(ExecState*) const;
virtual JSObject* toObject(ExecState*) const;
virtual UString toThisString(ExecState*) const;
virtual JSObject* toThisObject(ExecState*) const;
virtual JSValue* getJSNumber();
void* operator new(size_t size, ExecState* exec)
class ExecState;
class Identifier;
class JSCell;
class JSObject;
class JSString;
class PropertySlot;
struct ClassInfo;
struct Instruction;
class JSNumberCell : public JSCell {
friend JSValue* jsNumberCell(ExecState*, double);
public:
double value() const { return m_value; }
virtual JSType type() const;
virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
virtual bool toBoolean(ExecState*) const;
virtual double toNumber(ExecState*) const;
virtual UString toString(ExecState*) const;
virtual JSObject* toObject(ExecState*) const;
virtual UString toThisString(ExecState*) const;
virtual JSObject* toThisObject(ExecState*) const;
virtual JSValue* getJSNumber();
void* operator new(size_t size, ExecState* exec)
{
#ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE
return exec->heap()->inlineAllocateNumber(size);
#else
return exec->heap()->allocateNumber(size);
#endif
}
private:
JSNumberCell(double value)
: m_value(value)
{
}
virtual bool getUInt32(uint32_t&) const;
virtual bool getTruncatedInt32(int32_t&) const;
virtual bool getTruncatedUInt32(uint32_t&) const;
double m_value;
};
extern const double NaN;
extern const double Inf;
// Beware marking this function ALWAYS_INLINE: It takes a PIC branch, so
// inlining it may not always be a win.
inline JSValue* jsNumberCell(ExecState* exec, double d)
{
#ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE
return exec->heap()->inlineAllocateNumber(size);
#else
return exec->heap()->allocateNumber(size);
#endif
return new (exec) JSNumberCell(d);
}
private:
JSNumberCell(double v)
: val(v)
inline JSValue* jsNaN(ExecState* exec)
{
return jsNumberCell(exec, NaN);
}
virtual bool getUInt32(uint32_t&) const;
virtual bool getTruncatedInt32(int32_t&) const;
virtual bool getTruncatedUInt32(uint32_t&) const;
double val;
};
extern const double NaN;
extern const double Inf;
// Beware marking this function ALWAYS_INLINE: It takes a PIC branch, so
// inlining it may not always be a win.
inline JSValue* jsNumberCell(ExecState* exec, double d)
{
return new (exec) JSNumberCell(d);
}
inline JSValue* jsNaN(ExecState* exec)
{
return jsNumberCell(exec, NaN);
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, double d)
{
JSValue* v = JSImmediate::from(d);
return v ? v : jsNumberCell(exec, d);
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, int i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, i);
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, i);
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, long i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, i);
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned long i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, i);
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, long long i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, static_cast<double>(i));
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned long long i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, static_cast<double>(i));
}
// --- JSValue inlines ----------------------------
inline double JSValue::uncheckedGetNumber() const
{
ASSERT(JSImmediate::isImmediate(this) || asCell()->isNumber());
return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : static_cast<const JSNumberCell*>(this)->value();
}
ALWAYS_INLINE JSValue* JSValue::toJSNumber(ExecState* exec) const
{
return JSImmediate::isNumber(this) ? const_cast<JSValue*>(this) : jsNumber(exec, this->toNumber(exec));
}
// -------
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, double d)
{
JSValue* v = JSImmediate::from(d);
return v ? v : jsNumberCell(exec, d);
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, int i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, i);
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, i);
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, long i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, i);
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned long i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, i);
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, long long i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, static_cast<double>(i));
}
ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned long long i)
{
JSValue* v = JSImmediate::from(i);
return v ? v : jsNumberCell(exec, static_cast<double>(i));
}
// --- JSValue inlines ----------------------------
inline double JSValue::uncheckedGetNumber() const
{
ASSERT(JSImmediate::isImmediate(this) || asCell()->isNumber());
return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : static_cast<const JSNumberCell*>(this)->value();
}
ALWAYS_INLINE JSValue* JSValue::toJSNumber(ExecState* exec) const
{
return JSImmediate::isNumber(this) ? const_cast<JSValue*>(this) : jsNumber(exec, this->toNumber(exec));
}
} // namespace KJS
......
This diff is collapsed.
This diff is collapsed.
......@@ -32,7 +32,7 @@ namespace KJS {
JSValue* JSString::toPrimitive(ExecState*, JSType) const
{
return const_cast<JSString*>(this);
return const_cast<JSString*>(this);
}
bool JSString::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
......
......@@ -32,91 +32,99 @@
namespace KJS {
class JSString : public JSCell {
public:
JSString(const UString& value) : m_value(value) { Heap::heap(this)->reportExtraMemoryCost(value.cost()); }
enum HasOtherOwnerType { HasOtherOwner };
JSString(const UString& value, HasOtherOwnerType) : m_value(value) { }
const UString& value() const { return m_value; }
bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
bool getStringPropertySlot(unsigned propertyName, PropertySlot&);
bool canGetIndex(unsigned i) { return i < static_cast<unsigned>(m_value.size()); }
JSValue* getIndex(ExecState* exec, unsigned i)
class JSString : public JSCell {
public:
JSString(const UString& value)
: m_value(value)
{
Heap::heap(this)->reportExtraMemoryCost(value.cost());
}
enum HasOtherOwnerType { HasOtherOwner };
JSString(const UString& value, HasOtherOwnerType)
: m_value(value)
{
}
const UString& value() const { return m_value; }
bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
bool getStringPropertySlot(unsigned propertyName, PropertySlot&);
bool canGetIndex(unsigned i) { return i < static_cast<unsigned>(m_value.size()); }
JSValue* getIndex(ExecState* exec, unsigned i)
{
ASSERT(canGetIndex(i));
return new (exec) JSString(m_value.substr(i, 1));
}
private:
virtual JSType type() const { return StringType; }
virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
virtual bool toBoolean(ExecState*) const;
virtual double toNumber(ExecState*) const;
virtual JSObject* toObject(ExecState*) const;
virtual UString toString(ExecState*) const;
virtual JSObject* toThisObject(ExecState*) const;
virtual UString toThisString(ExecState*) const;
virtual JSString* toThisJSString(ExecState*);
// Actually getPropertySlot, not getOwnPropertySlot (see JSCell).
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
static JSValue* indexGetter(ExecState*, const Identifier&, const PropertySlot&);
static JSValue* indexNumericPropertyGetter(ExecState*, unsigned, const PropertySlot&);
UString m_value;
};
JSString* jsString(ExecState*, const UString&); // returns empty string if passed null string
JSString* jsString(ExecState*, const char* = ""); // returns empty string if passed 0
// Should be used for strings that are owned by an object that will
// likely outlive the JSValue this makes, such as the parse tree or a
// DOM object that contains a UString
JSString* jsOwnedString(ExecState*, const UString&);
ALWAYS_INLINE bool JSString::getStringPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
ASSERT(canGetIndex(i));
return new (exec) JSString(m_value.substr(i, 1));
if (propertyName == exec->propertyNames().length) {
slot.setCustom(this, lengthGetter);
return true;
}
bool isStrictUInt32;
unsigned i = propertyName.toStrictUInt32(&isStrictUInt32);
if (isStrictUInt32 && i < static_cast<unsigned>(m_value.size())) {
slot.setCustomIndex(this, i, indexGetter);
return true;
}
return false;
}
ALWAYS_INLINE bool JSString::getStringPropertySlot(unsigned propertyName, PropertySlot& slot)
{
if (propertyName < static_cast<unsigned>(m_value.size())) {
slot.setCustomNumeric(this, indexNumericPropertyGetter);
return true;
}
private:
virtual JSType type() const { return StringType; }
virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
virtual bool toBoolean(ExecState*) const;
virtual double toNumber(ExecState*) const;
virtual JSObject* toObject(ExecState*) const;
virtual UString toString(ExecState*) const;
virtual JSObject* toThisObject(ExecState*) const;
virtual UString toThisString(ExecState*) const;
virtual JSString* toThisJSString(ExecState*);
// Actually getPropertySlot, not getOwnPropertySlot (see JSCell).
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
static JSValue* indexGetter(ExecState*, const Identifier&, const PropertySlot&);
static JSValue* indexNumericPropertyGetter(ExecState*, unsigned, const PropertySlot&);
UString m_value;
};
JSString* jsString(ExecState*, const UString&); // returns empty string if passed null string
JSString* jsString(ExecState*, const char* = ""); // returns empty string if passed 0
// Should be used for strings that are owned by an object that will
// likely outlive the JSValue this makes, such as the parse tree or a
// DOM object that contains a UString
JSString* jsOwnedString(ExecState*, const UString&);
ALWAYS_INLINE bool JSString::getStringPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
if (propertyName == exec->propertyNames().length) {
slot.setCustom(this, lengthGetter);
return true;
return false;
}
bool isStrictUInt32;
unsigned i = propertyName.toStrictUInt32(&isStrictUInt32);
if (isStrictUInt32 && i < static_cast<unsigned>(m_value.size())) {
slot.setCustomIndex(this, i, indexGetter);
return true;
}
// --- JSValue inlines ----------------------------
return false;
}
ALWAYS_INLINE bool JSString::getStringPropertySlot(unsigned propertyName, PropertySlot& slot)
{
if (propertyName < static_cast<unsigned>(m_value.size())) {
slot.setCustomNumeric(this, indexNumericPropertyGetter);
return true;
inline JSString* JSValue::toThisJSString(ExecState* exec)
{
return JSImmediate::isImmediate(this) ? jsString(exec, JSImmediate::toString(this)) : asCell()->toThisJSString(exec);
}
return false;
}