namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(JSCallbackFunction);
+
const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 };
JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name)
- : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), name)
+ : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), name)
, m_callback(callback)
{
}
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSObject>);
+ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSGlobalObject>);
+
// Define the two types of JSCallbackObjects we support.
template <> const ClassInfo JSCallbackObject<JSObject>::info = { "CallbackObject", 0, 0, 0 };
template <> const ClassInfo JSCallbackObject<JSGlobalObject>::info = { "CallbackGlobalObject", 0, 0, 0 };
-COMPILE_ASSERT(sizeof(JSCallbackObject<JSGlobalObject>) <= CELL_SIZE, global_callback_object_fits_in_cell);
-
} // namespace KJS
static const ClassInfo info;
- JSClassRef classRef() const { return m_class; }
+ JSClassRef classRef() const { return m_callbackObjectData->jsClass; }
bool inherits(JSClassRef) const;
private:
static JSValue* staticValueGetter(ExecState*, const Identifier&, const PropertySlot&);
static JSValue* staticFunctionGetter(ExecState*, const Identifier&, const PropertySlot&);
static JSValue* callbackGetter(ExecState*, const Identifier&, const PropertySlot&);
+
+ struct JSCallbackObjectData {
+ JSCallbackObjectData(void* privateData_, JSClassRef jsClass_)
+ : privateData(privateData_)
+ , jsClass(jsClass_)
+ {
+ JSClassRetain(jsClass);
+ }
+
+ ~JSCallbackObjectData()
+ {
+ JSClassRelease(jsClass);
+ }
+
+ void* privateData;
+ JSClassRef jsClass;
+ };
- void* m_privateData;
- JSClassRef m_class;
+ OwnPtr<JSCallbackObjectData> m_callbackObjectData;
};
} // namespace KJS
template <class Base>
JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSClassRef jsClass, JSValue* prototype, void* data)
: Base(prototype)
- , m_privateData(data)
- , m_class(JSClassRetain(jsClass))
+ , m_callbackObjectData(new JSCallbackObjectData(data, jsClass))
{
init(exec);
}
// FIXME: Move this into a separate JSGlobalCallbackObject class derived from this one.
template <class Base>
JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass)
- : m_privateData(0)
- , m_class(JSClassRetain(jsClass))
+ : m_callbackObjectData(new JSCallbackObjectData(0, jsClass))
{
ASSERT(Base::isGlobalObject());
init(static_cast<JSGlobalObject*>(this)->globalExec());
ASSERT(exec);
Vector<JSObjectInitializeCallback, 16> initRoutines;
- JSClassRef jsClass = m_class;
+ JSClassRef jsClass = classRef();
do {
if (JSObjectInitializeCallback initialize = jsClass->initialize)
initRoutines.append(initialize);
{
JSObjectRef thisRef = toRef(this);
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
- if (JSObjectFinalizeCallback finalize = jsClass->finalize) {
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
+ if (JSObjectFinalizeCallback finalize = jsClass->finalize)
finalize(thisRef);
- }
-
- JSClassRelease(m_class);
}
template <class Base>
UString JSCallbackObject<Base>::className() const
{
- UString thisClassName = m_class->className();
+ UString thisClassName = classRef()->className();
if (!thisClassName.isNull())
return thisClassName;
JSObjectRef thisRef = toRef(this);
RefPtr<OpaqueJSString> propertyNameRef;
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
// optional optimization to bypass getProperty in cases when we only need to know if the property exists
if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) {
if (!propertyNameRef)
RefPtr<OpaqueJSString> propertyNameRef;
JSValueRef valueRef = toRef(value);
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
if (!propertyNameRef)
propertyNameRef = OpaqueJSString::create(propertyName.ustring());
JSObjectRef thisRef = toRef(this);
RefPtr<OpaqueJSString> propertyNameRef;
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) {
if (!propertyNameRef)
propertyNameRef = OpaqueJSString::create(propertyName.ustring());
template <class Base>
ConstructType JSCallbackObject<Base>::getConstructData(ConstructData& constructData)
{
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
if (jsClass->callAsConstructor) {
constructData.native.function = construct;
return ConstructTypeHost;
template <class Base>
bool JSCallbackObject<Base>::implementsHasInstance() const
{
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
if (jsClass->hasInstance)
return true;
JSContextRef execRef = toRef(exec);
JSObjectRef thisRef = toRef(this);
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance)
return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot()));
}
template <class Base>
CallType JSCallbackObject<Base>::getCallData(CallData& callData)
{
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
if (jsClass->callAsFunction) {
callData.native.function = call;
return CallTypeHost;
JSObjectRef functionRef = toRef(functionObject);
JSObjectRef thisObjRef = toRef(thisValue->toThisObject(exec));
- for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(functionObject)->m_class; jsClass; jsClass = jsClass->parentClass) {
+ for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(functionObject)->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) {
int argumentCount = static_cast<int>(args.size());
Vector<JSValueRef, 16> arguments(argumentCount);
JSContextRef execRef = toRef(exec);
JSObjectRef thisRef = toRef(this);
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames)
getPropertyNames(execRef, thisRef, toRef(&propertyNames));
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(this);
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot())))
return toJS(value)->getNumber();
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(this);
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
JSValueRef value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot()));
if (value)
template <class Base>
void JSCallbackObject<Base>::setPrivate(void* data)
{
- m_privateData = data;
+ m_callbackObjectData->privateData = data;
}
template <class Base>
void* JSCallbackObject<Base>::getPrivate()
{
- return m_privateData;
+ return m_callbackObjectData->privateData;
}
template <class Base>
bool JSCallbackObject<Base>::inherits(JSClassRef c) const
{
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
+ for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
if (jsClass == c)
return true;
JSObjectRef thisRef = toRef(thisObj);
RefPtr<OpaqueJSString> propertyNameRef;
- for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass)
+ for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass)
if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec))
if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep()))
if (JSObjectGetPropertyCallback getProperty = entry->getProperty) {
if (thisObj->Base::getOwnPropertySlot(exec, propertyName, slot2))
return slot2.getValue(exec, propertyName);
- for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) {
+ for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
JSObjectRef thisRef = toRef(thisObj);
RefPtr<OpaqueJSString> propertyNameRef;
- for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass)
+ for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass)
if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
if (!propertyNameRef)
propertyNameRef = OpaqueJSString::create(propertyName.ustring());
+2008-08-17 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Cameron Zwarich.
+
+ Made room for a free word in JSCell.
+
+ SunSpider says no change.
+
+ I changed JSCallbackObjectData, Arguments, JSArray, and RegExpObject to
+ store auxiliary data in a secondary structure.
+
+ I changed InternalFunction to store the function's name in the property
+ map.
+
+ I changed JSGlobalObjectData to use a virtual destructor, so WebCore's
+ JSDOMWindowBaseData could inherit from it safely. (It's a strange design
+ for JSDOMWindowBase to allocate an object that JSGlobalObject deletes,
+ but that's really our only option, given the size constraint.)
+
+ I also added a bunch of compile-time ASSERTs, and removed lots of comments
+ in JSObject.h because they were often out of date, and they got in the
+ way of reading what was actually going on.
+
+ Also renamed JSArray::getLength to JSArray::length, to match our style
+ guidelines.
+
2008-08-16 Geoffrey Garen <ggaren@apple.com>
Reviewed by Oliver Hunt.
__ZN3KJS14JSGlobalObjectnwEmPNS_12JSGlobalDataE
__ZN3KJS14constructArrayEPNS_9ExecStateERKNS_7ArgListE
__ZN3KJS15JSWrapperObject4markEv
-__ZN3KJS16InternalFunction14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
-__ZN3KJS16InternalFunction18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
-__ZN3KJS16InternalFunction3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
__ZN3KJS16InternalFunction4infoE
-__ZN3KJS16InternalFunctionC2EPNS_17FunctionPrototypeERKNS_10IdentifierE
+__ZN3KJS16InternalFunctionC2EPNS_9ExecStateEPNS_17FunctionPrototypeERKNS_10IdentifierE
__ZN3KJS16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
__ZN3KJS16JSVariableObject16setRegisterArrayEPNS_8RegisterEm
__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj
__ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
-__ZN3KJS8JSObject17putDirectFunctionEPNS_16InternalFunctionEj
+__ZN3KJS8JSObject17putDirectFunctionEPNS_9ExecStateEPNS_16InternalFunctionEj
__ZN3KJS8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEj
__ZN3KJS8JSObject17putWithAttributesEPNS_9ExecStateEjPNS_7JSValueEj
__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
namespace KJS {
-COMPILE_ASSERT(sizeof(JSPropertyNameIterator) <= CellSize<sizeof(void*)>::m_value, JSPropertyNameIteratorSizeASSERT);
+ASSERT_CLASS_FITS_IN_CELL(JSPropertyNameIterator);
JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSValue* v)
{
Register* callFrame = r - oldCodeBlock->numLocals - RegisterFile::CallFrameHeaderSize;
if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) {
- DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue);
+ DebuggerCallFrame debuggerCallFrame(exec, exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue);
if (callFrame[RegisterFile::Callee].jsValue(exec))
debugger->returnEvent(debuggerCallFrame, codeBlock->ownerNode->sourceId(), codeBlock->ownerNode->lastLine());
else
}
if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) {
- DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue);
+ DebuggerCallFrame debuggerCallFrame(exec, exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue);
debugger->exception(debuggerCallFrame, codeBlock->ownerNode->sourceId(), codeBlock->lineNumberForVPC(vPC));
}
if (!debugger)
return;
- DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, r, 0);
+ DebuggerCallFrame debuggerCallFrame(exec, exec->dynamicGlobalObject(), codeBlock, scopeChain, r, 0);
switch((DebugHookID)debugHookID) {
case DidEnterCallFrame: {
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(Arguments);
+
const ClassInfo Arguments::info = { "Arguments", 0, 0, 0 };
// ECMA 10.1.8
Arguments::Arguments(ExecState* exec, JSFunction* function, const ArgList& args, JSActivation* activation)
: JSObject(exec->lexicalGlobalObject()->objectPrototype())
- , m_activationObject(activation)
- , m_indexToNameMap(function, args)
+ , d(new ArgumentsData(activation, function, args))
{
+ ASSERT(activation);
+
putDirect(exec->propertyNames().callee, function, DontEnum);
putDirect(exec, exec->propertyNames().length, args.size(), DontEnum);
ArgList::const_iterator end = args.end();
for (ArgList::const_iterator it = args.begin(); it != end; ++it, ++i) {
Identifier name = Identifier::from(exec, i);
- if (!m_indexToNameMap.isMapped(name))
+ if (!d->indexToNameMap.isMapped(name))
putDirect(name, (*it).jsValue(exec), DontEnum);
}
}
void Arguments::mark()
{
JSObject::mark();
- if (m_activationObject && !m_activationObject->marked())
- m_activationObject->mark();
+ if (!d->activation->marked())
+ d->activation->mark();
}
JSValue* Arguments::mappedIndexGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
Arguments* thisObj = static_cast<Arguments*>(slot.slotBase());
- return thisObj->m_activationObject->get(exec, thisObj->m_indexToNameMap[propertyName]);
+ return thisObj->d->activation->get(exec, thisObj->d->indexToNameMap[propertyName]);
}
bool Arguments::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
- if (m_indexToNameMap.isMapped(propertyName)) {
+ if (d->indexToNameMap.isMapped(propertyName)) {
slot.setCustom(this, mappedIndexGetter);
return true;
}
void Arguments::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
{
- if (m_indexToNameMap.isMapped(propertyName))
- m_activationObject->put(exec, m_indexToNameMap[propertyName], value);
+ if (d->indexToNameMap.isMapped(propertyName))
+ d->activation->put(exec, d->indexToNameMap[propertyName], value);
else
JSObject::put(exec, propertyName, value);
}
bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName)
{
- if (m_indexToNameMap.isMapped(propertyName)) {
- m_indexToNameMap.unMap(exec, propertyName);
+ if (d->indexToNameMap.isMapped(propertyName)) {
+ d->indexToNameMap.unMap(exec, propertyName);
return true;
}
private:
static JSValue* mappedIndexGetter(ExecState*, const Identifier&, const PropertySlot& slot);
- JSActivation* m_activationObject;
- mutable IndexToNameMap m_indexToNameMap;
+ struct ArgumentsData {
+ ArgumentsData(JSActivation* activation_, JSFunction* function_, const ArgList& args_)
+ : activation(activation_)
+ , indexToNameMap(function_, args_)
+ {
+ }
+
+ JSActivation* activation;
+ mutable IndexToNameMap indexToNameMap;
+ };
+
+ OwnPtr<ArgumentsData> d;
};
} // namespace KJS
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(ArrayConstructor);
+
ArrayConstructor::ArrayConstructor(ExecState* exec, FunctionPrototype* functionPrototype, ArrayPrototype* arrayPrototype)
- : InternalFunction(functionPrototype, Identifier(exec, arrayPrototype->classInfo()->className))
+ : InternalFunction(exec, functionPrototype, Identifier(exec, arrayPrototype->classInfo()->className))
{
// ECMA 15.4.3.1 Array.prototype
putDirect(exec->propertyNames().prototype, arrayPrototype, DontEnum | DontDelete | ReadOnly);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(ArrayPrototype);
+
static JSValue* arrayProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* arrayProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* arrayProtoFuncConcat(ExecState*, JSObject*, JSValue*, const ArgList&);
while (1) {
if (curArg->isObject(&JSArray::info)) {
JSArray* curArray = static_cast<JSArray*>(curArg);
- unsigned length = curArray->getLength();
+ unsigned length = curArray->length();
for (unsigned k = 0; k < length; ++k) {
if (JSValue* v = getProperty(exec, curArray, k))
arr->put(exec, n, v);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(BooleanConstructor);
+
BooleanConstructor::BooleanConstructor(ExecState* exec, FunctionPrototype* functionPrototype, BooleanPrototype* booleanPrototype)
- : InternalFunction(functionPrototype, Identifier(exec, booleanPrototype->classInfo()->className))
+ : InternalFunction(exec, functionPrototype, Identifier(exec, booleanPrototype->classInfo()->className))
{
putDirect(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(BooleanObject);
+
const ClassInfo BooleanObject::info = { "Boolean", 0, 0, 0 };
BooleanObject::BooleanObject(JSObject* prototype)
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(BooleanPrototype);
+
// Functions
static JSValue* booleanProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* booleanProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
{
setInternalValue(jsBoolean(false));
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
}
// TODO: MakeTime (15.9.11.1) etc. ?
+ASSERT_CLASS_FITS_IN_CELL(DateConstructor);
+
static JSValue* dateParse(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* dateNow(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* dateUTC(ExecState*, JSObject*, JSValue*, const ArgList&);
DateConstructor::DateConstructor(ExecState* exec, FunctionPrototype* functionPrototype, DatePrototype* datePrototype)
- : InternalFunction(functionPrototype, Identifier(exec, datePrototype->classInfo()->className))
+ : InternalFunction(exec, functionPrototype, Identifier(exec, datePrototype->classInfo()->className))
{
putDirect(exec->propertyNames().prototype, datePrototype, DontEnum|DontDelete|ReadOnly);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().parse, dateParse), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().now, dateNow), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().parse, dateParse), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().now, dateNow), DontEnum);
putDirect(exec, exec->propertyNames().length, 7, ReadOnly | DontEnum | DontDelete);
}
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(DatePrototype);
+
static JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* dateProtoFuncGetDay(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* dateProtoFuncGetFullYear(ExecState*, JSObject*, JSValue*, const ArgList&);
JSFunction* function = static_cast<JSFunction*>(callFrame()[RegisterFile::Callee].getJSValue());
if (!function)
return 0;
- return &function->functionName().ustring();
+ return &function->name(m_exec);
}
DebuggerCallFrame::Type DebuggerCallFrame::type() const
namespace KJS {
class CodeBlock;
+ class ExecState;
class JSGlobalObject;
class JSObject;
class JSValue;
FunctionType
};
- DebuggerCallFrame(JSGlobalObject* dynamicGlobalObject, const CodeBlock* codeBlock, ScopeChainNode* scopeChain, Register* r, JSValue* exception)
- : m_dynamicGlobalObject(dynamicGlobalObject)
+ DebuggerCallFrame(ExecState* exec, JSGlobalObject* dynamicGlobalObject, const CodeBlock* codeBlock, ScopeChainNode* scopeChain, Register* r, JSValue* exception)
+ : m_exec(exec)
+ , m_dynamicGlobalObject(dynamicGlobalObject)
, m_codeBlock(codeBlock)
, m_scopeChain(scopeChain)
, m_registers(r)
private:
Register* callFrame() const;
+ ExecState* m_exec;
JSGlobalObject* m_dynamicGlobalObject;
const CodeBlock* m_codeBlock;
ScopeChainNode* m_scopeChain;
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(ErrorConstructor);
+
ErrorConstructor::ErrorConstructor(ExecState* exec, FunctionPrototype* functionPrototype, ErrorPrototype* errorPrototype)
- : InternalFunction(functionPrototype, Identifier(exec, errorPrototype->classInfo()->className))
+ : InternalFunction(exec, functionPrototype, Identifier(exec, errorPrototype->classInfo()->className))
{
// ECMA 15.11.3.1 Error.prototype
putDirect(exec->propertyNames().prototype, errorPrototype, DontEnum | DontDelete | ReadOnly);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(ErrorPrototype);
+
static JSValue* errorProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
// ECMA 15.9.4
putDirect(exec->propertyNames().name, jsString(exec, "Error"), DontEnum);
putDirect(exec->propertyNames().message, jsString(exec, "Unknown error"), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
}
JSValue* errorProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(FunctionConstructor);
+
FunctionConstructor::FunctionConstructor(ExecState* exec, FunctionPrototype* functionPrototype)
- : InternalFunction(functionPrototype, Identifier(exec, functionPrototype->classInfo()->className))
+ : InternalFunction(exec, functionPrototype, Identifier(exec, functionPrototype->classInfo()->className))
{
putDirect(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(FunctionPrototype);
+
static JSValue* functionProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* functionProtoFuncApply(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* functionProtoFuncCall(ExecState*, JSObject*, JSValue*, const ArgList&);
FunctionPrototype::FunctionPrototype(ExecState* exec)
+ : InternalFunction(exec)
{
putDirect(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, this, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, this, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);
}
static JSValue* callFunctionPrototype(ExecState*, JSObject*, JSValue*, const ArgList&)
JSValue* functionProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisValue->isObject(&InternalFunction::info))
- return throwError(exec, TypeError);
-
- InternalFunction* function = static_cast<InternalFunction*>(thisValue);
+ if (thisValue->isObject(&JSFunction::info)) {
+ JSFunction* function = static_cast<JSFunction*>(thisValue);
+ return jsString(exec, "function " + function->name(exec) + "(" + function->m_body->paramString() + ") " + function->m_body->toSourceString());
+ }
- if (function->inherits(&JSFunction::info)) {
- JSFunction* fi = static_cast<JSFunction*>(thisValue);
- return jsString(exec, "function " + fi->functionName().ustring() + "(" + fi->m_body->paramString() + ") " + fi->m_body->toSourceString());
+ if (thisValue->isObject(&InternalFunction::info)) {
+ InternalFunction* function = static_cast<InternalFunction*>(thisValue);
+ return jsString(exec, "function " + function->name(exec) + "() {\n [native code]\n}");
}
- return jsString(exec, "function " + function->functionName().ustring() + "() {\n [native code]\n}");
+ return throwError(exec, TypeError);
}
JSValue* functionProtoFuncApply(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(GlobalEvalFunction);
+
GlobalEvalFunction::GlobalEvalFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, NativeFunction function, JSGlobalObject* cachedGlobalObject)
: PrototypeFunction(exec, functionPrototype, len, name, function)
, m_cachedGlobalObject(cachedGlobalObject)
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(InternalFunction);
+
const ClassInfo InternalFunction::info = { "Function", 0, 0, 0 };
-InternalFunction::InternalFunction()
+InternalFunction::InternalFunction(ExecState* exec)
{
+ putDirect(exec->propertyNames().name, jsString(exec, exec->propertyNames().nullIdentifier.ustring()), DontDelete | ReadOnly | DontEnum);
}
-InternalFunction::InternalFunction(FunctionPrototype* prototype, const Identifier& name)
+InternalFunction::InternalFunction(ExecState* exec, FunctionPrototype* prototype, const Identifier& name)
: JSObject(prototype)
- , m_name(name)
-{
-}
-
-bool InternalFunction::implementsHasInstance() const
{
- return true;
+ putDirect(exec->propertyNames().name, jsString(exec, name.ustring()), DontDelete | ReadOnly | DontEnum);
}
-bool InternalFunction::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+const UString& InternalFunction::name(ExecState* exec)
{
- if (propertyName == exec->propertyNames().name) {
- slot.setCustom(this, nameGetter);
- return true;
- }
-
- return JSObject::getOwnPropertySlot(exec, propertyName, slot);
+ JSValue* v = getDirect(exec->propertyNames().name);
+ ASSERT(v->isString());
+ return static_cast<JSString*>(v)->value();
}
-void InternalFunction::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
-{
- if (propertyName == exec->propertyNames().name)
- return;
- JSObject::put(exec, propertyName, value);
-}
-
-bool InternalFunction::deleteProperty(ExecState* exec, const Identifier& propertyName)
-{
- if (propertyName == exec->propertyNames().name)
- return false;
- return JSObject::deleteProperty(exec, propertyName);
-}
-
-JSValue* InternalFunction::nameGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
+bool InternalFunction::implementsHasInstance() const
{
- InternalFunction* thisObj = static_cast<InternalFunction*>(slot.slotBase());
- return jsString(exec, thisObj->functionName().ustring());
+ return true;
}
} // namespace KJS
public:
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
-
- virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
- virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
- virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
-
- const Identifier& functionName() const { return m_name; }
+
+ const UString& name(ExecState*);
protected:
- InternalFunction();
- InternalFunction(FunctionPrototype*, const Identifier&);
+ InternalFunction(ExecState*);
+ InternalFunction(ExecState*, FunctionPrototype*, const Identifier&);
private:
- static JSValue* nameGetter(ExecState*, const Identifier&, const PropertySlot&);
virtual CallType getCallData(CallData&) = 0;
virtual bool implementsHasInstance() const;
-
- Identifier m_name;
};
} // namespace KJS
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(JSActivation);
+
const ClassInfo JSActivation::info = { "JSActivation", 0, 0, 0 };
JSActivation::JSActivation(PassRefPtr<FunctionBodyNode> functionBody, Register* registers)
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(JSArray);
+
// Overview of JSArray
//
// Properties of JSArray objects may be stored in one of three locations:
{
unsigned initialCapacity = min(initialLength, MIN_SPARSE_ARRAY_INDEX);
- m_length = initialLength;
- m_fastAccessCutoff = 0;
m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
+ m_fastAccessCutoff = 0;
m_storage->m_vectorLength = initialCapacity;
+ m_storage->m_length = initialLength;
Heap::heap(this)->reportExtraMemoryCost(initialCapacity * sizeof(JSValue*));
{
unsigned length = list.size();
- m_length = length;
m_fastAccessCutoff = length;
ArrayStorage* storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(length)));
storage->m_vectorLength = length;
storage->m_numValuesInVector = length;
storage->m_sparseValueMap = 0;
+ storage->m_length = length;
size_t i = 0;
ArgList::const_iterator end = list.end();
{
ArrayStorage* storage = m_storage;
- if (i >= m_length) {
+ if (i >= storage->m_length) {
if (i > MAX_ARRAY_INDEX)
return getOwnPropertySlot(exec, Identifier::from(exec, i), slot);
return false;
bool JSArray::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
if (propertyName == exec->propertyNames().length) {
- slot.setValue(jsNumber(exec, getLength()));
+ slot.setValue(jsNumber(exec, length()));
return true;
}
{
checkConsistency();
- unsigned length = m_length;
+ unsigned length = m_storage->m_length;
if (i >= length && i <= MAX_ARRAY_INDEX) {
length = i + 1;
- m_length = length;
+ m_storage->m_length = length;
}
if (i < m_storage->m_vectorLength) {
return;
}
valueSlot = value;
- if (++m_storage->m_numValuesInVector == m_length)
- m_fastAccessCutoff = m_length;
+ if (++m_storage->m_numValuesInVector == m_storage->m_length)
+ m_fastAccessCutoff = m_storage->m_length;
checkConsistency();
return;
}
ArrayStorage* storage = m_storage;
- unsigned usedVectorLength = min(m_length, storage->m_vectorLength);
+ unsigned usedVectorLength = min(storage->m_length, storage->m_vectorLength);
for (unsigned i = 0; i < usedVectorLength; ++i) {
if (storage->m_vector[i])
propertyNames.add(Identifier::from(exec, i));
ArrayStorage* storage = m_storage;
- unsigned length = m_length;
+ unsigned length = m_storage->m_length;
if (newLength < length) {
if (m_fastAccessCutoff > newLength)
}
}
- m_length = newLength;
+ m_storage->m_length = newLength;
checkConsistency();
}
ArrayStorage* storage = m_storage;
- unsigned usedVectorLength = min(m_length, storage->m_vectorLength);
+ unsigned usedVectorLength = min(storage->m_length, storage->m_vectorLength);
for (unsigned i = 0; i < usedVectorLength; ++i) {
JSValue* value = storage->m_vector[i];
if (value && !value->marked())
// The maximum tree depth is compiled in - but the caller is clearly up to no good
// if a larger array is passed.
- ASSERT(m_length <= static_cast<unsigned>(std::numeric_limits<int>::max()));
- if (m_length > static_cast<unsigned>(std::numeric_limits<int>::max()))
+ ASSERT(m_storage->m_length <= static_cast<unsigned>(std::numeric_limits<int>::max()));
+ if (m_storage->m_length > static_cast<unsigned>(std::numeric_limits<int>::max()))
return;
- if (!m_length)
+ if (!m_storage->m_length)
return;
- unsigned usedVectorLength = min(m_length, m_storage->m_vectorLength);
+ unsigned usedVectorLength = min(m_storage->m_length, m_storage->m_vectorLength);
AVLTree<AVLTreeAbstractorForArrayCompare, 44> tree; // Depth 44 is enough for 2^31 items
tree.abstractor().m_exec = exec;
ArrayStorage* storage = m_storage;
- unsigned usedVectorLength = min(m_length, storage->m_vectorLength);
+ unsigned usedVectorLength = min(m_storage->m_length, storage->m_vectorLength);
unsigned numDefined = 0;
unsigned numUndefined = 0;
if (type == SortConsistencyCheck)
ASSERT(!m_storage->m_sparseValueMap);
- ASSERT(m_fastAccessCutoff <= m_length);
+ ASSERT(m_fastAccessCutoff <= m_storage->m_length);
ASSERT(m_fastAccessCutoff <= m_storage->m_numValuesInVector);
unsigned numValuesInVector = 0;
for (unsigned i = 0; i < m_storage->m_vectorLength; ++i) {
if (JSValue* value = m_storage->m_vector[i]) {
- ASSERT(i < m_length);
+ ASSERT(i < m_storage->m_length);
if (type != DestructorConsistencyCheck)
value->type(); // Likely to crash if the object was deallocated.
++numValuesInVector;
SparseArrayValueMap::iterator end = m_storage->m_sparseValueMap->end();
for (SparseArrayValueMap::iterator it = m_storage->m_sparseValueMap->begin(); it != end; ++it) {
unsigned index = it->first;
- ASSERT(index < m_length);
+ ASSERT(index < m_storage->m_length);
ASSERT(index >= m_storage->m_vectorLength);
ASSERT(index <= MAX_ARRAY_INDEX);
ASSERT(it->second);
typedef HashMap<unsigned, JSValue*> SparseArrayValueMap;
struct ArrayStorage {
+ unsigned m_length;
unsigned m_vectorLength;
unsigned m_numValuesInVector;
SparseArrayValueMap* m_sparseValueMap;
static const ClassInfo info;
- unsigned getLength() const { return m_length; }
+ unsigned length() const { return m_storage->m_length; }
void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
void sort(ExecState*);
enum ConsistencyCheckType { NormalConsistencyCheck, DestructorConsistencyCheck, SortConsistencyCheck };
void checkConsistency(ConsistencyCheckType = NormalConsistencyCheck);
- unsigned m_length;
unsigned m_fastAccessCutoff;
ArrayStorage* m_storage;
};
// Base implementation, but for non-object classes implements getPropertySlot.
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
+
+ intptr_t reserved; // Reserved for work in progress.
};
inline JSCell::JSCell()
#include "config.h"
#include "JSFunction.h"
+#include "CommonIdentifiers.h"
#include "ExecState.h"
#include "FunctionPrototype.h"
#include "JSGlobalObject.h"
namespace KJS {
-const ClassInfo JSFunction::info = { "Function", &InternalFunction::info, 0, 0 };
+ASSERT_CLASS_FITS_IN_CELL(JSFunction);
+
+const ClassInfo JSFunction::info = { "Function", 0, 0, 0 };
JSFunction::JSFunction(ExecState* exec, const Identifier& name, FunctionBodyNode* body, ScopeChainNode* scopeChainNode)
- : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), name)
+ : Base(exec, exec->lexicalGlobalObject()->functionPrototype(), name)
, m_body(body)
, m_scopeChain(scopeChainNode)
{
void JSFunction::mark()
{
- InternalFunction::mark();
+ Base::mark();
m_body->mark();
m_scopeChain.mark();
}
return true;
}
- return InternalFunction::getOwnPropertySlot(exec, propertyName, slot);
+ return Base::getOwnPropertySlot(exec, propertyName, slot);
}
void JSFunction::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
{
if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
return;
- InternalFunction::put(exec, propertyName, value);
+ Base::put(exec, propertyName, value);
}
bool JSFunction::deleteProperty(ExecState* exec, const Identifier& propertyName)
{
if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
return false;
- return InternalFunction::deleteProperty(exec, propertyName);
+ return Base::deleteProperty(exec, propertyName);
}
/* Returns the parameter name corresponding to the given index. eg:
class JSGlobalObject;
class JSFunction : public InternalFunction {
+ typedef InternalFunction Base;
public:
JSFunction(ExecState*, const Identifier&, FunctionBodyNode*, ScopeChainNode*);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(JSGlobalObject);
+
// Default number of ticks before a timeout check should be done.
static const int initialTickCountThreshold = 255;
// Set global functions.
d()->evalFunction = new (exec) GlobalEvalFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);
- putDirectFunction(d()->evalFunction, DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
+ putDirectFunction(exec, d()->evalFunction, DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
#ifndef NDEBUG
- putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum);
#endif
// Set prototype, and also insert the object prototype at the end of the chain.
, globalScopeChain(globalObject, thisValue)
{
}
+
+ virtual ~JSGlobalObjectData()
+ {
+ }
JSGlobalObject* next;
JSGlobalObject* prev;
}
protected:
- JSGlobalObject(JSValue* prototype, JSObject* globalThisValue)
- : JSVariableObject(prototype, new JSGlobalObjectData(this, globalThisValue))
+ JSGlobalObject(JSValue* prototype, JSGlobalObjectData* d, JSObject* globalThisValue)
+ : JSVariableObject(prototype, d)
{
init(globalThisValue);
}
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(JSNotAnObject);
+
// JSValue methods
JSValue* JSNotAnObject::toPrimitive(ExecState* exec, JSType) const
{
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(JSObject);
+
void JSObject::mark()
{
JSCell::mark();
m_propertyMap.remove(propertyName);
}
-void JSObject::putDirectFunction(InternalFunction* function, unsigned attr)
+void JSObject::putDirectFunction(ExecState* exec, InternalFunction* function, unsigned attr)
{
- putDirect(function->functionName(), function, attr);
+ putDirect(Identifier(exec, function->name(exec)), function, attr);
}
NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue** location)
virtual void mark();
virtual JSType type() const;
- /**
- * A pointer to a ClassInfo struct for this class. This provides a basic
- * facility for run-time type information, and can be used to check an
- * object's class an inheritance (see inherits()). This should
- * always return a statically declared pointer, or 0 to indicate that
- * there is no class information.
- *
- * This is primarily useful if you have application-defined classes that you
- * wish to check against for casting purposes.
- *
- * For example, to specify the class info for classes FooImp and BarImp,
- * where FooImp inherits from BarImp, you would add the following in your
- * class declarations:
- *
- * \code
- * class BarImp : public JSObject {
- * virtual const ClassInfo *classInfo() const { return &info; }
- * static const ClassInfo info;
- * // ...
- * };
- *
- * class FooImp : public JSObject {
- * virtual const ClassInfo *classInfo() const { return &info; }
- * static const ClassInfo info;
- * // ...
- * };
- * \endcode
- *
- * And in your source file:
- *
- * \code
- * const ClassInfo BarImp::info = { "Bar", 0, 0, 0 }; // no parent class
- * const ClassInfo FooImp::info = { "Foo", &BarImp::info, 0, 0 };
- * \endcode
- *
- * @see inherits()
- */
-
- /**
- * Checks whether this object inherits from the class with the specified
- * classInfo() pointer. This requires that both this class and the other
- * class return a non-NULL pointer for their classInfo() methods (otherwise
- * it will return false).
- *
- * For example, for two JSObject pointers obj1 and obj2, you can check
- * if obj1's class inherits from obj2's class using the following:
- *
- * if (obj1->inherits(obj2->classInfo())) {
- * // ...
- * }
- *
- * If you have a handle to a statically declared ClassInfo, such as in the
- * classInfo() example, you can check for inheritance without needing
- * an instance of the other class:
- *
- * if (obj1->inherits(FooImp::info)) {
- * // ...
- * }
- *
- * @param cinfo The ClassInfo pointer for the class you want to check
- * inheritance against.
- * @return true if this object's class inherits from class with the
- * ClassInfo pointer specified in cinfo
- */
bool inherits(const ClassInfo* classInfo) const { return isObject(classInfo); } // FIXME: Merge with isObject.
- // internal properties (ECMA 262-3 8.6.2)
-
- /**
- * Returns the prototype of this object. Note that this is not the same as
- * the "prototype" property.
- *
- * See ECMA 8.6.2
- *
- * @return The object's prototype
- */
JSValue* prototype() const;
void setPrototype(JSValue* prototype);
- /**
- * Returns the class name of the object
- *
- * See ECMA 8.6.2
- *
- * @return The object's class name
- */
- /**
- * Implementation of the [[Class]] internal property (implemented by all
- * Objects)
- *
- * The default implementation uses classInfo().
- * You should either implement classInfo(), or
- * if you simply need a classname, you can reimplement className()
- * instead.
- */
virtual UString className() const;
- /**
- * Retrieves the specified property from the object. If neither the object
- * or any other object in its prototype chain have the property, this
- * function will return Undefined.
- *
- * See ECMA 8.6.2.1
- *
- * @param exec The current execution state
- * @param propertyName The name of the property to retrieve
- *
- * @return The specified property, or Undefined
- */
JSValue* get(ExecState*, const Identifier& propertyName) const;
JSValue* get(ExecState*, unsigned propertyName) const;
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
- /**
- * Sets the specified property.
- *
- * See ECMA 8.6.2.2
- *
- * @param exec The current execution state
- * @param propertyName The name of the property to set
- * @param propertyValue The value to set
- */
virtual void put(ExecState*, const Identifier& propertyName, JSValue* value);
virtual void put(ExecState*, unsigned propertyName, JSValue* value);
virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue* value, unsigned attributes);
virtual void putWithAttributes(ExecState*, unsigned propertyName, JSValue* value, unsigned attributes);
- /**
- * Checks if a property is enumerable, that is if it doesn't have the DontEnum
- * flag set
- *
- * See ECMA 15.2.4
- * @param exec The current execution state
- * @param propertyName The name of the property
- * @return true if the property is enumerable, otherwise false
- */
bool propertyIsEnumerable(ExecState*, const Identifier& propertyName) const;
- /**
- * Checks to see whether the object (or any object in its prototype chain)
- * has a property with the specified name.
- *
- * See ECMA 8.6.2.4
- *
- * @param exec The current execution state
- * @param propertyName The name of the property to check for
- * @return true if the object has the property, otherwise false
- */
bool hasProperty(ExecState*, const Identifier& propertyName) const;
bool hasProperty(ExecState*, unsigned propertyName) const;
bool hasOwnProperty(ExecState*, const Identifier& propertyName) const;
- /**
- * Removes the specified property from the object.
- *
- * See ECMA 8.6.2.5
- *
- * @param exec The current execution state
- * @param propertyName The name of the property to delete
- * @return true if the property was successfully deleted or did not
- * exist on the object. false if deleting the specified property is not
- * allowed.
- */
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
virtual bool deleteProperty(ExecState*, unsigned propertyName);
- /**
- * Converts the object into a primitive value. The value return may differ
- * depending on the supplied hint
- *
- * See ECMA 8.6.2.6
- *
- * @param exec The current execution state
- * @param hint The desired primitive type to convert to
- * @return A primitive value converted from the objetc. Note that the
- * type of primitive value returned may not be the same as the requested
- * hint.
- */
- /**
- * Implementation of the [[DefaultValue]] internal property (implemented by
- * all Objects)
- */
virtual JSValue* defaultValue(ExecState*, JSType hint) const;
- /**
- * Whether or not the object implements the hasInstance() method. If this
- * returns false you should not call the hasInstance() method on this
- * object (typically, an assertion will fail to indicate this).
- *
- * @return true if this object implements the hasInstance() method,
- * otherwise false
- */
virtual bool implementsHasInstance() const;
-
- /**
- * Checks whether value delegates behavior to this object. Used by the
- * instanceof operator.
- *
- * @param exec The current execution state
- * @param value The value to check
- * @return true if value delegates behavior to this object, otherwise
- * false
- */
virtual bool hasInstance(ExecState*, JSValue*);
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
virtual bool masqueradeAsUndefined() const { return false; }
// This get function only looks at the property map.
- // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want
- // to look up in the prototype, it might already exist there)
JSValue* getDirect(const Identifier& propertyName) const { return m_propertyMap.get(propertyName); }
JSValue** getDirectLocation(const Identifier& propertyName) { return m_propertyMap.getLocation(propertyName); }
JSValue** getDirectLocation(const Identifier& propertyName, bool& isWriteable) { return m_propertyMap.getLocation(propertyName, isWriteable); }
bool hasCustomProperties() { return !m_propertyMap.isEmpty(); }
// convenience to add a function property under the function's own built-in name
- void putDirectFunction(InternalFunction*, unsigned attr = 0);
+ void putDirectFunction(ExecState*, InternalFunction*, unsigned attr = 0);
void fillGetterPropertySlot(PropertySlot&, JSValue** location);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(JSStaticScopeObject);
+
JSObject* JSStaticScopeObject::toThisObject(ExecState* exec) const
{
return exec->globalThisValue();
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(JSWrapperObject);
+
void JSWrapperObject::mark()
{
JSObject::mark();
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(MathObject);
+
static JSValue* mathProtoFuncAbs(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* mathProtoFuncACos(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* mathProtoFuncASin(ExecState*, JSObject*, JSValue*, const ArgList&);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(NativeErrorConstructor);
+
const ClassInfo NativeErrorConstructor::info = { "Function", &InternalFunction::info, 0, 0 };
NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, FunctionPrototype* functionPrototype, NativeErrorPrototype* nativeErrorPrototype)
- : InternalFunction(functionPrototype, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString()))
+ : InternalFunction(exec, functionPrototype, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString()))
, m_proto(nativeErrorPrototype)
{
putDirect(exec->propertyNames().length, jsNumber(exec, 1), DontDelete | ReadOnly | DontEnum); // ECMA 15.11.7.5
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(NativeErrorPrototype);
+
NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, ErrorPrototype* errorPrototype, const UString& name, const UString& message)
: JSObject(errorPrototype)
{
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(NativeErrorConstructor);
+
const ClassInfo NumberConstructor::info = { "Function", &InternalFunction::info, 0, ExecState::numberTable };
/* Source for NumberObject.lut.h
@end
*/
NumberConstructor::NumberConstructor(ExecState* exec, FunctionPrototype* functionPrototype, NumberPrototype* numberPrototype)
- : InternalFunction(functionPrototype, Identifier(exec, numberPrototype->info.className))
+ : InternalFunction(exec, functionPrototype, Identifier(exec, numberPrototype->info.className))
{
// Number.Prototype
putDirect(exec->propertyNames().prototype, numberPrototype, DontEnum | DontDelete | ReadOnly);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(NumberObject);
+
const ClassInfo NumberObject::info = { "Number", 0, 0, 0 };
NumberObject::NumberObject(JSObject* prototype)
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(NumberPrototype);
+
static JSValue* numberProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* numberProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* numberProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
// The constructor will be added later, after NumberConstructor has been constructed
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
}
// ------------------------------ Functions ---------------------------
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(ObjectConstructor);
+
ObjectConstructor::ObjectConstructor(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
- : InternalFunction(functionPrototype, Identifier(exec, "Object"))
+ : InternalFunction(exec, functionPrototype, Identifier(exec, "Object"))
{
// ECMA 15.2.3.1
putDirect(exec->propertyNames().prototype, objectPrototype, DontEnum | DontDelete | ReadOnly);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(ObjectPrototype);
+
static JSValue* objectProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* objectProtoFuncHasOwnProperty(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* objectProtoFuncIsPrototypeOf(ExecState*, JSObject*, JSValue*, const ArgList&);
ObjectPrototype::ObjectPrototype(ExecState* exec, FunctionPrototype* functionPrototype)
: JSObject() // [[Prototype]] is null
{
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
// Mozilla extensions
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
}
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(PrototypeFunction);
+
PrototypeFunction::PrototypeFunction(ExecState* exec, int length, const Identifier& name, NativeFunction function)
- : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), name)
+ : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), name)
, m_function(function)
{
ASSERT_ARG(function, function);
}
PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functionPrototype, int length, const Identifier& name, NativeFunction function)
- : InternalFunction(functionPrototype, name)
+ : InternalFunction(exec, functionPrototype, name)
, m_function(function)
{
ASSERT_ARG(function, function);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(RegExpConstructor);
+
const ClassInfo RegExpConstructor::info = { "Function", &InternalFunction::info, 0, ExecState::regExpConstructorTable };
/* Source for RegExpConstructor.lut.h
};
RegExpConstructor::RegExpConstructor(ExecState* exec, FunctionPrototype* functionPrototype, RegExpPrototype* regExpPrototype)
- : InternalFunction(functionPrototype, Identifier(exec, "RegExp"))
+ : InternalFunction(exec, functionPrototype, Identifier(exec, "RegExp"))
, d(new RegExpConstructorPrivate)
{
// ECMA 15.10.5.1 RegExp.prototype
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(RegExpObject);
+
const ClassInfo RegExpObject::info = { "RegExp", 0, 0, ExecState::regExpTable };
/* Source for RegExpObject.lut.h
RegExpObject::RegExpObject(RegExpPrototype* regExpPrototype, PassRefPtr<RegExp> regExp)
: JSObject(regExpPrototype)
- , m_regExp(regExp)
- , m_lastIndex(0)
+ , d(new RegExpObjectData(regExp, 0))
{
}
{
switch (token) {
case Global:
- return jsBoolean(m_regExp->global());
+ return jsBoolean(d->regExp->global());
case IgnoreCase:
- return jsBoolean(m_regExp->ignoreCase());
+ return jsBoolean(d->regExp->ignoreCase());
case Multiline:
- return jsBoolean(m_regExp->multiline());
+ return jsBoolean(d->regExp->multiline());
case Source:
- return jsString(exec, m_regExp->pattern());
+ return jsString(exec, d->regExp->pattern());
case LastIndex:
- return jsNumber(exec, m_lastIndex);
+ return jsNumber(exec, d->lastIndex);
}
ASSERT_NOT_REACHED();
{
UNUSED_PARAM(token);
ASSERT(token == LastIndex);
- m_lastIndex = value->toInteger(exec);
+ d->lastIndex = value->toInteger(exec);
}
bool RegExpObject::match(ExecState* exec, const ArgList& args)
bool global = get(exec, exec->propertyNames().global)->toBoolean(exec);
int lastIndex = 0;
if (global) {
- if (m_lastIndex < 0 || m_lastIndex > input.size()) {
- m_lastIndex = 0;
+ if (d->lastIndex < 0 || d->lastIndex > input.size()) {
+ d->lastIndex = 0;
return false;
}
- lastIndex = static_cast<int>(m_lastIndex);
+ lastIndex = static_cast<int>(d->lastIndex);
}
int foundIndex;
int foundLength;
- regExpObj->performMatch(m_regExp.get(), input, lastIndex, foundIndex, foundLength);
+ regExpObj->performMatch(d->regExp.get(), input, lastIndex, foundIndex, foundLength);
if (global) {
lastIndex = foundIndex < 0 ? 0 : foundIndex + foundLength;
- m_lastIndex = lastIndex;
+ d->lastIndex = lastIndex;
}
return foundIndex >= 0;
RegExpObject(RegExpPrototype*, PassRefPtr<RegExp>);
virtual ~RegExpObject();
- void setRegExp(PassRefPtr<RegExp> r) { m_regExp = r; }
- RegExp* regExp() const { return m_regExp.get(); }
+ void setRegExp(PassRefPtr<RegExp> r) { d->regExp = r; }
+ RegExp* regExp() const { return d->regExp.get(); }
JSValue* test(ExecState*, const ArgList&);
JSValue* exec(ExecState*, const ArgList&);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
- void setLastIndex(double lastIndex) { m_lastIndex = lastIndex; }
+ void setLastIndex(double lastIndex) { d->lastIndex = lastIndex; }
private:
bool match(ExecState*, const ArgList&);
virtual CallType getCallData(CallData&);
-
- RefPtr<RegExp> m_regExp;
- double m_lastIndex;
+
+ struct RegExpObjectData {
+ RegExpObjectData(PassRefPtr<RegExp> regExp_, double lastIndex_)
+ : regExp(regExp_)
+ , lastIndex(lastIndex_)
+ {
+ }
+
+ RefPtr<RegExp> regExp;
+ double lastIndex;
+ };
+
+ OwnPtr<RegExpObjectData> d;
};
} // namespace KJS
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(RegExpPrototype);
+
static JSValue* regExpProtoFuncTest(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* regExpProtoFuncExec(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* regExpProtoFuncCompile(ExecState*, JSObject*, JSValue*, const ArgList&);
RegExpPrototype::RegExpPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
: JSObject(objectPrototype)
{
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
}
// ------------------------------ Functions ---------------------------
virtual UString className() const { return "global"; }
};
COMPILE_ASSERT(!IsInteger<GlobalObject>::value, WTF_IsInteger_GlobalObject_false);
+ASSERT_CLASS_FITS_IN_CELL(GlobalObject);
GlobalObject::GlobalObject(Vector<UString>& arguments)
{
- putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "debug"), functionDebug));
- putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "print"), functionPrint));
- putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "quit"), functionQuit));
- putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "gc"), functionGC));
- putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "version"), functionVersion));
- putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "run"), functionRun));
- putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "load"), functionLoad));
- putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "readline"), functionReadline));
+ putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "debug"), functionDebug));
+ putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "print"), functionPrint));
+ putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "quit"), functionQuit));
+ putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "gc"), functionGC));
+ putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "version"), functionVersion));
+ putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "run"), functionRun));
+ putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "load"), functionLoad));
+ putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "readline"), functionReadline));
JSObject* array = constructEmptyArray(globalExec());
for (size_t i = 0; i < arguments.size(); ++i)
return jsString(exec, s);
}
+ASSERT_CLASS_FITS_IN_CELL(StringConstructor);
+
StringConstructor::StringConstructor(ExecState* exec, FunctionPrototype* functionPrototype, StringPrototype* stringPrototype)
- : InternalFunction(functionPrototype, Identifier(exec, stringPrototype->classInfo()->className))
+ : InternalFunction(exec, functionPrototype, Identifier(exec, stringPrototype->classInfo()->className))
{
// ECMA 15.5.3.1 String.prototype
putDirect(exec->propertyNames().prototype, stringPrototype, ReadOnly | DontEnum | DontDelete);
// ECMA 15.5.3.2 fromCharCode()
- putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
+ putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
// no. of arguments for constructor
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(StringObject);
+
const ClassInfo StringObject::info = { "String", 0, 0, 0 };
StringObject::StringObject(ExecState* exec, JSObject* prototype)
namespace KJS {
+ASSERT_CLASS_FITS_IN_CELL(StringPrototype);
+
static JSValue* stringProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* stringProtoFuncCharAt(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* stringProtoFuncCharCodeAt(ExecState*, JSObject*, JSValue*, const ArgList&);
#include <pthread.h>
#endif
+#define ASSERT_CLASS_FITS_IN_CELL(class) COMPILE_ASSERT(sizeof(class) <= CELL_SIZE, class_fits_in_cell)
+
namespace KJS {
class ArgList;
#include "config.h"
#include "Profiler.h"
+#include "CommonIdentifiers.h"
#include "ExecState.h"
#include "JSFunction.h"
#include "JSGlobalObject.h"
static const char* AnonymousFunction = "(anonymous function)";
static unsigned ProfilesUID = 0;
-static CallIdentifier createCallIdentifier(JSObject*);
-static CallIdentifier createCallIdentifier(const UString& sourceURL, int startingLineNumber);
-static CallIdentifier createCallIdentifierFromFunctionImp(JSFunction*);
+static CallIdentifier createCallIdentifier(ExecState*, JSObject*);
+static CallIdentifier createCallIdentifier(ExecState*, const UString& sourceURL, int startingLineNumber);
+static CallIdentifier createCallIdentifierFromFunctionImp(ExecState*, JSFunction*);
Profiler* Profiler::s_sharedProfiler = 0;
Profiler* Profiler::s_sharedEnabledProfilerReference = 0;
{
ASSERT(!m_currentProfiles.isEmpty());
- dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(calledFunction), exec->lexicalGlobalObject()->profileGroup());
+ dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(exec, calledFunction), exec->lexicalGlobalObject()->profileGroup());
}
void Profiler::willExecute(ExecState* exec, const UString& sourceURL, int startingLineNumber)
{
ASSERT(!m_currentProfiles.isEmpty());
- CallIdentifier callIdentifier = createCallIdentifier(sourceURL, startingLineNumber);
+ CallIdentifier callIdentifier = createCallIdentifier(exec, sourceURL, startingLineNumber);
dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, callIdentifier, exec->lexicalGlobalObject()->profileGroup());
}
{
ASSERT(!m_currentProfiles.isEmpty());
- dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(calledFunction), exec->lexicalGlobalObject()->profileGroup());
+ dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, calledFunction), exec->lexicalGlobalObject()->profileGroup());
}
void Profiler::didExecute(ExecState* exec, const UString& sourceURL, int startingLineNumber)
{
ASSERT(!m_currentProfiles.isEmpty());
- dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(sourceURL, startingLineNumber), exec->lexicalGlobalObject()->profileGroup());
+ dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, sourceURL, startingLineNumber), exec->lexicalGlobalObject()->profileGroup());
}
-CallIdentifier createCallIdentifier(JSObject* calledFunction)
+CallIdentifier createCallIdentifier(ExecState* exec, JSObject* calledFunction)
{
if (calledFunction->inherits(&JSFunction::info))
- return createCallIdentifierFromFunctionImp(static_cast<JSFunction*>(calledFunction));
+ return createCallIdentifierFromFunctionImp(exec, static_cast<JSFunction*>(calledFunction));
if (calledFunction->inherits(&InternalFunction::info))
- return CallIdentifier(static_cast<InternalFunction*>(calledFunction)->functionName().ustring(), "", 0);
+ return CallIdentifier(static_cast<InternalFunction*>(calledFunction)->name(exec), "", 0);
UString name = "(" + calledFunction->className() + " object)";
return CallIdentifier(name, 0, 0);
}
-CallIdentifier createCallIdentifier(const UString& sourceURL, int startingLineNumber)
+CallIdentifier createCallIdentifier(ExecState*, const UString& sourceURL, int startingLineNumber)
{
return CallIdentifier(GlobalCodeExecution, sourceURL, startingLineNumber);
}
-CallIdentifier createCallIdentifierFromFunctionImp(JSFunction* functionImp)
+CallIdentifier createCallIdentifierFromFunctionImp(ExecState* exec, JSFunction* function)
{
- UString name = functionImp->functionName().ustring();
- if (name.isEmpty())
- name = AnonymousFunction;
-
- return CallIdentifier(name, functionImp->m_body->sourceURL(), functionImp->m_body->lineNo());
+ const UString& name = function->name(exec);
+ return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, function->m_body->sourceURL(), function->m_body->lineNo());
}
} // namespace KJS
+2008-08-17 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Cameron Zwarich.
+
+ Made room for a free word in JSCell.
+
+ Changed JSDOMWindowBase to store its auxiliary data in a subclass of
+ JSGlobalData, so the two could share a pointer.
+
+ Added a bunch of ASSERTs, to help catch over-sized objects.
+
2008-08-15 Mark Rowe <mrowe@apple.com>
Reviewed by Dan Bernstein.
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
- projectRoots = (
- "",
- );
targets = (
93F198A508245E59001E9ABC /* WebCore */,
DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
@end
*/
+JSDOMWindowBase::JSDOMWindowBaseData::JSDOMWindowBaseData(PassRefPtr<DOMWindow> window_, JSDOMWindowBase* jsWindow_, JSDOMWindowShell* shell_)
+ : JSGlobalObjectData(jsWindow_, shell_)
+ , impl(window_)
+ , evt(0)
+ , returnValueSlot(0)
+ , shell(shell_)
+{
+}
+
JSDOMWindowBase::JSDOMWindowBase(JSObject* prototype, DOMWindow* window, JSDOMWindowShell* shell)
- : JSGlobalObject(prototype, shell)
- , m_impl(window)
- , d(new JSDOMWindowBasePrivate(shell))
+ : JSGlobalObject(prototype, new JSDOMWindowBaseData(window, this, shell), shell)
{
// Time in milliseconds before the script timeout handler kicks in.
setTimeoutTime(10000);
GlobalPropertyInfo staticGlobals[] = {
GlobalPropertyInfo(Identifier(globalExec(), "document"), jsNull(), DontDelete | ReadOnly),
- GlobalPropertyInfo(Identifier(globalExec(), "window"), d->m_shell, DontDelete | ReadOnly)
+ GlobalPropertyInfo(Identifier(globalExec(), "window"), d()->shell, DontDelete | ReadOnly)
};
addStaticGlobals(staticGlobals, sizeof(staticGlobals) / sizeof(GlobalPropertyInfo));
void JSDOMWindowBase::updateDocument()
{
- ASSERT(m_impl->document());
+ ASSERT(d()->impl->document());
ExecState* exec = globalExec();
- symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, m_impl->document()), DontDelete | ReadOnly);
+ symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, d()->impl->document()), DontDelete | ReadOnly);
}
JSDOMWindowBase::~JSDOMWindowBase()
{
- if (m_impl->frame())
- m_impl->frame()->script()->clearFormerWindow(asJSDOMWindow(this));
+ if (d()->impl->frame())
+ d()->impl->frame()->script()->clearFormerWindow(asJSDOMWindow(this));
clearAllTimeouts();
// Clear any backpointers to the window
- ListenersMap::iterator i2 = d->jsEventListeners.begin();
- ListenersMap::iterator e2 = d->jsEventListeners.end();
+ ListenersMap::iterator i2 = d()->jsEventListeners.begin();
+ ListenersMap::iterator e2 = d()->jsEventListeners.end();
for (; i2 != e2; ++i2)
i2->second->clearWindow();
- i2 = d->jsHTMLEventListeners.begin();
- e2 = d->jsHTMLEventListeners.end();
+ i2 = d()->jsHTMLEventListeners.begin();
+ e2 = d()->jsHTMLEventListeners.end();
for (; i2 != e2; ++i2)
i2->second->clearWindow();
- UnprotectedListenersMap::iterator i1 = d->jsUnprotectedEventListeners.begin();
- UnprotectedListenersMap::iterator e1 = d->jsUnprotectedEventListeners.end();
+ UnprotectedListenersMap::iterator i1 = d()->jsUnprotectedEventListeners.begin();
+ UnprotectedListenersMap::iterator e1 = d()->jsUnprotectedEventListeners.end();
for (; i1 != e1; ++i1)
i1->second->clearWindow();
- i1 = d->jsUnprotectedHTMLEventListeners.begin();
- e1 = d->jsUnprotectedHTMLEventListeners.end();
+ i1 = d()->jsUnprotectedHTMLEventListeners.begin();
+ e1 = d()->jsUnprotectedHTMLEventListeners.end();
for (; i1 != e1; ++i1)
i1->second->clearWindow();
}
case Event_:
if (!allowsAccessFrom(exec))
return jsUndefined();
- if (!d->m_evt)
+ if (!d()->evt)
return jsUndefined();
- return toJS(exec, d->m_evt);
+ return toJS(exec, d()->evt);
case Image:
if (!allowsAccessFrom(exec))
return jsUndefined();
if (!val->isObject())
return 0;
JSObject* object = static_cast<JSObject*>(val);
- ListenersMap& listeners = html ? d->jsHTMLEventListeners : d->jsEventListeners;
+ ListenersMap& listeners = html ? d()->jsHTMLEventListeners : d()->jsEventListeners;
return listeners.get(object);
}
if (!val->isObject())
return 0;
JSObject* object = static_cast<JSObject*>(val);
- UnprotectedListenersMap& listeners = html ? d->jsUnprotectedHTMLEventListeners : d->jsUnprotectedEventListeners;
+ UnprotectedListenersMap& listeners = html ? d()->jsUnprotectedHTMLEventListeners : d()->jsUnprotectedEventListeners;
return listeners.get(object);
}
void JSDOMWindowBase::clearHelperObjectProperties()
{
- d->m_evt = 0;
+ d()->evt = 0;
}
void JSDOMWindowBase::clear()
{
- if (d->m_returnValueSlot && !*d->m_returnValueSlot)
- *d->m_returnValueSlot = getDirect(Identifier(globalExec(), "returnValue"));
+ if (d()->returnValueSlot && !*d()->returnValueSlot)
+ *d()->returnValueSlot = getDirect(Identifier(globalExec(), "returnValue"));
clearAllTimeouts();
clearHelperObjectProperties();
void JSDOMWindowBase::setCurrentEvent(Event* evt)
{
- d->m_evt = evt;
+ d()->evt = evt;
}
Event* JSDOMWindowBase::currentEvent()
{
- return d->m_evt;
+ return d()->evt;
}
JSObject* JSDOMWindowBase::toThisObject(ExecState*) const
JSDOMWindowShell* JSDOMWindowBase::shell() const
{
- return d->m_shell;
+ return d()->shell;
}
JSGlobalData* JSDOMWindowBase::commonJSGlobalData()
void JSDOMWindowBase::setReturnValueSlot(JSValue** slot)
{
- d->m_returnValueSlot = slot;
+ d()->returnValueSlot = slot;
}
////////////////////// timeouts ////////////////////////
void JSDOMWindowBase::clearAllTimeouts()
{
- deleteAllValues(d->m_timeouts);
- d->m_timeouts.clear();
+ deleteAllValues(d()->timeouts);
+ d()->timeouts.clear();
}
int JSDOMWindowBase::installTimeout(ScheduledAction* a, int t, bool singleShot)
int nestLevel = timerNestingLevel + 1;
DOMWindowTimer* timer = new DOMWindowTimer(timeoutId, nestLevel, this, a);
- ASSERT(!d->m_timeouts.get(timeoutId));
- d->m_timeouts.set(timeoutId, timer);
+ ASSERT(!d()->timeouts.get(timeoutId));
+ d()->timeouts.set(timeoutId, timer);
// Use a minimum interval of 10 ms to match other browsers, but only once we've
// nested enough to notice that we're repeating.
// Faster timers might be "better", but they're incompatible.
PausedTimeouts* JSDOMWindowBase::pauseTimeouts()
{
- size_t count = d->m_timeouts.size();
+ size_t count = d()->timeouts.size();
if (count == 0)
return 0;
PausedTimeout* t = new PausedTimeout [count];
PausedTimeouts* result = new PausedTimeouts(t, count);
- JSDOMWindowBasePrivate::TimeoutsMap::iterator it = d->m_timeouts.begin();
+ JSDOMWindowBaseData::TimeoutsMap::iterator it = d()->timeouts.begin();
for (size_t i = 0; i != count; ++i, ++it) {
int timeoutId = it->first;
DOMWindowTimer* timer = it->second;
t[i].repeatInterval = timer->repeatInterval();
t[i].action = timer->takeAction();
}
- ASSERT(it == d->m_timeouts.end());
+ ASSERT(it == d()->timeouts.end());
- deleteAllValues(d->m_timeouts);
- d->m_timeouts.clear();
+ deleteAllValues(d()->timeouts);
+ d()->timeouts.clear();
return result;
}
for (size_t i = 0; i != count; ++i) {
int timeoutId = array[i].timeoutId;
DOMWindowTimer* timer = new DOMWindowTimer(timeoutId, array[i].nestingLevel, this, array[i].action);
- d->m_timeouts.set(timeoutId, timer);
+ d()->timeouts.set(timeoutId, timer);
timer->start(array[i].nextFireInterval, array[i].repeatInterval);
}
delete [] array;
if (timeoutId <= 0)
return;
- delete d->m_timeouts.take(timeoutId);
+ delete d()->timeouts.take(timeoutId);
}
void JSDOMWindowBase::timerFired(DOMWindowTimer* timer)
timer->action()->execute(shell());
// The DOMWindowTimer object may have been deleted or replaced during execution,
// so we re-fetch it.
- timer = d->m_timeouts.get(timeoutId);
+ timer = d()->timeouts.get(timeoutId);
if (!timer)
return;
// Delete timer before executing the action for one-shot timers.
ScheduledAction* action = timer->takeAction();
- d->m_timeouts.remove(timer->timeoutId());
+ d()->timeouts.remove(timer->timeoutId());
delete timer;
action->execute(shell());
JSDOMWindowBase::ListenersMap& JSDOMWindowBase::jsEventListeners()
{
- return d->jsEventListeners;
+ return d()->jsEventListeners;
}
JSDOMWindowBase::ListenersMap& JSDOMWindowBase::jsHTMLEventListeners()
{
- return d->jsHTMLEventListeners;
+ return d()->jsHTMLEventListeners;
}
JSDOMWindowBase::UnprotectedListenersMap& JSDOMWindowBase::jsUnprotectedEventListeners()
{
- return d->jsUnprotectedEventListeners;
+ return d()->jsUnprotectedEventListeners;
}
JSDOMWindowBase::UnprotectedListenersMap& JSDOMWindowBase::jsUnprotectedHTMLEventListeners()
{
- return d->jsUnprotectedHTMLEventListeners;
+ return d()->jsUnprotectedHTMLEventListeners;
}
void DOMWindowTimer::fired()
void updateDocument();
- DOMWindow* impl() const { return m_impl.get(); }
+ DOMWindow* impl() const { return d()->impl.get(); }
void disconnectFrame();
};
private:
+ struct JSDOMWindowBaseData : public JSGlobalObjectData {
+ JSDOMWindowBaseData(PassRefPtr<DOMWindow> window_, JSDOMWindowBase* jsWindow_, JSDOMWindowShell* shell_);
+
+ RefPtr<DOMWindow> impl;
+
+ JSDOMWindowBase::ListenersMap jsEventListeners;
+ JSDOMWindowBase::ListenersMap jsHTMLEventListeners;
+ JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedEventListeners;
+ JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedHTMLEventListeners;
+ Event* evt;
+ KJS::JSValue** returnValueSlot;
+ JSDOMWindowShell* shell;
+
+ typedef HashMap<int, DOMWindowTimer*> TimeoutsMap;
+ TimeoutsMap timeouts;
+ };
+
KJS::JSValue* getListener(KJS::ExecState*, const AtomicString& eventType) const;
void setListener(KJS::ExecState*, const AtomicString& eventType, KJS::JSValue* function);
bool allowsAccessFromPrivate(const KJS::JSGlobalObject*) const;
String crossDomainAccessErrorMessage(const KJS::JSGlobalObject*) const;
-
- RefPtr<DOMWindow> m_impl;
- OwnPtr<JSDOMWindowBasePrivate> d;
+
+ JSDOMWindowBaseData* d() const { return static_cast<JSDOMWindowBaseData*>(KJS::JSVariableObject::d); }
};
// Returns a JSDOMWindow or jsNull()
namespace WebCore {
-struct JSDOMWindowBasePrivate {
- JSDOMWindowBasePrivate(JSDOMWindowShell* shell)
- : m_evt(0)
- , m_returnValueSlot(0)
- , m_shell(shell)
- {
- }
-
- JSDOMWindowBase::ListenersMap jsEventListeners;
- JSDOMWindowBase::ListenersMap jsHTMLEventListeners;
- JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedEventListeners;
- JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedHTMLEventListeners;
- Event* m_evt;
- KJS::JSValue** m_returnValueSlot;
- JSDOMWindowShell* m_shell;
-
- typedef HashMap<int, DOMWindowTimer*> TimeoutsMap;
- TimeoutsMap m_timeouts;
-};
-
inline JSDOMWindow* asJSDOMWindow(KJS::JSGlobalObject* globalObject)
{
return static_cast<JSDOMWindow*>(globalObject);
ALWAYS_INLINE bool JSDOMWindowBase::allowsAccessFromPrivate(const JSGlobalObject* other) const
{
const JSDOMWindow* originWindow = asJSDOMWindow(other);
- const JSDOMWindow* targetWindow = d->m_shell->window();
+ const JSDOMWindow* targetWindow = d()->shell->window();
if (originWindow == targetWindow)
return true;
namespace WebCore {
+ASSERT_CLASS_FITS_IN_CELL(JSDOMWindowShell)
+
const ClassInfo JSDOMWindowShell::s_info = { "JSDOMWindowShell", 0, 0, 0 };
JSDOMWindowShell::JSDOMWindowShell(DOMWindow* domWindow)
using namespace EventNames;
+ASSERT_CLASS_FITS_IN_CELL(JSAbstractEventListener)
+
void JSAbstractEventListener::handleEvent(Event* event, bool isWindowEvent)
{
JSObject* listener = listenerObj();
using namespace KJS;
+ASSERT_CLASS_FITS_IN_CELL(JSEventTargetNode)
+
JSEventTargetNode::JSEventTargetNode(JSObject* prototype, Node* node)
: JSNode(prototype, node)
{
namespace WebCore {
+ASSERT_CLASS_FITS_IN_CELL(JSHTMLInputElementBase)
+
static JSValue* jsHTMLInputElementBaseFunctionSetSelectionRange(ExecState*, JSObject*, JSValue*, const ArgList&);
}
namespace WebCore {
+ASSERT_CLASS_FITS_IN_CELL(JSHTMLOptionElementConstructor)
+
const ClassInfo JSHTMLOptionElementConstructor::s_info = { "OptionConstructor", 0, 0, 0 };
JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor(ExecState* exec, Document* document)
namespace WebCore {
+ASSERT_CLASS_FITS_IN_CELL(JSImageConstructor)
+
const ClassInfo JSImageConstructor::s_info = { "ImageConstructor", 0, 0, 0 };
JSImageConstructor::JSImageConstructor(ExecState* exec, Document* document)
namespace WebCore {
+ASSERT_CLASS_FITS_IN_CELL(JSInspectedObjectWrapper)
+
typedef HashMap<JSObject*, JSInspectedObjectWrapper*> WrapperMap;
typedef HashMap<JSGlobalObject*, WrapperMap*> GlobalObjectWrapperMap;
namespace WebCore {
+ASSERT_CLASS_FITS_IN_CELL(JSInspectorCallbackWrapper)
+
typedef HashMap<JSObject*, JSInspectorCallbackWrapper*> WrapperMap;
static WrapperMap& wrappers()
namespace WebCore {
+ASSERT_CLASS_FITS_IN_CELL(JSNSResolver)
+
JSNSResolver::JSNSResolver(JSValue* resolver)
: m_resolver(resolver)
{
using namespace KJS;
+ASSERT_CLASS_FITS_IN_CELL(JSNamedNodesCollection)
+
const ClassInfo JSNamedNodesCollection::s_info = { "Collection", 0, 0, 0 };
// Such a collection is usually very short-lived, it only exists
// so it shouldn't be a problem that it's storing all the nodes (with the same name). (David)
JSNamedNodesCollection::JSNamedNodesCollection(KJS::JSObject* prototype, const Vector<RefPtr<Node> >& nodes)
: DOMObject(prototype)
- , m_nodes(nodes)
+ , m_nodes(new Vector<RefPtr<Node> >(nodes))
{
}
JSValue* JSNamedNodesCollection::lengthGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
JSNamedNodesCollection* thisObj = static_cast<JSNamedNodesCollection*>(slot.slotBase());
- return jsNumber(exec, thisObj->m_nodes.size());
+ return jsNumber(exec, thisObj->m_nodes->size());
}
JSValue* JSNamedNodesCollection::indexGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
JSNamedNodesCollection *thisObj = static_cast<JSNamedNodesCollection*>(slot.slotBase());
- return toJS(exec, thisObj->m_nodes[slot.index()].get());
+ return toJS(exec, (*thisObj->m_nodes)[slot.index()].get());
}
bool JSNamedNodesCollection::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
bool ok;
unsigned index = propertyName.toUInt32(&ok);
- if (ok && index < m_nodes.size()) {
+ if (ok && index < m_nodes->size()) {
slot.setCustomIndex(this, index, indexGetter);
return true;
}
// document.formName.name result by id as well as be index.
AtomicString atomicPropertyName = propertyName;
- for (unsigned i = 0; i < m_nodes.size(); i++) {
- Node* node = m_nodes[i].get();
+ for (unsigned i = 0; i < m_nodes->size(); i++) {
+ Node* node = (*m_nodes)[i].get();
if (node->hasAttributes() && node->attributes()->id() == atomicPropertyName) {
slot.setCustomIndex(this, i, indexGetter);
return true;
static KJS::JSValue* lengthGetter(KJS::ExecState*, const KJS::Identifier&, const KJS::PropertySlot&);
static KJS::JSValue* indexGetter(KJS::ExecState*, const KJS::Identifier&, const KJS::PropertySlot&);
- Vector<RefPtr<Node> > m_nodes;
+ OwnPtr<Vector<RefPtr<Node> > > m_nodes;
};
} // namespace WebCore
using namespace KJS;
+ASSERT_CLASS_FITS_IN_CELL(JSNodeFilterCondition)
+
JSNodeFilterCondition::JSNodeFilterCondition(JSValue* filter)
: m_filter(filter)
{
namespace WebCore {
+ASSERT_CLASS_FITS_IN_CELL(JSQuarantinedObjectWrapper)
+
const ClassInfo JSQuarantinedObjectWrapper::s_info = { "JSQuarantinedObjectWrapper", 0, 0, 0 };
JSQuarantinedObjectWrapper* JSQuarantinedObjectWrapper::asWrapper(JSValue* value)
namespace WebCore {
+ASSERT_CLASS_FITS_IN_CELL(JSRGBColor)
+
const ClassInfo JSRGBColor::s_info = { "RGBColor", 0, &JSRGBColorTable, 0 };
/*
namespace WebCore {
+ASSERT_CLASS_FITS_IN_CELL(JSXMLHttpRequestConstructor)
+
const ClassInfo JSXMLHttpRequestConstructor::s_info = { "XMLHttpRequestConstructor", 0, 0, 0 };
JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor(ExecState* exec, Document* document)
namespace WebCore {
+ASSERT_CLASS_FITS_IN_CELL(JSXSLTProcessorConstructor)
+
const ClassInfo JSXSLTProcessorConstructor::s_info = { "XSLTProcessorConsructor", 0, 0, 0 };
JSXSLTProcessorConstructor::JSXSLTProcessorConstructor(ExecState* exec)
push(@implContent, "\nusing namespace KJS;\n\n");
push(@implContent, "namespace WebCore {\n\n");
+ push(@implContent, "ASSERT_CLASS_FITS_IN_CELL($className)\n\n");
+
# - Add all attributes in a hashtable definition
my $numAttributes = @{$dataNode->attributes};
$numAttributes++ if $dataNode->extendedAttributes->{"GenerateConstructor"};
// the requested Java Array type requested, unless the array type is some object array
// other than a string.
JSArray *jsArray = static_cast<JSArray *>(value);
- unsigned length = jsArray->getLength();
+ unsigned length = jsArray->length();
jobjectArray jarray = 0;
// Build the correct array type
using namespace Bindings;
+ASSERT_CLASS_FITS_IN_CELL(RuntimeMethod);
+
RuntimeMethod::RuntimeMethod(ExecState *exec, const Identifier &ident, Bindings::MethodList &m)
- : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), ident)
+ : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), ident)
, _methodList(new MethodList(m))
{
}
+2008-08-17 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Cameron Zwarich.
+
+ Made room for a free word in JSCell.
+
+ (Updated for JavaScriptCore changes.)
+
2008-08-15 Mark Rowe <mrowe@apple.com>
Rubber-stamped by Geoff Garen.
: m_callingDelegate(false)
{
attach(globalObject);
- DebuggerCallFrame globalCallFrame(globalObject, 0, globalObject->globalScopeChain().node(), 0, 0);
+ DebuggerCallFrame globalCallFrame(0, globalObject, 0, globalObject->globalScopeChain().node(), 0, 0);
callEvent(globalCallFrame, 0, -1);
}
JSArray* array = static_cast<JSArray*>(object);
aeDesc = [NSAppleEventDescriptor listDescriptor];
- unsigned numItems = array->getLength();
+ unsigned numItems = array->length();
for (unsigned i = 0; i < numItems; ++i)
[aeDesc insertDescriptor:aeDescFromJSValue(exec, array->get(exec, i)) atIndex:0];