Changeset 35807 in webkit
- Timestamp:
- Aug 17, 2008, 1:23:49 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 85 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSCallbackFunction.cpp
r35478 r35807 37 37 namespace KJS { 38 38 39 ASSERT_CLASS_FITS_IN_CELL(JSCallbackFunction); 40 39 41 const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 }; 40 42 41 43 JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name) 42 : InternalFunction(exec ->lexicalGlobalObject()->functionPrototype(), name)44 : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), name) 43 45 , m_callback(callback) 44 46 { -
trunk/JavaScriptCore/API/JSCallbackObject.cpp
r32652 r35807 33 33 namespace KJS { 34 34 35 ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSObject>); 36 ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSGlobalObject>); 37 35 38 // Define the two types of JSCallbackObjects we support. 36 39 template <> const ClassInfo JSCallbackObject<JSObject>::info = { "CallbackObject", 0, 0, 0 }; 37 40 template <> const ClassInfo JSCallbackObject<JSGlobalObject>::info = { "CallbackGlobalObject", 0, 0, 0 }; 38 41 39 COMPILE_ASSERT(sizeof(JSCallbackObject<JSGlobalObject>) <= CELL_SIZE, global_callback_object_fits_in_cell);40 41 42 } // namespace KJS -
trunk/JavaScriptCore/API/JSCallbackObject.h
r34754 r35807 47 47 static const ClassInfo info; 48 48 49 JSClassRef classRef() const { return m_c lass; }49 JSClassRef classRef() const { return m_callbackObjectData->jsClass; } 50 50 bool inherits(JSClassRef) const; 51 51 … … 83 83 static JSValue* staticFunctionGetter(ExecState*, const Identifier&, const PropertySlot&); 84 84 static JSValue* callbackGetter(ExecState*, const Identifier&, const PropertySlot&); 85 86 struct JSCallbackObjectData { 87 JSCallbackObjectData(void* privateData_, JSClassRef jsClass_) 88 : privateData(privateData_) 89 , jsClass(jsClass_) 90 { 91 JSClassRetain(jsClass); 92 } 93 94 ~JSCallbackObjectData() 95 { 96 JSClassRelease(jsClass); 97 } 98 99 void* privateData; 100 JSClassRef jsClass; 101 }; 85 102 86 void* m_privateData; 87 JSClassRef m_class; 103 OwnPtr<JSCallbackObjectData> m_callbackObjectData; 88 104 }; 89 105 -
trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h
r35775 r35807 43 43 JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSClassRef jsClass, JSValue* prototype, void* data) 44 44 : Base(prototype) 45 , m_privateData(data) 46 , m_class(JSClassRetain(jsClass)) 45 , m_callbackObjectData(new JSCallbackObjectData(data, jsClass)) 47 46 { 48 47 init(exec); … … 53 52 template <class Base> 54 53 JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass) 55 : m_privateData(0) 56 , m_class(JSClassRetain(jsClass)) 54 : m_callbackObjectData(new JSCallbackObjectData(0, jsClass)) 57 55 { 58 56 ASSERT(Base::isGlobalObject()); … … 66 64 67 65 Vector<JSObjectInitializeCallback, 16> initRoutines; 68 JSClassRef jsClass = m_class;66 JSClassRef jsClass = classRef(); 69 67 do { 70 68 if (JSObjectInitializeCallback initialize = jsClass->initialize) … … 84 82 JSObjectRef thisRef = toRef(this); 85 83 86 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)87 if (JSObjectFinalizeCallback finalize = jsClass->finalize) {84 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) 85 if (JSObjectFinalizeCallback finalize = jsClass->finalize) 88 86 finalize(thisRef); 89 }90 91 JSClassRelease(m_class);92 87 } 93 88 … … 95 90 UString JSCallbackObject<Base>::className() const 96 91 { 97 UString thisClassName = m_class->className();92 UString thisClassName = classRef()->className(); 98 93 if (!thisClassName.isNull()) 99 94 return thisClassName; … … 109 104 RefPtr<OpaqueJSString> propertyNameRef; 110 105 111 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {106 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { 112 107 // optional optimization to bypass getProperty in cases when we only need to know if the property exists 113 108 if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) { … … 162 157 JSValueRef valueRef = toRef(value); 163 158 164 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {159 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { 165 160 if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) { 166 161 if (!propertyNameRef) … … 210 205 RefPtr<OpaqueJSString> propertyNameRef; 211 206 212 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {207 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { 213 208 if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) { 214 209 if (!propertyNameRef) … … 247 242 ConstructType JSCallbackObject<Base>::getConstructData(ConstructData& constructData) 248 243 { 249 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {244 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { 250 245 if (jsClass->callAsConstructor) { 251 246 constructData.native.function = construct; … … 279 274 bool JSCallbackObject<Base>::implementsHasInstance() const 280 275 { 281 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)276 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) 282 277 if (jsClass->hasInstance) 283 278 return true; … … 292 287 JSObjectRef thisRef = toRef(this); 293 288 294 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {289 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { 295 290 if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) 296 291 return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot())); … … 303 298 CallType JSCallbackObject<Base>::getCallData(CallData& callData) 304 299 { 305 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {300 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { 306 301 if (jsClass->callAsFunction) { 307 302 callData.native.function = call; … … 319 314 JSObjectRef thisObjRef = toRef(thisValue->toThisObject(exec)); 320 315 321 for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(functionObject)-> m_class; jsClass; jsClass = jsClass->parentClass) {316 for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(functionObject)->classRef(); jsClass; jsClass = jsClass->parentClass) { 322 317 if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) { 323 318 int argumentCount = static_cast<int>(args.size()); … … 339 334 JSObjectRef thisRef = toRef(this); 340 335 341 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {336 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { 342 337 if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) 343 338 getPropertyNames(execRef, thisRef, toRef(&propertyNames)); … … 380 375 JSObjectRef thisRef = toRef(this); 381 376 382 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)377 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) 383 378 if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { 384 379 if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot()))) … … 395 390 JSObjectRef thisRef = toRef(this); 396 391 397 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)392 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) 398 393 if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { 399 394 JSValueRef value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot())); … … 408 403 void JSCallbackObject<Base>::setPrivate(void* data) 409 404 { 410 m_ privateData = data;405 m_callbackObjectData->privateData = data; 411 406 } 412 407 … … 414 409 void* JSCallbackObject<Base>::getPrivate() 415 410 { 416 return m_ privateData;411 return m_callbackObjectData->privateData; 417 412 } 418 413 … … 420 415 bool JSCallbackObject<Base>::inherits(JSClassRef c) const 421 416 { 422 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)417 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) 423 418 if (jsClass == c) 424 419 return true; … … 444 439 RefPtr<OpaqueJSString> propertyNameRef; 445 440 446 for (JSClassRef jsClass = thisObj-> m_class; jsClass; jsClass = jsClass->parentClass)441 for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) 447 442 if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) 448 443 if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) … … 468 463 return slot2.getValue(exec, propertyName); 469 464 470 for (JSClassRef jsClass = thisObj-> m_class; jsClass; jsClass = jsClass->parentClass) {465 for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) { 471 466 if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { 472 467 if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { … … 492 487 RefPtr<OpaqueJSString> propertyNameRef; 493 488 494 for (JSClassRef jsClass = thisObj-> m_class; jsClass; jsClass = jsClass->parentClass)489 for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) 495 490 if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { 496 491 if (!propertyNameRef) -
trunk/JavaScriptCore/ChangeLog
r35806 r35807 1 2008-08-17 Geoffrey Garen <[email protected]> 2 3 Reviewed by Cameron Zwarich. 4 5 Made room for a free word in JSCell. 6 7 SunSpider says no change. 8 9 I changed JSCallbackObjectData, Arguments, JSArray, and RegExpObject to 10 store auxiliary data in a secondary structure. 11 12 I changed InternalFunction to store the function's name in the property 13 map. 14 15 I changed JSGlobalObjectData to use a virtual destructor, so WebCore's 16 JSDOMWindowBaseData could inherit from it safely. (It's a strange design 17 for JSDOMWindowBase to allocate an object that JSGlobalObject deletes, 18 but that's really our only option, given the size constraint.) 19 20 I also added a bunch of compile-time ASSERTs, and removed lots of comments 21 in JSObject.h because they were often out of date, and they got in the 22 way of reading what was actually going on. 23 24 Also renamed JSArray::getLength to JSArray::length, to match our style 25 guidelines. 26 1 27 2008-08-16 Geoffrey Garen <[email protected]> 2 28 -
trunk/JavaScriptCore/JavaScriptCore.exp
r35806 r35807 132 132 __ZN3KJS14constructArrayEPNS_9ExecStateERKNS_7ArgListE 133 133 __ZN3KJS15JSWrapperObject4markEv 134 __ZN3KJS16InternalFunction14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE135 __ZN3KJS16InternalFunction18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE136 __ZN3KJS16InternalFunction3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE137 134 __ZN3KJS16InternalFunction4infoE 138 __ZN3KJS16InternalFunctionC2EPNS_ 17FunctionPrototypeERKNS_10IdentifierE135 __ZN3KJS16InternalFunctionC2EPNS_9ExecStateEPNS_17FunctionPrototypeERKNS_10IdentifierE 139 136 __ZN3KJS16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE 140 137 __ZN3KJS16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE … … 209 206 __ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj 210 207 __ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE 211 __ZN3KJS8JSObject17putDirectFunctionEPNS_ 16InternalFunctionEj208 __ZN3KJS8JSObject17putDirectFunctionEPNS_9ExecStateEPNS_16InternalFunctionEj 212 209 __ZN3KJS8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEj 213 210 __ZN3KJS8JSObject17putWithAttributesEPNS_9ExecStateEjPNS_7JSValueEj -
trunk/JavaScriptCore/VM/JSPropertyNameIterator.cpp
r35439 r35807 37 37 namespace KJS { 38 38 39 COMPILE_ASSERT(sizeof(JSPropertyNameIterator) <= CellSize<sizeof(void*)>::m_value, JSPropertyNameIteratorSizeASSERT);39 ASSERT_CLASS_FITS_IN_CELL(JSPropertyNameIterator); 40 40 41 41 JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSValue* v) -
trunk/JavaScriptCore/VM/Machine.cpp
r35652 r35807 646 646 647 647 if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) { 648 DebuggerCallFrame debuggerCallFrame(exec ->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue);648 DebuggerCallFrame debuggerCallFrame(exec, exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue); 649 649 if (callFrame[RegisterFile::Callee].jsValue(exec)) 650 650 debugger->returnEvent(debuggerCallFrame, codeBlock->ownerNode->sourceId(), codeBlock->ownerNode->lastLine()); … … 724 724 725 725 if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) { 726 DebuggerCallFrame debuggerCallFrame(exec ->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue);726 DebuggerCallFrame debuggerCallFrame(exec, exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue); 727 727 debugger->exception(debuggerCallFrame, codeBlock->ownerNode->sourceId(), codeBlock->lineNumberForVPC(vPC)); 728 728 } … … 956 956 return; 957 957 958 DebuggerCallFrame debuggerCallFrame(exec ->dynamicGlobalObject(), codeBlock, scopeChain, r, 0);958 DebuggerCallFrame debuggerCallFrame(exec, exec->dynamicGlobalObject(), codeBlock, scopeChain, r, 0); 959 959 960 960 switch((DebugHookID)debugHookID) { -
trunk/JavaScriptCore/kjs/Arguments.cpp
r35291 r35807 33 33 namespace KJS { 34 34 35 ASSERT_CLASS_FITS_IN_CELL(Arguments); 36 35 37 const ClassInfo Arguments::info = { "Arguments", 0, 0, 0 }; 36 38 … … 38 40 Arguments::Arguments(ExecState* exec, JSFunction* function, const ArgList& args, JSActivation* activation) 39 41 : JSObject(exec->lexicalGlobalObject()->objectPrototype()) 40 , m_activationObject(activation) 41 , m_indexToNameMap(function, args) 42 , d(new ArgumentsData(activation, function, args)) 42 43 { 44 ASSERT(activation); 45 43 46 putDirect(exec->propertyNames().callee, function, DontEnum); 44 47 putDirect(exec, exec->propertyNames().length, args.size(), DontEnum); … … 48 51 for (ArgList::const_iterator it = args.begin(); it != end; ++it, ++i) { 49 52 Identifier name = Identifier::from(exec, i); 50 if (! m_indexToNameMap.isMapped(name))53 if (!d->indexToNameMap.isMapped(name)) 51 54 putDirect(name, (*it).jsValue(exec), DontEnum); 52 55 } … … 56 59 { 57 60 JSObject::mark(); 58 if ( m_activationObject && !m_activationObject->marked())59 m_activationObject->mark();61 if (!d->activation->marked()) 62 d->activation->mark(); 60 63 } 61 64 … … 63 66 { 64 67 Arguments* thisObj = static_cast<Arguments*>(slot.slotBase()); 65 return thisObj-> m_activationObject->get(exec, thisObj->m_indexToNameMap[propertyName]);68 return thisObj->d->activation->get(exec, thisObj->d->indexToNameMap[propertyName]); 66 69 } 67 70 68 71 bool Arguments::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 69 72 { 70 if ( m_indexToNameMap.isMapped(propertyName)) {73 if (d->indexToNameMap.isMapped(propertyName)) { 71 74 slot.setCustom(this, mappedIndexGetter); 72 75 return true; … … 78 81 void Arguments::put(ExecState* exec, const Identifier& propertyName, JSValue* value) 79 82 { 80 if ( m_indexToNameMap.isMapped(propertyName))81 m_activationObject->put(exec, m_indexToNameMap[propertyName], value);83 if (d->indexToNameMap.isMapped(propertyName)) 84 d->activation->put(exec, d->indexToNameMap[propertyName], value); 82 85 else 83 86 JSObject::put(exec, propertyName, value); … … 86 89 bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName) 87 90 { 88 if ( m_indexToNameMap.isMapped(propertyName)) {89 m_indexToNameMap.unMap(exec, propertyName);91 if (d->indexToNameMap.isMapped(propertyName)) { 92 d->indexToNameMap.unMap(exec, propertyName); 90 93 return true; 91 94 } -
trunk/JavaScriptCore/kjs/Arguments.h
r35022 r35807 48 48 static JSValue* mappedIndexGetter(ExecState*, const Identifier&, const PropertySlot& slot); 49 49 50 JSActivation* m_activationObject; 51 mutable IndexToNameMap m_indexToNameMap; 50 struct ArgumentsData { 51 ArgumentsData(JSActivation* activation_, JSFunction* function_, const ArgList& args_) 52 : activation(activation_) 53 , indexToNameMap(function_, args_) 54 { 55 } 56 57 JSActivation* activation; 58 mutable IndexToNameMap indexToNameMap; 59 }; 60 61 OwnPtr<ArgumentsData> d; 52 62 }; 53 63 -
trunk/JavaScriptCore/kjs/ArrayConstructor.cpp
r35411 r35807 32 32 namespace KJS { 33 33 34 ASSERT_CLASS_FITS_IN_CELL(ArrayConstructor); 35 34 36 ArrayConstructor::ArrayConstructor(ExecState* exec, FunctionPrototype* functionPrototype, ArrayPrototype* arrayPrototype) 35 : InternalFunction( functionPrototype, Identifier(exec, arrayPrototype->classInfo()->className))37 : InternalFunction(exec, functionPrototype, Identifier(exec, arrayPrototype->classInfo()->className)) 36 38 { 37 39 // ECMA 15.4.3.1 Array.prototype -
trunk/JavaScriptCore/kjs/ArrayPrototype.cpp
r35291 r35807 34 34 35 35 namespace KJS { 36 37 ASSERT_CLASS_FITS_IN_CELL(ArrayPrototype); 36 38 37 39 static JSValue* arrayProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&); … … 263 265 if (curArg->isObject(&JSArray::info)) { 264 266 JSArray* curArray = static_cast<JSArray*>(curArg); 265 unsigned length = curArray-> getLength();267 unsigned length = curArray->length(); 266 268 for (unsigned k = 0; k < length; ++k) { 267 269 if (JSValue* v = getProperty(exec, curArray, k)) -
trunk/JavaScriptCore/kjs/BooleanConstructor.cpp
r35411 r35807 27 27 namespace KJS { 28 28 29 ASSERT_CLASS_FITS_IN_CELL(BooleanConstructor); 30 29 31 BooleanConstructor::BooleanConstructor(ExecState* exec, FunctionPrototype* functionPrototype, BooleanPrototype* booleanPrototype) 30 : InternalFunction( functionPrototype, Identifier(exec, booleanPrototype->classInfo()->className))32 : InternalFunction(exec, functionPrototype, Identifier(exec, booleanPrototype->classInfo()->className)) 31 33 { 32 34 putDirect(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly); -
trunk/JavaScriptCore/kjs/BooleanObject.cpp
r35022 r35807 24 24 namespace KJS { 25 25 26 ASSERT_CLASS_FITS_IN_CELL(BooleanObject); 27 26 28 const ClassInfo BooleanObject::info = { "Boolean", 0, 0, 0 }; 27 29 -
trunk/JavaScriptCore/kjs/BooleanPrototype.cpp
r35020 r35807 30 30 namespace KJS { 31 31 32 ASSERT_CLASS_FITS_IN_CELL(BooleanPrototype); 33 32 34 // Functions 33 35 static JSValue* booleanProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&); … … 41 43 setInternalValue(jsBoolean(false)); 42 44 43 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);44 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);45 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum); 46 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum); 45 47 } 46 48 -
trunk/JavaScriptCore/kjs/DateConstructor.cpp
r35411 r35807 46 46 // TODO: MakeTime (15.9.11.1) etc. ? 47 47 48 ASSERT_CLASS_FITS_IN_CELL(DateConstructor); 49 48 50 static JSValue* dateParse(ExecState*, JSObject*, JSValue*, const ArgList&); 49 51 static JSValue* dateNow(ExecState*, JSObject*, JSValue*, const ArgList&); … … 51 53 52 54 DateConstructor::DateConstructor(ExecState* exec, FunctionPrototype* functionPrototype, DatePrototype* datePrototype) 53 : InternalFunction( functionPrototype, Identifier(exec, datePrototype->classInfo()->className))55 : InternalFunction(exec, functionPrototype, Identifier(exec, datePrototype->classInfo()->className)) 54 56 { 55 57 putDirect(exec->propertyNames().prototype, datePrototype, DontEnum|DontDelete|ReadOnly); 56 58 57 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().parse, dateParse), DontEnum);58 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 7, exec->propertyNames().UTC, dateUTC), DontEnum);59 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().now, dateNow), DontEnum);59 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().parse, dateParse), DontEnum); 60 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 7, exec->propertyNames().UTC, dateUTC), DontEnum); 61 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().now, dateNow), DontEnum); 60 62 61 63 putDirect(exec, exec->propertyNames().length, 7, ReadOnly | DontEnum | DontDelete); -
trunk/JavaScriptCore/kjs/DatePrototype.cpp
r35291 r35807 56 56 57 57 namespace KJS { 58 59 ASSERT_CLASS_FITS_IN_CELL(DatePrototype); 58 60 59 61 static JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, JSValue*, const ArgList&); -
trunk/JavaScriptCore/kjs/DebuggerCallFrame.cpp
r35291 r35807 50 50 if (!function) 51 51 return 0; 52 return &function-> functionName().ustring();52 return &function->name(m_exec); 53 53 } 54 54 -
trunk/JavaScriptCore/kjs/DebuggerCallFrame.h
r35037 r35807 33 33 34 34 class CodeBlock; 35 class ExecState; 35 36 class JSGlobalObject; 36 37 class JSObject; … … 48 49 }; 49 50 50 DebuggerCallFrame(JSGlobalObject* dynamicGlobalObject, const CodeBlock* codeBlock, ScopeChainNode* scopeChain, Register* r, JSValue* exception) 51 : m_dynamicGlobalObject(dynamicGlobalObject) 51 DebuggerCallFrame(ExecState* exec, JSGlobalObject* dynamicGlobalObject, const CodeBlock* codeBlock, ScopeChainNode* scopeChain, Register* r, JSValue* exception) 52 : m_exec(exec) 53 , m_dynamicGlobalObject(dynamicGlobalObject) 52 54 , m_codeBlock(codeBlock) 53 55 , m_scopeChain(scopeChain) … … 68 70 Register* callFrame() const; 69 71 72 ExecState* m_exec; 70 73 JSGlobalObject* m_dynamicGlobalObject; 71 74 const CodeBlock* m_codeBlock; -
trunk/JavaScriptCore/kjs/ErrorConstructor.cpp
r35411 r35807 30 30 namespace KJS { 31 31 32 ASSERT_CLASS_FITS_IN_CELL(ErrorConstructor); 33 32 34 ErrorConstructor::ErrorConstructor(ExecState* exec, FunctionPrototype* functionPrototype, ErrorPrototype* errorPrototype) 33 : InternalFunction( functionPrototype, Identifier(exec, errorPrototype->classInfo()->className))35 : InternalFunction(exec, functionPrototype, Identifier(exec, errorPrototype->classInfo()->className)) 34 36 { 35 37 // ECMA 15.11.3.1 Error.prototype -
trunk/JavaScriptCore/kjs/ErrorPrototype.cpp
r35020 r35807 30 30 namespace KJS { 31 31 32 ASSERT_CLASS_FITS_IN_CELL(ErrorPrototype); 33 32 34 static JSValue* errorProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&); 33 35 … … 41 43 putDirect(exec->propertyNames().message, jsString(exec, "Unknown error"), DontEnum); 42 44 43 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);45 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum); 44 46 } 45 47 -
trunk/JavaScriptCore/kjs/FunctionConstructor.cpp
r35411 r35807 33 33 namespace KJS { 34 34 35 ASSERT_CLASS_FITS_IN_CELL(FunctionConstructor); 36 35 37 FunctionConstructor::FunctionConstructor(ExecState* exec, FunctionPrototype* functionPrototype) 36 : InternalFunction( functionPrototype, Identifier(exec, functionPrototype->classInfo()->className))38 : InternalFunction(exec, functionPrototype, Identifier(exec, functionPrototype->classInfo()->className)) 37 39 { 38 40 putDirect(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly); -
trunk/JavaScriptCore/kjs/FunctionPrototype.cpp
r35291 r35807 30 30 namespace KJS { 31 31 32 ASSERT_CLASS_FITS_IN_CELL(FunctionPrototype); 33 32 34 static JSValue* functionProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&); 33 35 static JSValue* functionProtoFuncApply(ExecState*, JSObject*, JSValue*, const ArgList&); … … 35 37 36 38 FunctionPrototype::FunctionPrototype(ExecState* exec) 39 : InternalFunction(exec) 37 40 { 38 41 putDirect(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum); 39 42 40 putDirectFunction( new (exec) PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);41 putDirectFunction( new (exec) PrototypeFunction(exec, this, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum);42 putDirectFunction( new (exec) PrototypeFunction(exec, this, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);43 putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum); 44 putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum); 45 putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum); 43 46 } 44 47 … … 59 62 JSValue* functionProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 60 63 { 61 if (!thisValue->isObject(&InternalFunction::info)) 62 return throwError(exec, TypeError); 63 64 InternalFunction* function = static_cast<InternalFunction*>(thisValue); 65 66 if (function->inherits(&JSFunction::info)) { 67 JSFunction* fi = static_cast<JSFunction*>(thisValue); 68 return jsString(exec, "function " + fi->functionName().ustring() + "(" + fi->m_body->paramString() + ") " + fi->m_body->toSourceString()); 64 if (thisValue->isObject(&JSFunction::info)) { 65 JSFunction* function = static_cast<JSFunction*>(thisValue); 66 return jsString(exec, "function " + function->name(exec) + "(" + function->m_body->paramString() + ") " + function->m_body->toSourceString()); 69 67 } 70 68 71 return jsString(exec, "function " + function->functionName().ustring() + "() {\n [native code]\n}"); 69 if (thisValue->isObject(&InternalFunction::info)) { 70 InternalFunction* function = static_cast<InternalFunction*>(thisValue); 71 return jsString(exec, "function " + function->name(exec) + "() {\n [native code]\n}"); 72 } 73 74 return throwError(exec, TypeError); 72 75 } 73 76 -
trunk/JavaScriptCore/kjs/GlobalEvalFunction.cpp
r35016 r35807 32 32 namespace KJS { 33 33 34 ASSERT_CLASS_FITS_IN_CELL(GlobalEvalFunction); 35 34 36 GlobalEvalFunction::GlobalEvalFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, NativeFunction function, JSGlobalObject* cachedGlobalObject) 35 37 : PrototypeFunction(exec, functionPrototype, len, name, function) -
trunk/JavaScriptCore/kjs/InternalFunction.cpp
r35229 r35807 29 29 namespace KJS { 30 30 31 ASSERT_CLASS_FITS_IN_CELL(InternalFunction); 32 31 33 const ClassInfo InternalFunction::info = { "Function", 0, 0, 0 }; 32 34 33 InternalFunction::InternalFunction( )35 InternalFunction::InternalFunction(ExecState* exec) 34 36 { 37 putDirect(exec->propertyNames().name, jsString(exec, exec->propertyNames().nullIdentifier.ustring()), DontDelete | ReadOnly | DontEnum); 35 38 } 36 39 37 InternalFunction::InternalFunction( FunctionPrototype* prototype, const Identifier& name)40 InternalFunction::InternalFunction(ExecState* exec, FunctionPrototype* prototype, const Identifier& name) 38 41 : JSObject(prototype) 39 , m_name(name)40 42 { 43 putDirect(exec->propertyNames().name, jsString(exec, name.ustring()), DontDelete | ReadOnly | DontEnum); 44 } 45 46 const UString& InternalFunction::name(ExecState* exec) 47 { 48 JSValue* v = getDirect(exec->propertyNames().name); 49 ASSERT(v->isString()); 50 return static_cast<JSString*>(v)->value(); 41 51 } 42 52 … … 46 56 } 47 57 48 bool InternalFunction::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)49 {50 if (propertyName == exec->propertyNames().name) {51 slot.setCustom(this, nameGetter);52 return true;53 }54 55 return JSObject::getOwnPropertySlot(exec, propertyName, slot);56 }57 58 void InternalFunction::put(ExecState* exec, const Identifier& propertyName, JSValue* value)59 {60 if (propertyName == exec->propertyNames().name)61 return;62 JSObject::put(exec, propertyName, value);63 }64 65 bool InternalFunction::deleteProperty(ExecState* exec, const Identifier& propertyName)66 {67 if (propertyName == exec->propertyNames().name)68 return false;69 return JSObject::deleteProperty(exec, propertyName);70 }71 72 JSValue* InternalFunction::nameGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)73 {74 InternalFunction* thisObj = static_cast<InternalFunction*>(slot.slotBase());75 return jsString(exec, thisObj->functionName().ustring());76 }77 78 58 } // namespace KJS -
trunk/JavaScriptCore/kjs/InternalFunction.h
r35228 r35807 36 36 virtual const ClassInfo* classInfo() const { return &info; } 37 37 static const ClassInfo info; 38 39 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); 40 virtual void put(ExecState*, const Identifier& propertyName, JSValue*); 41 virtual bool deleteProperty(ExecState*, const Identifier& propertyName); 42 43 const Identifier& functionName() const { return m_name; } 38 39 const UString& name(ExecState*); 44 40 45 41 protected: 46 InternalFunction( );47 InternalFunction( FunctionPrototype*, const Identifier&);42 InternalFunction(ExecState*); 43 InternalFunction(ExecState*, FunctionPrototype*, const Identifier&); 48 44 49 45 private: 50 static JSValue* nameGetter(ExecState*, const Identifier&, const PropertySlot&);51 46 virtual CallType getCallData(CallData&) = 0; 52 47 virtual bool implementsHasInstance() const; 53 54 Identifier m_name;55 48 }; 56 49 -
trunk/JavaScriptCore/kjs/JSActivation.cpp
r35657 r35807 37 37 38 38 namespace KJS { 39 40 ASSERT_CLASS_FITS_IN_CELL(JSActivation); 39 41 40 42 const ClassInfo JSActivation::info = { "JSActivation", 0, 0, 0 }; -
trunk/JavaScriptCore/kjs/JSArray.cpp
r35806 r35807 35 35 36 36 namespace KJS { 37 38 ASSERT_CLASS_FITS_IN_CELL(JSArray); 37 39 38 40 // Overview of JSArray … … 129 131 unsigned initialCapacity = min(initialLength, MIN_SPARSE_ARRAY_INDEX); 130 132 131 m_ length = initialLength;133 m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity))); 132 134 m_fastAccessCutoff = 0; 133 m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));134 135 m_storage->m_vectorLength = initialCapacity; 136 m_storage->m_length = initialLength; 135 137 136 138 Heap::heap(this)->reportExtraMemoryCost(initialCapacity * sizeof(JSValue*)); … … 144 146 unsigned length = list.size(); 145 147 146 m_length = length;147 148 m_fastAccessCutoff = length; 148 149 … … 152 153 storage->m_numValuesInVector = length; 153 154 storage->m_sparseValueMap = 0; 155 storage->m_length = length; 154 156 155 157 size_t i = 0; … … 178 180 ArrayStorage* storage = m_storage; 179 181 180 if (i >= m_length) {182 if (i >= storage->m_length) { 181 183 if (i > MAX_ARRAY_INDEX) 182 184 return getOwnPropertySlot(exec, Identifier::from(exec, i), slot); … … 206 208 { 207 209 if (propertyName == exec->propertyNames().length) { 208 slot.setValue(jsNumber(exec, getLength()));210 slot.setValue(jsNumber(exec, length())); 209 211 return true; 210 212 } … … 245 247 checkConsistency(); 246 248 247 unsigned length = m_ length;249 unsigned length = m_storage->m_length; 248 250 if (i >= length && i <= MAX_ARRAY_INDEX) { 249 251 length = i + 1; 250 m_ length = length;252 m_storage->m_length = length; 251 253 } 252 254 … … 259 261 } 260 262 valueSlot = value; 261 if (++m_storage->m_numValuesInVector == m_ length)262 m_fastAccessCutoff = m_ length;263 if (++m_storage->m_numValuesInVector == m_storage->m_length) 264 m_fastAccessCutoff = m_storage->m_length; 263 265 checkConsistency(); 264 266 return; … … 414 416 ArrayStorage* storage = m_storage; 415 417 416 unsigned usedVectorLength = min( m_length, storage->m_vectorLength);418 unsigned usedVectorLength = min(storage->m_length, storage->m_vectorLength); 417 419 for (unsigned i = 0; i < usedVectorLength; ++i) { 418 420 if (storage->m_vector[i]) … … 460 462 ArrayStorage* storage = m_storage; 461 463 462 unsigned length = m_ length;464 unsigned length = m_storage->m_length; 463 465 464 466 if (newLength < length) { … … 488 490 } 489 491 490 m_ length = newLength;492 m_storage->m_length = newLength; 491 493 492 494 checkConsistency(); … … 499 501 ArrayStorage* storage = m_storage; 500 502 501 unsigned usedVectorLength = min( m_length, storage->m_vectorLength);503 unsigned usedVectorLength = min(storage->m_length, storage->m_vectorLength); 502 504 for (unsigned i = 0; i < usedVectorLength; ++i) { 503 505 JSValue* value = storage->m_vector[i]; … … 662 664 // The maximum tree depth is compiled in - but the caller is clearly up to no good 663 665 // if a larger array is passed. 664 ASSERT(m_ length <= static_cast<unsigned>(std::numeric_limits<int>::max()));665 if (m_ length > static_cast<unsigned>(std::numeric_limits<int>::max()))666 return; 667 668 if (!m_ length)669 return; 670 671 unsigned usedVectorLength = min(m_ length, m_storage->m_vectorLength);666 ASSERT(m_storage->m_length <= static_cast<unsigned>(std::numeric_limits<int>::max())); 667 if (m_storage->m_length > static_cast<unsigned>(std::numeric_limits<int>::max())) 668 return; 669 670 if (!m_storage->m_length) 671 return; 672 673 unsigned usedVectorLength = min(m_storage->m_length, m_storage->m_vectorLength); 672 674 673 675 AVLTree<AVLTreeAbstractorForArrayCompare, 44> tree; // Depth 44 is enough for 2^31 items … … 766 768 ArrayStorage* storage = m_storage; 767 769 768 unsigned usedVectorLength = min(m_ length, storage->m_vectorLength);770 unsigned usedVectorLength = min(m_storage->m_length, storage->m_vectorLength); 769 771 770 772 unsigned numDefined = 0; … … 836 838 ASSERT(!m_storage->m_sparseValueMap); 837 839 838 ASSERT(m_fastAccessCutoff <= m_ length);840 ASSERT(m_fastAccessCutoff <= m_storage->m_length); 839 841 ASSERT(m_fastAccessCutoff <= m_storage->m_numValuesInVector); 840 842 … … 842 844 for (unsigned i = 0; i < m_storage->m_vectorLength; ++i) { 843 845 if (JSValue* value = m_storage->m_vector[i]) { 844 ASSERT(i < m_ length);846 ASSERT(i < m_storage->m_length); 845 847 if (type != DestructorConsistencyCheck) 846 848 value->type(); // Likely to crash if the object was deallocated. … … 858 860 for (SparseArrayValueMap::iterator it = m_storage->m_sparseValueMap->begin(); it != end; ++it) { 859 861 unsigned index = it->first; 860 ASSERT(index < m_ length);862 ASSERT(index < m_storage->m_length); 861 863 ASSERT(index >= m_storage->m_vectorLength); 862 864 ASSERT(index <= MAX_ARRAY_INDEX); -
trunk/JavaScriptCore/kjs/JSArray.h
r35806 r35807 30 30 31 31 struct ArrayStorage { 32 unsigned m_length; 32 33 unsigned m_vectorLength; 33 34 unsigned m_numValuesInVector; … … 49 50 static const ClassInfo info; 50 51 51 unsigned getLength() const { returnm_length; }52 unsigned length() const { return m_storage->m_length; } 52 53 void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray. 53 54 … … 92 93 void checkConsistency(ConsistencyCheckType = NormalConsistencyCheck); 93 94 94 unsigned m_length;95 95 unsigned m_fastAccessCutoff; 96 96 ArrayStorage* m_storage; -
trunk/JavaScriptCore/kjs/JSCell.h
r35022 r35807 97 97 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 98 98 virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); 99 100 intptr_t reserved; // Reserved for work in progress. 99 101 }; 100 102 -
trunk/JavaScriptCore/kjs/JSFunction.cpp
r35022 r35807 26 26 #include "JSFunction.h" 27 27 28 #include "CommonIdentifiers.h" 28 29 #include "ExecState.h" 29 30 #include "FunctionPrototype.h" … … 40 41 namespace KJS { 41 42 42 const ClassInfo JSFunction::info = { "Function", &InternalFunction::info, 0, 0 }; 43 ASSERT_CLASS_FITS_IN_CELL(JSFunction); 44 45 const ClassInfo JSFunction::info = { "Function", 0, 0, 0 }; 43 46 44 47 JSFunction::JSFunction(ExecState* exec, const Identifier& name, FunctionBodyNode* body, ScopeChainNode* scopeChainNode) 45 : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), name)48 : Base(exec, exec->lexicalGlobalObject()->functionPrototype(), name) 46 49 , m_body(body) 47 50 , m_scopeChain(scopeChainNode) … … 51 54 void JSFunction::mark() 52 55 { 53 InternalFunction::mark();56 Base::mark(); 54 57 m_body->mark(); 55 58 m_scopeChain.mark(); … … 103 106 } 104 107 105 return InternalFunction::getOwnPropertySlot(exec, propertyName, slot);108 return Base::getOwnPropertySlot(exec, propertyName, slot); 106 109 } 107 110 … … 110 113 if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length) 111 114 return; 112 InternalFunction::put(exec, propertyName, value);115 Base::put(exec, propertyName, value); 113 116 } 114 117 … … 117 120 if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length) 118 121 return false; 119 return InternalFunction::deleteProperty(exec, propertyName);122 return Base::deleteProperty(exec, propertyName); 120 123 } 121 124 -
trunk/JavaScriptCore/kjs/JSFunction.h
r35022 r35807 39 39 40 40 class JSFunction : public InternalFunction { 41 typedef InternalFunction Base; 41 42 public: 42 43 JSFunction(ExecState*, const Identifier&, FunctionBodyNode*, ScopeChainNode*); -
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r35657 r35807 63 63 namespace KJS { 64 64 65 ASSERT_CLASS_FITS_IN_CELL(JSGlobalObject); 66 65 67 // Default number of ticks before a timeout check should be done. 66 68 static const int initialTickCountThreshold = 255; … … 312 314 313 315 d()->evalFunction = new (exec) GlobalEvalFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this); 314 putDirectFunction( d()->evalFunction, DontEnum);315 putDirectFunction( new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);316 putDirectFunction( new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);317 putDirectFunction( new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);318 putDirectFunction( new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);319 putDirectFunction( new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);320 putDirectFunction( new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);321 putDirectFunction( new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);322 putDirectFunction( new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);323 putDirectFunction( new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);324 putDirectFunction( new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);316 putDirectFunction(exec, d()->evalFunction, DontEnum); 317 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum); 318 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum); 319 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum); 320 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum); 321 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum); 322 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum); 323 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum); 324 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum); 325 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum); 326 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum); 325 327 #ifndef NDEBUG 326 putDirectFunction( new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum);328 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum); 327 329 #endif 328 330 -
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r35203 r35807 78 78 { 79 79 } 80 81 virtual ~JSGlobalObjectData() 82 { 83 } 80 84 81 85 JSGlobalObject* next; … … 134 138 135 139 protected: 136 JSGlobalObject(JSValue* prototype, JS Object* globalThisValue)137 : JSVariableObject(prototype, new JSGlobalObjectData(this, globalThisValue))140 JSGlobalObject(JSValue* prototype, JSGlobalObjectData* d, JSObject* globalThisValue) 141 : JSVariableObject(prototype, d) 138 142 { 139 143 init(globalThisValue); -
trunk/JavaScriptCore/kjs/JSNotAnObject.cpp
r34754 r35807 34 34 35 35 namespace KJS { 36 37 ASSERT_CLASS_FITS_IN_CELL(JSNotAnObject); 36 38 37 39 // JSValue methods -
trunk/JavaScriptCore/kjs/JSObject.cpp
r35750 r35807 43 43 namespace KJS { 44 44 45 ASSERT_CLASS_FITS_IN_CELL(JSObject); 46 45 47 void JSObject::mark() 46 48 { … … 461 463 } 462 464 463 void JSObject::putDirectFunction( InternalFunction* function, unsigned attr)464 { 465 putDirect( function->functionName(), function, attr);465 void JSObject::putDirectFunction(ExecState* exec, InternalFunction* function, unsigned attr) 466 { 467 putDirect(Identifier(exec, function->name(exec)), function, attr); 466 468 } 467 469 -
trunk/JavaScriptCore/kjs/JSObject.h
r35657 r35807 70 70 virtual JSType type() const; 71 71 72 /**73 * A pointer to a ClassInfo struct for this class. This provides a basic74 * facility for run-time type information, and can be used to check an75 * object's class an inheritance (see inherits()). This should76 * always return a statically declared pointer, or 0 to indicate that77 * there is no class information.78 *79 * This is primarily useful if you have application-defined classes that you80 * wish to check against for casting purposes.81 *82 * For example, to specify the class info for classes FooImp and BarImp,83 * where FooImp inherits from BarImp, you would add the following in your84 * class declarations:85 *86 * \code87 * class BarImp : public JSObject {88 * virtual const ClassInfo *classInfo() const { return &info; }89 * static const ClassInfo info;90 * // ...91 * };92 *93 * class FooImp : public JSObject {94 * virtual const ClassInfo *classInfo() const { return &info; }95 * static const ClassInfo info;96 * // ...97 * };98 * \endcode99 *100 * And in your source file:101 *102 * \code103 * const ClassInfo BarImp::info = { "Bar", 0, 0, 0 }; // no parent class104 * const ClassInfo FooImp::info = { "Foo", &BarImp::info, 0, 0 };105 * \endcode106 *107 * @see inherits()108 */109 110 /**111 * Checks whether this object inherits from the class with the specified112 * classInfo() pointer. This requires that both this class and the other113 * class return a non-NULL pointer for their classInfo() methods (otherwise114 * it will return false).115 *116 * For example, for two JSObject pointers obj1 and obj2, you can check117 * if obj1's class inherits from obj2's class using the following:118 *119 * if (obj1->inherits(obj2->classInfo())) {120 * // ...121 * }122 *123 * If you have a handle to a statically declared ClassInfo, such as in the124 * classInfo() example, you can check for inheritance without needing125 * an instance of the other class:126 *127 * if (obj1->inherits(FooImp::info)) {128 * // ...129 * }130 *131 * @param cinfo The ClassInfo pointer for the class you want to check132 * inheritance against.133 * @return true if this object's class inherits from class with the134 * ClassInfo pointer specified in cinfo135 */136 72 bool inherits(const ClassInfo* classInfo) const { return isObject(classInfo); } // FIXME: Merge with isObject. 137 73 138 // internal properties (ECMA 262-3 8.6.2)139 140 /**141 * Returns the prototype of this object. Note that this is not the same as142 * the "prototype" property.143 *144 * See ECMA 8.6.2145 *146 * @return The object's prototype147 */148 74 JSValue* prototype() const; 149 75 void setPrototype(JSValue* prototype); 150 76 151 /**152 * Returns the class name of the object153 *154 * See ECMA 8.6.2155 *156 * @return The object's class name157 */158 /**159 * Implementation of the [[Class]] internal property (implemented by all160 * Objects)161 *162 * The default implementation uses classInfo().163 * You should either implement classInfo(), or164 * if you simply need a classname, you can reimplement className()165 * instead.166 */167 77 virtual UString className() const; 168 78 169 /**170 * Retrieves the specified property from the object. If neither the object171 * or any other object in its prototype chain have the property, this172 * function will return Undefined.173 *174 * See ECMA 8.6.2.1175 *176 * @param exec The current execution state177 * @param propertyName The name of the property to retrieve178 *179 * @return The specified property, or Undefined180 */181 79 JSValue* get(ExecState*, const Identifier& propertyName) const; 182 80 JSValue* get(ExecState*, unsigned propertyName) const; … … 188 86 virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); 189 87 190 /**191 * Sets the specified property.192 *193 * See ECMA 8.6.2.2194 *195 * @param exec The current execution state196 * @param propertyName The name of the property to set197 * @param propertyValue The value to set198 */199 88 virtual void put(ExecState*, const Identifier& propertyName, JSValue* value); 200 89 virtual void put(ExecState*, unsigned propertyName, JSValue* value); … … 203 92 virtual void putWithAttributes(ExecState*, unsigned propertyName, JSValue* value, unsigned attributes); 204 93 205 /**206 * Checks if a property is enumerable, that is if it doesn't have the DontEnum207 * flag set208 *209 * See ECMA 15.2.4210 * @param exec The current execution state211 * @param propertyName The name of the property212 * @return true if the property is enumerable, otherwise false213 */214 94 bool propertyIsEnumerable(ExecState*, const Identifier& propertyName) const; 215 95 216 /**217 * Checks to see whether the object (or any object in its prototype chain)218 * has a property with the specified name.219 *220 * See ECMA 8.6.2.4221 *222 * @param exec The current execution state223 * @param propertyName The name of the property to check for224 * @return true if the object has the property, otherwise false225 */226 96 bool hasProperty(ExecState*, const Identifier& propertyName) const; 227 97 bool hasProperty(ExecState*, unsigned propertyName) const; 228 98 bool hasOwnProperty(ExecState*, const Identifier& propertyName) const; 229 99 230 /**231 * Removes the specified property from the object.232 *233 * See ECMA 8.6.2.5234 *235 * @param exec The current execution state236 * @param propertyName The name of the property to delete237 * @return true if the property was successfully deleted or did not238 * exist on the object. false if deleting the specified property is not239 * allowed.240 */241 100 virtual bool deleteProperty(ExecState*, const Identifier& propertyName); 242 101 virtual bool deleteProperty(ExecState*, unsigned propertyName); 243 102 244 /**245 * Converts the object into a primitive value. The value return may differ246 * depending on the supplied hint247 *248 * See ECMA 8.6.2.6249 *250 * @param exec The current execution state251 * @param hint The desired primitive type to convert to252 * @return A primitive value converted from the objetc. Note that the253 * type of primitive value returned may not be the same as the requested254 * hint.255 */256 /**257 * Implementation of the [[DefaultValue]] internal property (implemented by258 * all Objects)259 */260 103 virtual JSValue* defaultValue(ExecState*, JSType hint) const; 261 104 262 /**263 * Whether or not the object implements the hasInstance() method. If this264 * returns false you should not call the hasInstance() method on this265 * object (typically, an assertion will fail to indicate this).266 *267 * @return true if this object implements the hasInstance() method,268 * otherwise false269 */270 105 virtual bool implementsHasInstance() const; 271 272 /**273 * Checks whether value delegates behavior to this object. Used by the274 * instanceof operator.275 *276 * @param exec The current execution state277 * @param value The value to check278 * @return true if value delegates behavior to this object, otherwise279 * false280 */281 106 virtual bool hasInstance(ExecState*, JSValue*); 282 107 … … 299 124 300 125 // This get function only looks at the property map. 301 // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want302 // to look up in the prototype, it might already exist there)303 126 JSValue* getDirect(const Identifier& propertyName) const { return m_propertyMap.get(propertyName); } 304 127 JSValue** getDirectLocation(const Identifier& propertyName) { return m_propertyMap.getLocation(propertyName); } … … 310 133 311 134 // convenience to add a function property under the function's own built-in name 312 void putDirectFunction( InternalFunction*, unsigned attr = 0);135 void putDirectFunction(ExecState*, InternalFunction*, unsigned attr = 0); 313 136 314 137 void fillGetterPropertySlot(PropertySlot&, JSValue** location); -
trunk/JavaScriptCore/kjs/JSStaticScopeObject.cpp
r35533 r35807 29 29 30 30 namespace KJS { 31 32 ASSERT_CLASS_FITS_IN_CELL(JSStaticScopeObject); 31 33 32 34 JSObject* JSStaticScopeObject::toThisObject(ExecState* exec) const -
trunk/JavaScriptCore/kjs/JSWrapperObject.cpp
r31124 r35807 26 26 namespace KJS { 27 27 28 ASSERT_CLASS_FITS_IN_CELL(JSWrapperObject); 29 28 30 void JSWrapperObject::mark() 29 31 { -
trunk/JavaScriptCore/kjs/MathObject.cpp
r35476 r35807 29 29 30 30 namespace KJS { 31 32 ASSERT_CLASS_FITS_IN_CELL(MathObject); 31 33 32 34 static JSValue* mathProtoFuncAbs(ExecState*, JSObject*, JSValue*, const ArgList&); -
trunk/JavaScriptCore/kjs/NativeErrorConstructor.cpp
r35411 r35807 29 29 namespace KJS { 30 30 31 ASSERT_CLASS_FITS_IN_CELL(NativeErrorConstructor); 32 31 33 const ClassInfo NativeErrorConstructor::info = { "Function", &InternalFunction::info, 0, 0 }; 32 34 33 35 NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, FunctionPrototype* functionPrototype, NativeErrorPrototype* nativeErrorPrototype) 34 : InternalFunction( functionPrototype, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString()))36 : InternalFunction(exec, functionPrototype, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString())) 35 37 , m_proto(nativeErrorPrototype) 36 38 { -
trunk/JavaScriptCore/kjs/NativeErrorPrototype.cpp
r35027 r35807 28 28 namespace KJS { 29 29 30 ASSERT_CLASS_FITS_IN_CELL(NativeErrorPrototype); 31 30 32 NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, ErrorPrototype* errorPrototype, const UString& name, const UString& message) 31 33 : JSObject(errorPrototype) -
trunk/JavaScriptCore/kjs/NumberConstructor.cpp
r35411 r35807 29 29 namespace KJS { 30 30 31 ASSERT_CLASS_FITS_IN_CELL(NativeErrorConstructor); 32 31 33 const ClassInfo NumberConstructor::info = { "Function", &InternalFunction::info, 0, ExecState::numberTable }; 32 34 … … 41 43 */ 42 44 NumberConstructor::NumberConstructor(ExecState* exec, FunctionPrototype* functionPrototype, NumberPrototype* numberPrototype) 43 : InternalFunction( functionPrototype, Identifier(exec, numberPrototype->info.className))45 : InternalFunction(exec, functionPrototype, Identifier(exec, numberPrototype->info.className)) 44 46 { 45 47 // Number.Prototype -
trunk/JavaScriptCore/kjs/NumberObject.cpp
r35027 r35807 28 28 namespace KJS { 29 29 30 ASSERT_CLASS_FITS_IN_CELL(NumberObject); 31 30 32 const ClassInfo NumberObject::info = { "Number", 0, 0, 0 }; 31 33 -
trunk/JavaScriptCore/kjs/NumberPrototype.cpp
r35291 r35807 36 36 namespace KJS { 37 37 38 ASSERT_CLASS_FITS_IN_CELL(NumberPrototype); 39 38 40 static JSValue* numberProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&); 39 41 static JSValue* numberProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&); … … 52 54 // The constructor will be added later, after NumberConstructor has been constructed 53 55 54 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);55 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);56 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);57 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);58 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);59 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);56 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum); 57 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum); 58 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum); 59 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum); 60 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum); 61 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum); 60 62 } 61 63 -
trunk/JavaScriptCore/kjs/ObjectConstructor.cpp
r35411 r35807 28 28 namespace KJS { 29 29 30 ASSERT_CLASS_FITS_IN_CELL(ObjectConstructor); 31 30 32 ObjectConstructor::ObjectConstructor(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype) 31 : InternalFunction( functionPrototype, Identifier(exec, "Object"))33 : InternalFunction(exec, functionPrototype, Identifier(exec, "Object")) 32 34 { 33 35 // ECMA 15.2.3.1 -
trunk/JavaScriptCore/kjs/ObjectPrototype.cpp
r35291 r35807 29 29 namespace KJS { 30 30 31 ASSERT_CLASS_FITS_IN_CELL(ObjectPrototype); 32 31 33 static JSValue* objectProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&); 32 34 static JSValue* objectProtoFuncHasOwnProperty(ExecState*, JSObject*, JSValue*, const ArgList&); … … 42 44 : JSObject() // [[Prototype]] is null 43 45 { 44 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);45 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);46 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);47 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);48 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);49 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);46 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum); 47 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum); 48 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum); 49 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum); 50 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum); 51 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum); 50 52 51 53 // Mozilla extensions 52 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);53 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);54 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);55 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);54 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum); 55 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum); 56 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum); 57 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum); 56 58 } 57 59 -
trunk/JavaScriptCore/kjs/PrototypeFunction.cpp
r35242 r35807 32 32 namespace KJS { 33 33 34 ASSERT_CLASS_FITS_IN_CELL(PrototypeFunction); 35 34 36 PrototypeFunction::PrototypeFunction(ExecState* exec, int length, const Identifier& name, NativeFunction function) 35 : InternalFunction(exec ->lexicalGlobalObject()->functionPrototype(), name)37 : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), name) 36 38 , m_function(function) 37 39 { … … 41 43 42 44 PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functionPrototype, int length, const Identifier& name, NativeFunction function) 43 : InternalFunction( functionPrototype, name)45 : InternalFunction(exec, functionPrototype, name) 44 46 , m_function(function) 45 47 { -
trunk/JavaScriptCore/kjs/RegExpConstructor.cpp
r35411 r35807 33 33 34 34 namespace KJS { 35 36 ASSERT_CLASS_FITS_IN_CELL(RegExpConstructor); 35 37 36 38 const ClassInfo RegExpConstructor::info = { "Function", &InternalFunction::info, 0, ExecState::regExpConstructorTable }; … … 77 79 78 80 RegExpConstructor::RegExpConstructor(ExecState* exec, FunctionPrototype* functionPrototype, RegExpPrototype* regExpPrototype) 79 : InternalFunction( functionPrototype, Identifier(exec, "RegExp"))81 : InternalFunction(exec, functionPrototype, Identifier(exec, "RegExp")) 80 82 , d(new RegExpConstructorPrivate) 81 83 { -
trunk/JavaScriptCore/kjs/RegExpObject.cpp
r35291 r35807 31 31 namespace KJS { 32 32 33 ASSERT_CLASS_FITS_IN_CELL(RegExpObject); 34 33 35 const ClassInfo RegExpObject::info = { "RegExp", 0, 0, ExecState::regExpTable }; 34 36 … … 45 47 RegExpObject::RegExpObject(RegExpPrototype* regExpPrototype, PassRefPtr<RegExp> regExp) 46 48 : JSObject(regExpPrototype) 47 , m_regExp(regExp) 48 , m_lastIndex(0) 49 , d(new RegExpObjectData(regExp, 0)) 49 50 { 50 51 } … … 63 64 switch (token) { 64 65 case Global: 65 return jsBoolean( m_regExp->global());66 return jsBoolean(d->regExp->global()); 66 67 case IgnoreCase: 67 return jsBoolean( m_regExp->ignoreCase());68 return jsBoolean(d->regExp->ignoreCase()); 68 69 case Multiline: 69 return jsBoolean( m_regExp->multiline());70 return jsBoolean(d->regExp->multiline()); 70 71 case Source: 71 return jsString(exec, m_regExp->pattern());72 return jsString(exec, d->regExp->pattern()); 72 73 case LastIndex: 73 return jsNumber(exec, m_lastIndex);74 return jsNumber(exec, d->lastIndex); 74 75 } 75 76 … … 87 88 UNUSED_PARAM(token); 88 89 ASSERT(token == LastIndex); 89 m_lastIndex = value->toInteger(exec);90 d->lastIndex = value->toInteger(exec); 90 91 } 91 92 … … 108 109 int lastIndex = 0; 109 110 if (global) { 110 if ( m_lastIndex < 0 || m_lastIndex > input.size()) {111 m_lastIndex = 0;111 if (d->lastIndex < 0 || d->lastIndex > input.size()) { 112 d->lastIndex = 0; 112 113 return false; 113 114 } 114 lastIndex = static_cast<int>( m_lastIndex);115 lastIndex = static_cast<int>(d->lastIndex); 115 116 } 116 117 117 118 int foundIndex; 118 119 int foundLength; 119 regExpObj->performMatch( m_regExp.get(), input, lastIndex, foundIndex, foundLength);120 regExpObj->performMatch(d->regExp.get(), input, lastIndex, foundIndex, foundLength); 120 121 121 122 if (global) { 122 123 lastIndex = foundIndex < 0 ? 0 : foundIndex + foundLength; 123 m_lastIndex = lastIndex;124 d->lastIndex = lastIndex; 124 125 } 125 126 -
trunk/JavaScriptCore/kjs/RegExpObject.h
r35027 r35807 36 36 virtual ~RegExpObject(); 37 37 38 void setRegExp(PassRefPtr<RegExp> r) { m_regExp = r; }39 RegExp* regExp() const { return m_regExp.get(); }38 void setRegExp(PassRefPtr<RegExp> r) { d->regExp = r; } 39 RegExp* regExp() const { return d->regExp.get(); } 40 40 41 41 JSValue* test(ExecState*, const ArgList&); … … 50 50 static const ClassInfo info; 51 51 52 void setLastIndex(double lastIndex) { m_lastIndex = lastIndex; }52 void setLastIndex(double lastIndex) { d->lastIndex = lastIndex; } 53 53 54 54 private: … … 56 56 57 57 virtual CallType getCallData(CallData&); 58 59 struct RegExpObjectData { 60 RegExpObjectData(PassRefPtr<RegExp> regExp_, double lastIndex_) 61 : regExp(regExp_) 62 , lastIndex(lastIndex_) 63 { 64 } 58 65 59 RefPtr<RegExp> m_regExp; 60 double m_lastIndex; 66 RefPtr<RegExp> regExp; 67 double lastIndex; 68 }; 69 70 OwnPtr<RegExpObjectData> d; 61 71 }; 62 72 -
trunk/JavaScriptCore/kjs/RegExpPrototype.cpp
r35291 r35807 35 35 namespace KJS { 36 36 37 ASSERT_CLASS_FITS_IN_CELL(RegExpPrototype); 38 37 39 static JSValue* regExpProtoFuncTest(ExecState*, JSObject*, JSValue*, const ArgList&); 38 40 static JSValue* regExpProtoFuncExec(ExecState*, JSObject*, JSValue*, const ArgList&); … … 47 49 : JSObject(objectPrototype) 48 50 { 49 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);50 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);51 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);52 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);51 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum); 52 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum); 53 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum); 54 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum); 53 55 } 54 56 -
trunk/JavaScriptCore/kjs/Shell.cpp
r35478 r35807 166 166 }; 167 167 COMPILE_ASSERT(!IsInteger<GlobalObject>::value, WTF_IsInteger_GlobalObject_false); 168 ASSERT_CLASS_FITS_IN_CELL(GlobalObject); 168 169 169 170 GlobalObject::GlobalObject(Vector<UString>& arguments) 170 171 { 171 putDirectFunction( new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "debug"), functionDebug));172 putDirectFunction( new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "print"), functionPrint));173 putDirectFunction( new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "quit"), functionQuit));174 putDirectFunction( new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "gc"), functionGC));175 putDirectFunction( new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "version"), functionVersion));176 putDirectFunction( new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "run"), functionRun));177 putDirectFunction( new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "load"), functionLoad));178 putDirectFunction( new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "readline"), functionReadline));172 putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "debug"), functionDebug)); 173 putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "print"), functionPrint)); 174 putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "quit"), functionQuit)); 175 putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "gc"), functionGC)); 176 putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "version"), functionVersion)); 177 putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "run"), functionRun)); 178 putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "load"), functionLoad)); 179 putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "readline"), functionReadline)); 179 180 180 181 JSObject* array = constructEmptyArray(globalExec()); -
trunk/JavaScriptCore/kjs/StringConstructor.cpp
r35411 r35807 45 45 } 46 46 47 ASSERT_CLASS_FITS_IN_CELL(StringConstructor); 48 47 49 StringConstructor::StringConstructor(ExecState* exec, FunctionPrototype* functionPrototype, StringPrototype* stringPrototype) 48 : InternalFunction( functionPrototype, Identifier(exec, stringPrototype->classInfo()->className))50 : InternalFunction(exec, functionPrototype, Identifier(exec, stringPrototype->classInfo()->className)) 49 51 { 50 52 // ECMA 15.5.3.1 String.prototype … … 52 54 53 55 // ECMA 15.5.3.2 fromCharCode() 54 putDirectFunction( new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);56 putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum); 55 57 56 58 // no. of arguments for constructor -
trunk/JavaScriptCore/kjs/StringObject.cpp
r35806 r35807 25 25 26 26 namespace KJS { 27 28 ASSERT_CLASS_FITS_IN_CELL(StringObject); 27 29 28 30 const ClassInfo StringObject::info = { "String", 0, 0, 0 }; -
trunk/JavaScriptCore/kjs/StringPrototype.cpp
r35291 r35807 34 34 35 35 namespace KJS { 36 37 ASSERT_CLASS_FITS_IN_CELL(StringPrototype); 36 38 37 39 static JSValue* stringProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&); -
trunk/JavaScriptCore/kjs/collector.h
r35639 r35807 34 34 #include <pthread.h> 35 35 #endif 36 37 #define ASSERT_CLASS_FITS_IN_CELL(class) COMPILE_ASSERT(sizeof(class) <= CELL_SIZE, class_fits_in_cell) 36 38 37 39 namespace KJS { -
trunk/JavaScriptCore/profiler/Profiler.cpp
r35756 r35807 30 30 #include "Profiler.h" 31 31 32 #include "CommonIdentifiers.h" 32 33 #include "ExecState.h" 33 34 #include "JSFunction.h" … … 44 45 static unsigned ProfilesUID = 0; 45 46 46 static CallIdentifier createCallIdentifier( JSObject*);47 static CallIdentifier createCallIdentifier( const UString& sourceURL, int startingLineNumber);48 static CallIdentifier createCallIdentifierFromFunctionImp( JSFunction*);47 static CallIdentifier createCallIdentifier(ExecState*, JSObject*); 48 static CallIdentifier createCallIdentifier(ExecState*, const UString& sourceURL, int startingLineNumber); 49 static CallIdentifier createCallIdentifierFromFunctionImp(ExecState*, JSFunction*); 49 50 50 51 Profiler* Profiler::s_sharedProfiler = 0; … … 116 117 ASSERT(!m_currentProfiles.isEmpty()); 117 118 118 dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier( calledFunction), exec->lexicalGlobalObject()->profileGroup());119 dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(exec, calledFunction), exec->lexicalGlobalObject()->profileGroup()); 119 120 } 120 121 … … 123 124 ASSERT(!m_currentProfiles.isEmpty()); 124 125 125 CallIdentifier callIdentifier = createCallIdentifier( sourceURL, startingLineNumber);126 CallIdentifier callIdentifier = createCallIdentifier(exec, sourceURL, startingLineNumber); 126 127 127 128 dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, callIdentifier, exec->lexicalGlobalObject()->profileGroup()); … … 132 133 ASSERT(!m_currentProfiles.isEmpty()); 133 134 134 dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier( calledFunction), exec->lexicalGlobalObject()->profileGroup());135 dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, calledFunction), exec->lexicalGlobalObject()->profileGroup()); 135 136 } 136 137 … … 139 140 ASSERT(!m_currentProfiles.isEmpty()); 140 141 141 dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier( sourceURL, startingLineNumber), exec->lexicalGlobalObject()->profileGroup());142 dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, sourceURL, startingLineNumber), exec->lexicalGlobalObject()->profileGroup()); 142 143 } 143 144 144 CallIdentifier createCallIdentifier( JSObject* calledFunction)145 CallIdentifier createCallIdentifier(ExecState* exec, JSObject* calledFunction) 145 146 { 146 147 if (calledFunction->inherits(&JSFunction::info)) 147 return createCallIdentifierFromFunctionImp( static_cast<JSFunction*>(calledFunction));148 return createCallIdentifierFromFunctionImp(exec, static_cast<JSFunction*>(calledFunction)); 148 149 if (calledFunction->inherits(&InternalFunction::info)) 149 return CallIdentifier(static_cast<InternalFunction*>(calledFunction)-> functionName().ustring(), "", 0);150 return CallIdentifier(static_cast<InternalFunction*>(calledFunction)->name(exec), "", 0); 150 151 151 152 UString name = "(" + calledFunction->className() + " object)"; … … 153 154 } 154 155 155 CallIdentifier createCallIdentifier( const UString& sourceURL, int startingLineNumber)156 CallIdentifier createCallIdentifier(ExecState*, const UString& sourceURL, int startingLineNumber) 156 157 { 157 158 return CallIdentifier(GlobalCodeExecution, sourceURL, startingLineNumber); 158 159 } 159 160 160 CallIdentifier createCallIdentifierFromFunctionImp( JSFunction* functionImp)161 CallIdentifier createCallIdentifierFromFunctionImp(ExecState* exec, JSFunction* function) 161 162 { 162 UString name = functionImp->functionName().ustring(); 163 if (name.isEmpty()) 164 name = AnonymousFunction; 165 166 return CallIdentifier(name, functionImp->m_body->sourceURL(), functionImp->m_body->lineNo()); 163 const UString& name = function->name(exec); 164 return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, function->m_body->sourceURL(), function->m_body->lineNo()); 167 165 } 168 166 -
trunk/WebCore/ChangeLog
r35804 r35807 1 2008-08-17 Geoffrey Garen <[email protected]> 2 3 Reviewed by Cameron Zwarich. 4 5 Made room for a free word in JSCell. 6 7 Changed JSDOMWindowBase to store its auxiliary data in a subclass of 8 JSGlobalData, so the two could share a pointer. 9 10 Added a bunch of ASSERTs, to help catch over-sized objects. 11 1 12 2008-08-15 Mark Rowe <[email protected]> 2 13 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r35804 r35807 15457 15457 projectDirPath = ""; 15458 15458 projectRoot = ""; 15459 projectRoots = (15460 "",15461 );15462 15459 targets = ( 15463 15460 93F198A508245E59001E9ABC /* WebCore */, -
trunk/WebCore/bindings/js/JSDOMWindowBase.cpp
r35666 r35807 193 193 */ 194 194 195 JSDOMWindowBase::JSDOMWindowBaseData::JSDOMWindowBaseData(PassRefPtr<DOMWindow> window_, JSDOMWindowBase* jsWindow_, JSDOMWindowShell* shell_) 196 : JSGlobalObjectData(jsWindow_, shell_) 197 , impl(window_) 198 , evt(0) 199 , returnValueSlot(0) 200 , shell(shell_) 201 { 202 } 203 195 204 JSDOMWindowBase::JSDOMWindowBase(JSObject* prototype, DOMWindow* window, JSDOMWindowShell* shell) 196 : JSGlobalObject(prototype, shell) 197 , m_impl(window) 198 , d(new JSDOMWindowBasePrivate(shell)) 205 : JSGlobalObject(prototype, new JSDOMWindowBaseData(window, this, shell), shell) 199 206 { 200 207 // Time in milliseconds before the script timeout handler kicks in. … … 203 210 GlobalPropertyInfo staticGlobals[] = { 204 211 GlobalPropertyInfo(Identifier(globalExec(), "document"), jsNull(), DontDelete | ReadOnly), 205 GlobalPropertyInfo(Identifier(globalExec(), "window"), d ->m_shell, DontDelete | ReadOnly)212 GlobalPropertyInfo(Identifier(globalExec(), "window"), d()->shell, DontDelete | ReadOnly) 206 213 }; 207 214 … … 211 218 void JSDOMWindowBase::updateDocument() 212 219 { 213 ASSERT( m_impl->document());220 ASSERT(d()->impl->document()); 214 221 ExecState* exec = globalExec(); 215 symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, m_impl->document()), DontDelete | ReadOnly);222 symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, d()->impl->document()), DontDelete | ReadOnly); 216 223 } 217 224 218 225 JSDOMWindowBase::~JSDOMWindowBase() 219 226 { 220 if ( m_impl->frame())221 m_impl->frame()->script()->clearFormerWindow(asJSDOMWindow(this));227 if (d()->impl->frame()) 228 d()->impl->frame()->script()->clearFormerWindow(asJSDOMWindow(this)); 222 229 223 230 clearAllTimeouts(); … … 225 232 // Clear any backpointers to the window 226 233 227 ListenersMap::iterator i2 = d ->jsEventListeners.begin();228 ListenersMap::iterator e2 = d ->jsEventListeners.end();234 ListenersMap::iterator i2 = d()->jsEventListeners.begin(); 235 ListenersMap::iterator e2 = d()->jsEventListeners.end(); 229 236 for (; i2 != e2; ++i2) 230 237 i2->second->clearWindow(); 231 i2 = d ->jsHTMLEventListeners.begin();232 e2 = d ->jsHTMLEventListeners.end();238 i2 = d()->jsHTMLEventListeners.begin(); 239 e2 = d()->jsHTMLEventListeners.end(); 233 240 for (; i2 != e2; ++i2) 234 241 i2->second->clearWindow(); 235 242 236 UnprotectedListenersMap::iterator i1 = d ->jsUnprotectedEventListeners.begin();237 UnprotectedListenersMap::iterator e1 = d ->jsUnprotectedEventListeners.end();243 UnprotectedListenersMap::iterator i1 = d()->jsUnprotectedEventListeners.begin(); 244 UnprotectedListenersMap::iterator e1 = d()->jsUnprotectedEventListeners.end(); 238 245 for (; i1 != e1; ++i1) 239 246 i1->second->clearWindow(); 240 i1 = d ->jsUnprotectedHTMLEventListeners.begin();241 e1 = d ->jsUnprotectedHTMLEventListeners.end();247 i1 = d()->jsUnprotectedHTMLEventListeners.begin(); 248 e1 = d()->jsUnprotectedHTMLEventListeners.end(); 242 249 for (; i1 != e1; ++i1) 243 250 i1->second->clearWindow(); … … 432 439 if (!allowsAccessFrom(exec)) 433 440 return jsUndefined(); 434 if (!d ->m_evt)435 return jsUndefined(); 436 return toJS(exec, d ->m_evt);441 if (!d()->evt) 442 return jsUndefined(); 443 return toJS(exec, d()->evt); 437 444 case Image: 438 445 if (!allowsAccessFrom(exec)) … … 835 842 return 0; 836 843 JSObject* object = static_cast<JSObject*>(val); 837 ListenersMap& listeners = html ? d ->jsHTMLEventListeners : d->jsEventListeners;844 ListenersMap& listeners = html ? d()->jsHTMLEventListeners : d()->jsEventListeners; 838 845 return listeners.get(object); 839 846 } … … 858 865 return 0; 859 866 JSObject* object = static_cast<JSObject*>(val); 860 UnprotectedListenersMap& listeners = html ? d ->jsUnprotectedHTMLEventListeners : d->jsUnprotectedEventListeners;867 UnprotectedListenersMap& listeners = html ? d()->jsUnprotectedHTMLEventListeners : d()->jsUnprotectedEventListeners; 861 868 return listeners.get(object); 862 869 } … … 877 884 void JSDOMWindowBase::clearHelperObjectProperties() 878 885 { 879 d ->m_evt = 0;886 d()->evt = 0; 880 887 } 881 888 882 889 void JSDOMWindowBase::clear() 883 890 { 884 if (d ->m_returnValueSlot && !*d->m_returnValueSlot)885 *d ->m_returnValueSlot = getDirect(Identifier(globalExec(), "returnValue"));891 if (d()->returnValueSlot && !*d()->returnValueSlot) 892 *d()->returnValueSlot = getDirect(Identifier(globalExec(), "returnValue")); 886 893 887 894 clearAllTimeouts(); … … 891 898 void JSDOMWindowBase::setCurrentEvent(Event* evt) 892 899 { 893 d ->m_evt = evt;900 d()->evt = evt; 894 901 } 895 902 896 903 Event* JSDOMWindowBase::currentEvent() 897 904 { 898 return d ->m_evt;905 return d()->evt; 899 906 } 900 907 … … 906 913 JSDOMWindowShell* JSDOMWindowBase::shell() const 907 914 { 908 return d ->m_shell;915 return d()->shell; 909 916 } 910 917 … … 1154 1161 void JSDOMWindowBase::setReturnValueSlot(JSValue** slot) 1155 1162 { 1156 d ->m_returnValueSlot = slot;1163 d()->returnValueSlot = slot; 1157 1164 } 1158 1165 … … 1161 1168 void JSDOMWindowBase::clearAllTimeouts() 1162 1169 { 1163 deleteAllValues(d ->m_timeouts);1164 d ->m_timeouts.clear();1170 deleteAllValues(d()->timeouts); 1171 d()->timeouts.clear(); 1165 1172 } 1166 1173 … … 1175 1182 int nestLevel = timerNestingLevel + 1; 1176 1183 DOMWindowTimer* timer = new DOMWindowTimer(timeoutId, nestLevel, this, a); 1177 ASSERT(!d ->m_timeouts.get(timeoutId));1178 d ->m_timeouts.set(timeoutId, timer);1184 ASSERT(!d()->timeouts.get(timeoutId)); 1185 d()->timeouts.set(timeoutId, timer); 1179 1186 // Use a minimum interval of 10 ms to match other browsers, but only once we've 1180 1187 // nested enough to notice that we're repeating. … … 1202 1209 PausedTimeouts* JSDOMWindowBase::pauseTimeouts() 1203 1210 { 1204 size_t count = d ->m_timeouts.size();1211 size_t count = d()->timeouts.size(); 1205 1212 if (count == 0) 1206 1213 return 0; … … 1209 1216 PausedTimeouts* result = new PausedTimeouts(t, count); 1210 1217 1211 JSDOMWindowBase Private::TimeoutsMap::iterator it = d->m_timeouts.begin();1218 JSDOMWindowBaseData::TimeoutsMap::iterator it = d()->timeouts.begin(); 1212 1219 for (size_t i = 0; i != count; ++i, ++it) { 1213 1220 int timeoutId = it->first; … … 1219 1226 t[i].action = timer->takeAction(); 1220 1227 } 1221 ASSERT(it == d ->m_timeouts.end());1222 1223 deleteAllValues(d ->m_timeouts);1224 d ->m_timeouts.clear();1228 ASSERT(it == d()->timeouts.end()); 1229 1230 deleteAllValues(d()->timeouts); 1231 d()->timeouts.clear(); 1225 1232 1226 1233 return result; … … 1236 1243 int timeoutId = array[i].timeoutId; 1237 1244 DOMWindowTimer* timer = new DOMWindowTimer(timeoutId, array[i].nestingLevel, this, array[i].action); 1238 d ->m_timeouts.set(timeoutId, timer);1245 d()->timeouts.set(timeoutId, timer); 1239 1246 timer->start(array[i].nextFireInterval, array[i].repeatInterval); 1240 1247 } … … 1250 1257 return; 1251 1258 1252 delete d ->m_timeouts.take(timeoutId);1259 delete d()->timeouts.take(timeoutId); 1253 1260 } 1254 1261 … … 1262 1269 // The DOMWindowTimer object may have been deleted or replaced during execution, 1263 1270 // so we re-fetch it. 1264 timer = d ->m_timeouts.get(timeoutId);1271 timer = d()->timeouts.get(timeoutId); 1265 1272 if (!timer) 1266 1273 return; … … 1276 1283 // Delete timer before executing the action for one-shot timers. 1277 1284 ScheduledAction* action = timer->takeAction(); 1278 d ->m_timeouts.remove(timer->timeoutId());1285 d()->timeouts.remove(timer->timeoutId()); 1279 1286 delete timer; 1280 1287 action->execute(shell()); … … 1290 1297 JSDOMWindowBase::ListenersMap& JSDOMWindowBase::jsEventListeners() 1291 1298 { 1292 return d ->jsEventListeners;1299 return d()->jsEventListeners; 1293 1300 } 1294 1301 1295 1302 JSDOMWindowBase::ListenersMap& JSDOMWindowBase::jsHTMLEventListeners() 1296 1303 { 1297 return d ->jsHTMLEventListeners;1304 return d()->jsHTMLEventListeners; 1298 1305 } 1299 1306 1300 1307 JSDOMWindowBase::UnprotectedListenersMap& JSDOMWindowBase::jsUnprotectedEventListeners() 1301 1308 { 1302 return d ->jsUnprotectedEventListeners;1309 return d()->jsUnprotectedEventListeners; 1303 1310 } 1304 1311 1305 1312 JSDOMWindowBase::UnprotectedListenersMap& JSDOMWindowBase::jsUnprotectedHTMLEventListeners() 1306 1313 { 1307 return d ->jsUnprotectedHTMLEventListeners;1314 return d()->jsUnprotectedHTMLEventListeners; 1308 1315 } 1309 1316 -
trunk/WebCore/bindings/js/JSDOMWindowBase.h
r35666 r35807 61 61 void updateDocument(); 62 62 63 DOMWindow* impl() const { return m_impl.get(); }63 DOMWindow* impl() const { return d()->impl.get(); } 64 64 65 65 void disconnectFrame(); … … 147 147 148 148 private: 149 struct JSDOMWindowBaseData : public JSGlobalObjectData { 150 JSDOMWindowBaseData(PassRefPtr<DOMWindow> window_, JSDOMWindowBase* jsWindow_, JSDOMWindowShell* shell_); 151 152 RefPtr<DOMWindow> impl; 153 154 JSDOMWindowBase::ListenersMap jsEventListeners; 155 JSDOMWindowBase::ListenersMap jsHTMLEventListeners; 156 JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedEventListeners; 157 JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedHTMLEventListeners; 158 Event* evt; 159 KJS::JSValue** returnValueSlot; 160 JSDOMWindowShell* shell; 161 162 typedef HashMap<int, DOMWindowTimer*> TimeoutsMap; 163 TimeoutsMap timeouts; 164 }; 165 149 166 KJS::JSValue* getListener(KJS::ExecState*, const AtomicString& eventType) const; 150 167 void setListener(KJS::ExecState*, const AtomicString& eventType, KJS::JSValue* function); … … 160 177 bool allowsAccessFromPrivate(const KJS::JSGlobalObject*) const; 161 178 String crossDomainAccessErrorMessage(const KJS::JSGlobalObject*) const; 162 163 RefPtr<DOMWindow> m_impl; 164 OwnPtr<JSDOMWindowBasePrivate> d; 179 180 JSDOMWindowBaseData* d() const { return static_cast<JSDOMWindowBaseData*>(KJS::JSVariableObject::d); } 165 181 }; 166 182 -
trunk/WebCore/bindings/js/JSDOMWindowCustom.h
r34607 r35807 25 25 26 26 namespace WebCore { 27 28 struct JSDOMWindowBasePrivate {29 JSDOMWindowBasePrivate(JSDOMWindowShell* shell)30 : m_evt(0)31 , m_returnValueSlot(0)32 , m_shell(shell)33 {34 }35 36 JSDOMWindowBase::ListenersMap jsEventListeners;37 JSDOMWindowBase::ListenersMap jsHTMLEventListeners;38 JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedEventListeners;39 JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedHTMLEventListeners;40 Event* m_evt;41 KJS::JSValue** m_returnValueSlot;42 JSDOMWindowShell* m_shell;43 44 typedef HashMap<int, DOMWindowTimer*> TimeoutsMap;45 TimeoutsMap m_timeouts;46 };47 27 48 28 inline JSDOMWindow* asJSDOMWindow(KJS::JSGlobalObject* globalObject) … … 181 161 { 182 162 const JSDOMWindow* originWindow = asJSDOMWindow(other); 183 const JSDOMWindow* targetWindow = d ->m_shell->window();163 const JSDOMWindow* targetWindow = d()->shell->window(); 184 164 185 165 if (originWindow == targetWindow) -
trunk/WebCore/bindings/js/JSDOMWindowShell.cpp
r35159 r35807 39 39 40 40 namespace WebCore { 41 42 ASSERT_CLASS_FITS_IN_CELL(JSDOMWindowShell) 41 43 42 44 const ClassInfo JSDOMWindowShell::s_info = { "JSDOMWindowShell", 0, 0, 0 }; -
trunk/WebCore/bindings/js/JSEventListener.cpp
r35783 r35807 42 42 using namespace EventNames; 43 43 44 ASSERT_CLASS_FITS_IN_CELL(JSAbstractEventListener) 45 44 46 void JSAbstractEventListener::handleEvent(Event* event, bool isWindowEvent) 45 47 { -
trunk/WebCore/bindings/js/JSEventTargetNode.cpp
r34659 r35807 35 35 using namespace KJS; 36 36 37 ASSERT_CLASS_FITS_IN_CELL(JSEventTargetNode) 38 37 39 JSEventTargetNode::JSEventTargetNode(JSObject* prototype, Node* node) 38 40 : JSNode(prototype, node) -
trunk/WebCore/bindings/js/JSHTMLInputElementBase.cpp
r35291 r35807 26 26 27 27 namespace WebCore { 28 29 ASSERT_CLASS_FITS_IN_CELL(JSHTMLInputElementBase) 28 30 29 31 static JSValue* jsHTMLInputElementBaseFunctionSetSelectionRange(ExecState*, JSObject*, JSValue*, const ArgList&); -
trunk/WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp
r35411 r35807 29 29 30 30 namespace WebCore { 31 32 ASSERT_CLASS_FITS_IN_CELL(JSHTMLOptionElementConstructor) 31 33 32 34 const ClassInfo JSHTMLOptionElementConstructor::s_info = { "OptionConstructor", 0, 0, 0 }; -
trunk/WebCore/bindings/js/JSImageConstructor.cpp
r35411 r35807 28 28 29 29 namespace WebCore { 30 31 ASSERT_CLASS_FITS_IN_CELL(JSImageConstructor) 30 32 31 33 const ClassInfo JSImageConstructor::s_info = { "ImageConstructor", 0, 0, 0 }; -
trunk/WebCore/bindings/js/JSInspectedObjectWrapper.cpp
r34659 r35807 32 32 33 33 namespace WebCore { 34 35 ASSERT_CLASS_FITS_IN_CELL(JSInspectedObjectWrapper) 34 36 35 37 typedef HashMap<JSObject*, JSInspectedObjectWrapper*> WrapperMap; -
trunk/WebCore/bindings/js/JSInspectorCallbackWrapper.cpp
r34754 r35807 32 32 33 33 namespace WebCore { 34 35 ASSERT_CLASS_FITS_IN_CELL(JSInspectorCallbackWrapper) 34 36 35 37 typedef HashMap<JSObject*, JSInspectorCallbackWrapper*> WrapperMap; -
trunk/WebCore/bindings/js/JSNSResolver.cpp
r35478 r35807 35 35 36 36 namespace WebCore { 37 38 ASSERT_CLASS_FITS_IN_CELL(JSNSResolver) 37 39 38 40 JSNSResolver::JSNSResolver(JSValue* resolver) -
trunk/WebCore/bindings/js/JSNamedNodesCollection.cpp
r34659 r35807 36 36 using namespace KJS; 37 37 38 ASSERT_CLASS_FITS_IN_CELL(JSNamedNodesCollection) 39 38 40 const ClassInfo JSNamedNodesCollection::s_info = { "Collection", 0, 0, 0 }; 39 41 … … 43 45 JSNamedNodesCollection::JSNamedNodesCollection(KJS::JSObject* prototype, const Vector<RefPtr<Node> >& nodes) 44 46 : DOMObject(prototype) 45 , m_nodes(n odes)47 , m_nodes(new Vector<RefPtr<Node> >(nodes)) 46 48 { 47 49 } … … 50 52 { 51 53 JSNamedNodesCollection* thisObj = static_cast<JSNamedNodesCollection*>(slot.slotBase()); 52 return jsNumber(exec, thisObj->m_nodes .size());54 return jsNumber(exec, thisObj->m_nodes->size()); 53 55 } 54 56 … … 56 58 { 57 59 JSNamedNodesCollection *thisObj = static_cast<JSNamedNodesCollection*>(slot.slotBase()); 58 return toJS(exec, thisObj->m_nodes[slot.index()].get());60 return toJS(exec, (*thisObj->m_nodes)[slot.index()].get()); 59 61 } 60 62 … … 68 70 bool ok; 69 71 unsigned index = propertyName.toUInt32(&ok); 70 if (ok && index < m_nodes .size()) {72 if (ok && index < m_nodes->size()) { 71 73 slot.setCustomIndex(this, index, indexGetter); 72 74 return true; … … 77 79 78 80 AtomicString atomicPropertyName = propertyName; 79 for (unsigned i = 0; i < m_nodes .size(); i++) {80 Node* node = m_nodes[i].get();81 for (unsigned i = 0; i < m_nodes->size(); i++) { 82 Node* node = (*m_nodes)[i].get(); 81 83 if (node->hasAttributes() && node->attributes()->id() == atomicPropertyName) { 82 84 slot.setCustomIndex(this, i, indexGetter); -
trunk/WebCore/bindings/js/JSNamedNodesCollection.h
r34561 r35807 49 49 static KJS::JSValue* indexGetter(KJS::ExecState*, const KJS::Identifier&, const KJS::PropertySlot&); 50 50 51 Vector<RefPtr<Node> > m_nodes;51 OwnPtr<Vector<RefPtr<Node> > > m_nodes; 52 52 }; 53 53 -
trunk/WebCore/bindings/js/JSNodeFilterCondition.cpp
r35478 r35807 28 28 29 29 using namespace KJS; 30 31 ASSERT_CLASS_FITS_IN_CELL(JSNodeFilterCondition) 30 32 31 33 JSNodeFilterCondition::JSNodeFilterCondition(JSValue* filter) -
trunk/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp
r35411 r35807 33 33 namespace WebCore { 34 34 35 ASSERT_CLASS_FITS_IN_CELL(JSQuarantinedObjectWrapper) 36 35 37 const ClassInfo JSQuarantinedObjectWrapper::s_info = { "JSQuarantinedObjectWrapper", 0, 0, 0 }; 36 38 -
trunk/WebCore/bindings/js/JSRGBColor.cpp
r34754 r35807 32 32 33 33 namespace WebCore { 34 35 ASSERT_CLASS_FITS_IN_CELL(JSRGBColor) 34 36 35 37 const ClassInfo JSRGBColor::s_info = { "RGBColor", 0, &JSRGBColorTable, 0 }; -
trunk/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp
r35411 r35807 29 29 namespace WebCore { 30 30 31 ASSERT_CLASS_FITS_IN_CELL(JSXMLHttpRequestConstructor) 32 31 33 const ClassInfo JSXMLHttpRequestConstructor::s_info = { "XMLHttpRequestConstructor", 0, 0, 0 }; 32 34 -
trunk/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp
r35411 r35807 38 38 namespace WebCore { 39 39 40 ASSERT_CLASS_FITS_IN_CELL(JSXSLTProcessorConstructor) 41 40 42 const ClassInfo JSXSLTProcessorConstructor::s_info = { "XSLTProcessorConsructor", 0, 0, 0 }; 41 43 -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r35674 r35807 727 727 push(@implContent, "\nusing namespace KJS;\n\n"); 728 728 push(@implContent, "namespace WebCore {\n\n"); 729 730 push(@implContent, "ASSERT_CLASS_FITS_IN_CELL($className)\n\n"); 729 731 730 732 # - Add all attributes in a hashtable definition -
trunk/WebCore/bridge/jni/jni_utility.cpp
r35478 r35807 355 355 // other than a string. 356 356 JSArray *jsArray = static_cast<JSArray *>(value); 357 unsigned length = jsArray-> getLength();357 unsigned length = jsArray->length(); 358 358 jobjectArray jarray = 0; 359 359 -
trunk/WebCore/bridge/runtime_method.cpp
r35242 r35807 35 35 using namespace Bindings; 36 36 37 ASSERT_CLASS_FITS_IN_CELL(RuntimeMethod); 38 37 39 RuntimeMethod::RuntimeMethod(ExecState *exec, const Identifier &ident, Bindings::MethodList &m) 38 : InternalFunction(exec ->lexicalGlobalObject()->functionPrototype(), ident)40 : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), ident) 39 41 , _methodList(new MethodList(m)) 40 42 { -
trunk/WebKit/mac/ChangeLog
r35802 r35807 1 2008-08-17 Geoffrey Garen <[email protected]> 2 3 Reviewed by Cameron Zwarich. 4 5 Made room for a free word in JSCell. 6 7 (Updated for JavaScriptCore changes.) 8 1 9 2008-08-15 Mark Rowe <[email protected]> 2 10 -
trunk/WebKit/mac/WebView/WebScriptDebugger.mm
r35590 r35807 81 81 { 82 82 attach(globalObject); 83 DebuggerCallFrame globalCallFrame( globalObject, 0, globalObject->globalScopeChain().node(), 0, 0);83 DebuggerCallFrame globalCallFrame(0, globalObject, 0, globalObject->globalScopeChain().node(), 0, 0); 84 84 callEvent(globalCallFrame, 0, -1); 85 85 } -
trunk/WebKit/mac/WebView/WebView.mm
r35767 r35807 3251 3251 JSArray* array = static_cast<JSArray*>(object); 3252 3252 aeDesc = [NSAppleEventDescriptor listDescriptor]; 3253 unsigned numItems = array-> getLength();3253 unsigned numItems = array->length(); 3254 3254 for (unsigned i = 0; i < numItems; ++i) 3255 3255 [aeDesc insertDescriptor:aeDescFromJSValue(exec, array->get(exec, i)) atIndex:0];
Note:
See TracChangeset
for help on using the changeset viewer.