Changeset 82173 in webkit
- Timestamp:
- Mar 28, 2011 4:39:16 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r82169 r82173 1 2011-03-28 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 instanceof Array test fails when using iframes 6 https://bugs.webkit.org/show_bug.cgi?id=17250 7 8 Add test cases for correct behaviour 9 10 * fast/js/js-constructors-use-correct-global-expected.txt: Added. 11 * fast/js/js-constructors-use-correct-global.html: Added. 12 * fast/js/resources/js-constructors-use-correct-global.js: Added. 13 1 14 2011-03-28 Vincent Scheib <scheib@chromium.org> 2 15 -
trunk/Source/JavaScriptCore/API/JSObjectRef.cpp
r79132 r82173 125 125 args.append(jsString(exec, body->ustring())); 126 126 127 JSObject* result = constructFunction(exec, args, nameID, sourceURL->ustring(), startingLineNumber);127 JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, sourceURL->ustring(), startingLineNumber); 128 128 if (exec->hadException()) { 129 129 if (exception) … … 208 208 argList.append(toJS(exec, arguments[i])); 209 209 210 JSObject* result = constructRegExp(exec, argList);210 JSObject* result = constructRegExp(exec, exec->lexicalGlobalObject(), argList); 211 211 if (exec->hadException()) { 212 212 if (exception) -
trunk/Source/JavaScriptCore/ChangeLog
r82162 r82173 1 2011-03-28 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 instanceof Array test fails when using iframes 6 https://bugs.webkit.org/show_bug.cgi?id=17250 7 8 This is a problem with all built in constructors, the use of 9 lexicalGlobalObject rather than the constructors own 10 global object reference means that a builtin will always use 11 the prototype from the lexical global object rather than that 12 of the constructors origin. 13 14 * API/JSObjectRef.cpp: 15 (JSObjectMakeFunction): 16 (JSObjectMakeRegExp): 17 * JavaScriptCore.exp: 18 * runtime/ArrayConstructor.cpp: 19 (JSC::constructArrayWithSizeQuirk): 20 * runtime/BooleanConstructor.cpp: 21 (JSC::constructBoolean): 22 (JSC::constructBooleanFromImmediateBoolean): 23 * runtime/BooleanConstructor.h: 24 * runtime/DateConstructor.cpp: 25 (JSC::constructDate): 26 * runtime/DateInstance.cpp: 27 * runtime/DateInstance.h: 28 * runtime/ErrorConstructor.cpp: 29 (JSC::constructWithErrorConstructor): 30 (JSC::callErrorConstructor): 31 * runtime/FunctionConstructor.cpp: 32 (JSC::constructWithFunctionConstructor): 33 (JSC::callFunctionConstructor): 34 (JSC::constructFunction): 35 * runtime/FunctionConstructor.h: 36 * runtime/JSCell.cpp: 37 (JSC::JSCell::getOwnPropertySlot): 38 (JSC::JSCell::put): 39 (JSC::JSCell::deleteProperty): 40 (JSC::JSCell::toThisObject): 41 (JSC::JSCell::toObject): 42 * runtime/JSCell.h: 43 (JSC::JSCell::JSValue::toObject): 44 * runtime/JSNotAnObject.cpp: 45 (JSC::JSNotAnObject::toObject): 46 * runtime/JSNotAnObject.h: 47 * runtime/JSObject.cpp: 48 (JSC::JSObject::toObject): 49 * runtime/JSObject.h: 50 * runtime/JSString.cpp: 51 (JSC::StringObject::create): 52 (JSC::JSString::toObject): 53 (JSC::JSString::toThisObject): 54 * runtime/JSString.h: 55 * runtime/JSValue.cpp: 56 (JSC::JSValue::toObjectSlowCase): 57 (JSC::JSValue::toThisObjectSlowCase): 58 (JSC::JSValue::synthesizeObject): 59 * runtime/JSValue.h: 60 * runtime/NumberConstructor.cpp: 61 (JSC::constructWithNumberConstructor): 62 * runtime/NumberObject.cpp: 63 (JSC::constructNumber): 64 * runtime/NumberObject.h: 65 * runtime/ObjectConstructor.cpp: 66 (JSC::constructObject): 67 (JSC::constructWithObjectConstructor): 68 (JSC::callObjectConstructor): 69 * runtime/RegExpConstructor.cpp: 70 (JSC::constructRegExp): 71 (JSC::constructWithRegExpConstructor): 72 (JSC::callRegExpConstructor): 73 * runtime/RegExpConstructor.h: 74 * runtime/StringConstructor.cpp: 75 (JSC::constructWithStringConstructor): 76 * runtime/StringObject.h: 77 1 78 2011-03-28 Geoffrey Garen <ggaren@apple.com> 2 79 -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r81969 r82173 123 123 __ZN3JSC12DateInstance6s_infoE 124 124 __ZN3JSC12DateInstanceC1EPNS_9ExecStateEN3WTF17NonNullPassRefPtrINS_9StructureEEEd 125 __ZN3JSC12DateInstanceC1EPNS_9ExecStateEd126 125 __ZN3JSC12JSGlobalData10ClientDataD2Ev 127 126 __ZN3JSC12JSGlobalData11jsArrayVPtrE … … 183 182 __ZN3JSC17BytecodeGenerator21setDumpsGeneratedCodeEb 184 183 __ZN3JSC17PropertyNameArray3addEPN3WTF10StringImplE 185 __ZN3JSC17constructFunctionEPNS_9ExecStateE RKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi184 __ZN3JSC17constructFunctionEPNS_9ExecStateEPNS_14JSGlobalObjectERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi 186 185 __ZN3JSC17createSyntaxErrorEPNS_9ExecStateERKNS_7UStringE 187 186 __ZN3JSC18DebuggerActivationC1ERNS_12JSGlobalDataEPNS_8JSObjectE … … 536 535 __ZNK3JSC6JSCell14isGetterSetterEv 537 536 __ZNK3JSC6JSCell8toNumberEPNS_9ExecStateE 538 __ZNK3JSC6JSCell8toObjectEPNS_9ExecStateE 537 __ZNK3JSC6JSCell8toObjectEPNS_9ExecStateEPNS_14JSGlobalObjectE 539 538 __ZNK3JSC6JSCell8toStringEPNS_9ExecStateE 540 539 __ZNK3JSC6JSCell9getStringEPNS_9ExecStateE … … 544 543 __ZNK3JSC7ArgList8getSliceEiRS0_ 545 544 __ZNK3JSC7JSArray12subclassDataEv 546 __ZNK3JSC7JSValue16toObjectSlowCaseEPNS_9ExecStateE 545 __ZNK3JSC7JSValue16toObjectSlowCaseEPNS_9ExecStateEPNS_14JSGlobalObjectE 547 546 __ZNK3JSC7JSValue19synthesizePrototypeEPNS_9ExecStateE 548 547 __ZNK3JSC7JSValue20toThisObjectSlowCaseEPNS_9ExecStateE … … 557 556 __ZNK3JSC8JSObject18toStrictThisObjectEPNS_9ExecStateE 558 557 __ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE 559 __ZNK3JSC8JSObject8toObjectEPNS_9ExecStateE 558 __ZNK3JSC8JSObject8toObjectEPNS_9ExecStateEPNS_14JSGlobalObjectE 560 559 __ZNK3JSC8JSObject8toStringEPNS_9ExecStateE 561 560 __ZNK3JSC8JSObject9classNameEv -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r81943 r82173 4 4 ??0CString@WTF@@QAE@PBDI@Z 5 5 ??0Collator@WTF@@QAE@PBD@Z 6 ??0DateInstance@JSC@@QAE@PAVExecState@1@N@Z7 6 ??0DateInstance@JSC@@QAE@PAVExecState@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@N@Z 8 7 ??0DefaultGCActivityCallback@JSC@@QAE@PAVHeap@1@@Z … … 95 94 ?constructEmptyArray@JSC@@YAPAVJSArray@1@PAVExecState@1@@Z 96 95 ?constructEmptyObject@JSC@@YAPAVJSObject@1@PAVExecState@1@@Z 97 ?constructFunction@JSC@@YAPAVJSObject@1@PAVExecState@1@ ABVArgList@1@ABVIdentifier@1@ABVUString@1@H@Z96 ?constructFunction@JSC@@YAPAVJSObject@1@PAVExecState@1@PAVJSGlobalObject@1@ABVArgList@1@ABVIdentifier@1@ABVUString@1@H@Z 98 97 ?convertUTF16ToUTF8@Unicode@WTF@@YA?AW4ConversionResult@12@PAPB_WPB_WPAPADPAD_N@Z 99 98 ?convertUTF8ToUTF16@Unicode@WTF@@YA?AW4ConversionResult@12@PAPBDPBDPAPA_WPA_W_N@Z … … 337 336 ?toNumber@JSObject@JSC@@UBENPAVExecState@2@@Z 338 337 ?toNumber@JSString@JSC@@EBENPAVExecState@2@@Z 339 ?toObject@JSCell@JSC@@UBEPAVJSObject@2@PAVExecState@2@@Z 340 ?toObject@JSObject@JSC@@UBEPAV12@PAVExecState@2@@Z 341 ?toObject@JSString@JSC@@EBEPAVJSObject@2@PAVExecState@2@@Z 342 ?toObjectSlowCase@JSValue@JSC@@ABEPAVJSObject@2@PAVExecState@2@@Z 338 ?toObject@JSCell@JSC@@UBEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z 339 ?toObject@JSObject@JSC@@UBEPAV12@PAVExecState@2@PAVJSGlobalObject@2@@Z 340 ?toObjectSlowCase@JSValue@JSC@@ABEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z 343 341 ?toPrimitive@JSCell@JSC@@UBE?AVJSValue@2@PAVExecState@2@W4PreferredPrimitiveType@2@@Z 344 342 ?toPrimitive@JSString@JSC@@EBE?AVJSValue@2@PAVExecState@2@W4PreferredPrimitiveType@2@@Z -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r81411 r82173 249 249 for (SymbolTable::iterator it = symbolTable->begin(); it != end; ++it) 250 250 registerFor(it->second.getIndex()).setIndex(it->second.getIndex() + m_globalVarStorageOffset); 251 251 252 252 BatchedTransitionOptimizer optimizer(*m_globalData, globalObject); 253 253 -
trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp
r79177 r82173 53 53 static inline JSObject* constructArrayWithSizeQuirk(ExecState* exec, const ArgList& args) 54 54 { 55 JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject(); 56 55 57 // a single numeric argument denotes the array size (!) 56 58 if (args.size() == 1 && args.at(0).isNumber()) { … … 58 60 if (n != args.at(0).toNumber(exec)) 59 61 return throwError(exec, createRangeError(exec, "Array size is not a small enough positive integer.")); 60 return new (exec) JSArray( exec->lexicalGlobalObject()->arrayStructure(), n, CreateInitialized);62 return new (exec) JSArray(globalObject->arrayStructure(), n, CreateInitialized); 61 63 } 62 64 63 65 // otherwise the array is constructed with the arguments in it 64 return new (exec) JSArray(exec->globalData(), exec->lexicalGlobalObject()->arrayStructure(), args);66 return new (exec) JSArray(exec->globalData(), globalObject->arrayStructure(), args); 65 67 } 66 68 -
trunk/Source/JavaScriptCore/runtime/BooleanConstructor.cpp
r77269 r82173 41 41 JSObject* constructBoolean(ExecState* exec, const ArgList& args) 42 42 { 43 BooleanObject* obj = new (exec) BooleanObject(exec->globalData(), exec->lexicalGlobalObject()->booleanObjectStructure());43 BooleanObject* obj = new (exec) BooleanObject(exec->globalData(), asInternalFunction(exec->callee())->globalObject()->booleanObjectStructure()); 44 44 obj->setInternalValue(exec->globalData(), jsBoolean(args.at(0).toBoolean(exec))); 45 45 return obj; … … 70 70 } 71 71 72 JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JS Value immediateBooleanValue)72 JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JSGlobalObject* globalObject, JSValue immediateBooleanValue) 73 73 { 74 BooleanObject* obj = new (exec) BooleanObject(exec->globalData(), exec->lexicalGlobalObject()->booleanObjectStructure());74 BooleanObject* obj = new (exec) BooleanObject(exec->globalData(), globalObject->booleanObjectStructure()); 75 75 obj->setInternalValue(exec->globalData(), immediateBooleanValue); 76 76 return obj; -
trunk/Source/JavaScriptCore/runtime/BooleanConstructor.h
r59941 r82173 37 37 }; 38 38 39 JSObject* constructBooleanFromImmediateBoolean(ExecState*, JS Value);39 JSObject* constructBooleanFromImmediateBoolean(ExecState*, JSGlobalObject*, JSValue); 40 40 JSObject* constructBoolean(ExecState*, const ArgList&); 41 41 -
trunk/Source/JavaScriptCore/runtime/DateConstructor.cpp
r79177 r82173 122 122 } 123 123 124 return new (exec) DateInstance(exec, value);124 return new (exec) DateInstance(exec, asInternalFunction(exec->callee())->globalObject()->dateStructure(), value); 125 125 } 126 126 -
trunk/Source/JavaScriptCore/runtime/DateInstance.cpp
r81086 r82173 49 49 } 50 50 51 DateInstance::DateInstance(ExecState* exec, double time)52 : JSWrapperObject(exec->lexicalGlobalObject()->dateStructure())53 {54 ASSERT(inherits(&s_info));55 setInternalValue(exec->globalData(), jsNumber(timeClip(time)));56 }57 58 51 const GregorianDateTime* DateInstance::calculateGregorianDateTime(ExecState* exec) const 59 52 { -
trunk/Source/JavaScriptCore/runtime/DateInstance.h
r81272 r82173 32 32 class DateInstance : public JSWrapperObject { 33 33 public: 34 DateInstance(ExecState*, double);35 34 DateInstance(ExecState*, NonNullPassRefPtr<Structure>, double); 36 35 explicit DateInstance(ExecState*, NonNullPassRefPtr<Structure>); -
trunk/Source/JavaScriptCore/runtime/ErrorConstructor.cpp
r77151 r82173 43 43 { 44 44 JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined(); 45 Structure* errorStructure = exec->lexicalGlobalObject()->errorStructure();45 Structure* errorStructure = asInternalFunction(exec->callee())->globalObject()->errorStructure(); 46 46 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message)); 47 47 } … … 56 56 { 57 57 JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined(); 58 Structure* errorStructure = exec->lexicalGlobalObject()->errorStructure();58 Structure* errorStructure = asInternalFunction(exec->callee())->globalObject()->errorStructure(); 59 59 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message)); 60 60 } -
trunk/Source/JavaScriptCore/runtime/FunctionConstructor.cpp
r80598 r82173 50 50 { 51 51 ArgList args(exec); 52 return JSValue::encode(constructFunction(exec, a rgs));52 return JSValue::encode(constructFunction(exec, asInternalFunction(exec->callee())->globalObject(), args)); 53 53 } 54 54 … … 62 62 { 63 63 ArgList args(exec); 64 return JSValue::encode(constructFunction(exec, a rgs));64 return JSValue::encode(constructFunction(exec, asInternalFunction(exec->callee())->globalObject(), args)); 65 65 } 66 66 … … 73 73 74 74 // ECMA 15.3.2 The Function Constructor 75 JSObject* constructFunction(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber)75 JSObject* constructFunction(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber) 76 76 { 77 77 // Functions need to have a space following the opening { due to for web compatibility … … 97 97 } 98 98 99 JSGlobalObject* globalObject = exec->lexicalGlobalObject();100 99 JSGlobalData& globalData = globalObject->globalData(); 101 100 SourceCode source = makeSource(program, sourceURL, lineNumber); … … 112 111 113 112 // ECMA 15.3.2 The Function Constructor 114 JSObject* constructFunction(ExecState* exec, const ArgList& args)113 JSObject* constructFunction(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args) 115 114 { 116 return constructFunction(exec, args, Identifier(exec, "anonymous"), UString(), 1);115 return constructFunction(exec, globalObject, args, Identifier(exec, "anonymous"), UString(), 1); 117 116 } 118 117 -
trunk/Source/JavaScriptCore/runtime/FunctionConstructor.h
r59941 r82173 37 37 }; 38 38 39 JSObject* constructFunction(ExecState*, const ArgList&, const Identifier& functionName, const UString& sourceURL, int lineNumber);40 JSObject* constructFunction(ExecState*, const ArgList&);39 JSObject* constructFunction(ExecState*, JSGlobalObject*, const ArgList&, const Identifier& functionName, const UString& sourceURL, int lineNumber); 40 JSObject* constructFunction(ExecState*, JSGlobalObject*, const ArgList&); 41 41 42 42 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSCell.cpp
r79132 r82173 120 120 // It should only be called by JSValue::get. 121 121 // It calls getPropertySlot, not getOwnPropertySlot. 122 JSObject* object = toObject(exec );122 JSObject* object = toObject(exec, exec->lexicalGlobalObject()); 123 123 slot.setBase(object); 124 124 if (!object->getPropertySlot(exec, identifier, slot)) … … 132 132 // It should only be called by JSValue::get. 133 133 // It calls getPropertySlot, not getOwnPropertySlot. 134 JSObject* object = toObject(exec );134 JSObject* object = toObject(exec, exec->lexicalGlobalObject()); 135 135 slot.setBase(object); 136 136 if (!object->getPropertySlot(exec, identifier, slot)) … … 141 141 void JSCell::put(ExecState* exec, const Identifier& identifier, JSValue value, PutPropertySlot& slot) 142 142 { 143 toObject(exec )->put(exec, identifier, value, slot);143 toObject(exec, exec->lexicalGlobalObject())->put(exec, identifier, value, slot); 144 144 } 145 145 146 146 void JSCell::put(ExecState* exec, unsigned identifier, JSValue value) 147 147 { 148 toObject(exec )->put(exec, identifier, value);148 toObject(exec, exec->lexicalGlobalObject())->put(exec, identifier, value); 149 149 } 150 150 151 151 bool JSCell::deleteProperty(ExecState* exec, const Identifier& identifier) 152 152 { 153 return toObject(exec )->deleteProperty(exec, identifier);153 return toObject(exec, exec->lexicalGlobalObject())->deleteProperty(exec, identifier); 154 154 } 155 155 156 156 bool JSCell::deleteProperty(ExecState* exec, unsigned identifier) 157 157 { 158 return toObject(exec )->deleteProperty(exec, identifier);158 return toObject(exec, exec->lexicalGlobalObject())->deleteProperty(exec, identifier); 159 159 } 160 160 161 161 JSObject* JSCell::toThisObject(ExecState* exec) const 162 162 { 163 return toObject(exec );163 return toObject(exec, exec->lexicalGlobalObject()); 164 164 } 165 165 … … 204 204 } 205 205 206 JSObject* JSCell::toObject(ExecState* ) const206 JSObject* JSCell::toObject(ExecState*, JSGlobalObject*) const 207 207 { 208 208 ASSERT_NOT_REACHED(); -
trunk/Source/JavaScriptCore/runtime/JSCell.h
r81272 r82173 36 36 namespace JSC { 37 37 38 class JSGlobalObject; 39 38 40 #if COMPILER(MSVC) 39 41 // If WTF_MAKE_NONCOPYABLE is applied to JSCell we end up with a bunch of … … 107 109 virtual double toNumber(ExecState*) const; 108 110 virtual UString toString(ExecState*) const; 109 virtual JSObject* toObject(ExecState* ) const;111 virtual JSObject* toObject(ExecState*, JSGlobalObject*) const; 110 112 111 113 // Garbage collection. … … 337 339 inline JSObject* JSValue::toObject(ExecState* exec) const 338 340 { 339 return isCell() ? asCell()->toObject(exec) : toObjectSlowCase(exec); 341 return isCell() ? asCell()->toObject(exec, exec->lexicalGlobalObject()) : toObjectSlowCase(exec, exec->lexicalGlobalObject()); 342 } 343 344 inline JSObject* JSValue::toObject(ExecState* exec, JSGlobalObject* globalObject) const 345 { 346 return isCell() ? asCell()->toObject(exec, globalObject) : toObjectSlowCase(exec, globalObject); 340 347 } 341 348 -
trunk/Source/JavaScriptCore/runtime/JSNotAnObject.cpp
r72127 r82173 68 68 } 69 69 70 JSObject* JSNotAnObject::toObject(ExecState* exec ) const70 JSObject* JSNotAnObject::toObject(ExecState* exec, JSGlobalObject*) const 71 71 { 72 72 ASSERT_UNUSED(exec, exec->hadException()); -
trunk/Source/JavaScriptCore/runtime/JSNotAnObject.h
r81272 r82173 59 59 virtual double toNumber(ExecState*) const; 60 60 virtual UString toString(ExecState*) const; 61 virtual JSObject* toObject(ExecState* ) const;61 virtual JSObject* toObject(ExecState*, JSGlobalObject*) const; 62 62 63 63 // JSObject methods -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r82003 r82173 490 490 } 491 491 492 JSObject* JSObject::toObject(ExecState* ) const492 JSObject* JSObject::toObject(ExecState*, JSGlobalObject*) const 493 493 { 494 494 return const_cast<JSObject*>(this); -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r81272 r82173 139 139 virtual double toNumber(ExecState*) const; 140 140 virtual UString toString(ExecState*) const; 141 virtual JSObject* toObject(ExecState* ) const;141 virtual JSObject* toObject(ExecState*, JSGlobalObject*) const; 142 142 143 143 virtual JSObject* toThisObject(ExecState*) const; -
trunk/Source/JavaScriptCore/runtime/JSString.cpp
r81071 r82173 254 254 } 255 255 256 inline StringObject* StringObject::create(ExecState* exec, JS String* string)257 { 258 return new (exec) StringObject(exec->globalData(), exec->lexicalGlobalObject()->stringObjectStructure(), string);259 } 260 261 JSObject* JSString::toObject(ExecState* exec ) const262 { 263 return StringObject::create(exec, const_cast<JSString*>(this));256 inline StringObject* StringObject::create(ExecState* exec, JSGlobalObject* globalObject, JSString* string) 257 { 258 return new (exec) StringObject(exec->globalData(), globalObject->stringObjectStructure(), string); 259 } 260 261 JSObject* JSString::toObject(ExecState* exec, JSGlobalObject* globalObject) const 262 { 263 return StringObject::create(exec, globalObject, const_cast<JSString*>(this)); 264 264 } 265 265 266 266 JSObject* JSString::toThisObject(ExecState* exec) const 267 267 { 268 return StringObject::create(exec, const_cast<JSString*>(this));268 return StringObject::create(exec, exec->lexicalGlobalObject(), const_cast<JSString*>(this)); 269 269 } 270 270 -
trunk/Source/JavaScriptCore/runtime/JSString.h
r81272 r82173 403 403 virtual bool toBoolean(ExecState*) const; 404 404 virtual double toNumber(ExecState*) const; 405 virtual JSObject* toObject(ExecState* ) const;405 virtual JSObject* toObject(ExecState*, JSGlobalObject*) const; 406 406 virtual UString toString(ExecState*) const; 407 407 -
trunk/Source/JavaScriptCore/runtime/JSValue.cpp
r72127 r82173 55 55 } 56 56 57 JSObject* JSValue::toObjectSlowCase(ExecState* exec ) const57 JSObject* JSValue::toObjectSlowCase(ExecState* exec, JSGlobalObject* globalObject) const 58 58 { 59 59 ASSERT(!isCell()); 60 60 61 61 if (isInt32() || isDouble()) 62 return constructNumber(exec, asValue());62 return constructNumber(exec, globalObject, asValue()); 63 63 if (isTrue() || isFalse()) 64 return constructBooleanFromImmediateBoolean(exec, asValue());64 return constructBooleanFromImmediateBoolean(exec, globalObject, asValue()); 65 65 66 66 ASSERT(isUndefinedOrNull()); … … 74 74 75 75 if (isInt32() || isDouble()) 76 return constructNumber(exec, asValue());76 return constructNumber(exec, exec->lexicalGlobalObject(), asValue()); 77 77 if (isTrue() || isFalse()) 78 return constructBooleanFromImmediateBoolean(exec, asValue());78 return constructBooleanFromImmediateBoolean(exec, exec->lexicalGlobalObject(), asValue()); 79 79 ASSERT(isUndefinedOrNull()); 80 80 return exec->globalThisValue(); … … 85 85 ASSERT(!isCell()); 86 86 if (isNumber()) 87 return constructNumber(exec, asValue());87 return constructNumber(exec, exec->lexicalGlobalObject(), asValue()); 88 88 if (isBoolean()) 89 return constructBooleanFromImmediateBoolean(exec, asValue());89 return constructBooleanFromImmediateBoolean(exec, exec->lexicalGlobalObject(), asValue()); 90 90 91 91 ASSERT(isUndefinedOrNull()); -
trunk/Source/JavaScriptCore/runtime/JSValue.h
r81040 r82173 38 38 class JSCell; 39 39 class JSGlobalData; 40 class JSGlobalObject; 40 41 class JSImmediate; 41 42 class JSObject; … … 190 191 UString toPrimitiveString(ExecState*) const; 191 192 JSObject* toObject(ExecState*) const; 193 JSObject* toObject(ExecState*, JSGlobalObject*) const; 192 194 193 195 // Integer conversions. … … 245 247 246 248 inline const JSValue asValue() const { return *this; } 247 JSObject* toObjectSlowCase(ExecState* ) const;249 JSObject* toObjectSlowCase(ExecState*, JSGlobalObject*) const; 248 250 JSObject* toThisObjectSlowCase(ExecState*) const; 249 251 -
trunk/Source/JavaScriptCore/runtime/NumberConstructor.cpp
r79240 r82173 105 105 static EncodedJSValue JSC_HOST_CALL constructWithNumberConstructor(ExecState* exec) 106 106 { 107 NumberObject* object = new (exec) NumberObject(exec->globalData(), exec->lexicalGlobalObject()->numberObjectStructure());107 NumberObject* object = new (exec) NumberObject(exec->globalData(), asInternalFunction(exec->callee())->globalObject()->numberObjectStructure()); 108 108 double n = exec->argumentCount() ? exec->argument(0).toNumber(exec) : 0; 109 109 object->setInternalValue(exec->globalData(), jsNumber(n)); -
trunk/Source/JavaScriptCore/runtime/NumberObject.cpp
r81086 r82173 43 43 } 44 44 45 NumberObject* constructNumber(ExecState* exec, JS Value number)45 NumberObject* constructNumber(ExecState* exec, JSGlobalObject* globalObject, JSValue number) 46 46 { 47 NumberObject* object = new (exec) NumberObject(exec->globalData(), exec->lexicalGlobalObject()->numberObjectStructure());47 NumberObject* object = new (exec) NumberObject(exec->globalData(), globalObject->numberObjectStructure()); 48 48 object->setInternalValue(exec->globalData(), number); 49 49 return object; -
trunk/Source/JavaScriptCore/runtime/NumberObject.h
r81272 r82173 41 41 }; 42 42 43 NumberObject* constructNumber(ExecState*, JS Value);43 NumberObject* constructNumber(ExecState*, JSGlobalObject*, JSValue); 44 44 45 45 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp
r80378 r82173 96 96 97 97 // ECMA 15.2.2 98 static ALWAYS_INLINE JSObject* constructObject(ExecState* exec, const ArgList& args)98 static ALWAYS_INLINE JSObject* constructObject(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args) 99 99 { 100 100 JSValue arg = args.at(0); 101 101 if (arg.isUndefinedOrNull()) 102 return constructEmptyObject(exec );103 return arg.toObject(exec );102 return constructEmptyObject(exec, globalObject); 103 return arg.toObject(exec, globalObject); 104 104 } 105 105 … … 107 107 { 108 108 ArgList args(exec); 109 return JSValue::encode(constructObject(exec, a rgs));109 return JSValue::encode(constructObject(exec, asInternalFunction(exec->callee())->globalObject(), args)); 110 110 } 111 111 … … 119 119 { 120 120 ArgList args(exec); 121 return JSValue::encode(constructObject(exec, a rgs));121 return JSValue::encode(constructObject(exec, asInternalFunction(exec->callee())->globalObject(), args)); 122 122 } 123 123 -
trunk/Source/JavaScriptCore/runtime/RegExpConstructor.cpp
r80667 r82173 294 294 295 295 // ECMA 15.10.4 296 JSObject* constructRegExp(ExecState* exec, const ArgList& args)296 JSObject* constructRegExp(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args) 297 297 { 298 298 JSValue arg0 = args.at(0); … … 321 321 if (!regExp->isValid()) 322 322 return throwError(exec, createSyntaxError(exec, regExp->errorMessage())); 323 return new (exec) RegExpObject(exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regExp.release());323 return new (exec) RegExpObject(exec->lexicalGlobalObject(), globalObject->regExpStructure(), regExp.release()); 324 324 } 325 325 … … 327 327 { 328 328 ArgList args(exec); 329 return JSValue::encode(constructRegExp(exec, a rgs));329 return JSValue::encode(constructRegExp(exec, asInternalFunction(exec->callee())->globalObject(), args)); 330 330 } 331 331 … … 340 340 { 341 341 ArgList args(exec); 342 return JSValue::encode(constructRegExp(exec, a rgs));342 return JSValue::encode(constructRegExp(exec, asInternalFunction(exec->callee())->globalObject(), args)); 343 343 } 344 344 -
trunk/Source/JavaScriptCore/runtime/RegExpConstructor.h
r81272 r82173 97 97 RegExpConstructor* asRegExpConstructor(JSValue); 98 98 99 JSObject* constructRegExp(ExecState*, const ArgList&);99 JSObject* constructRegExp(ExecState*, JSGlobalObject*, const ArgList&); 100 100 101 101 inline RegExpConstructor* asRegExpConstructor(JSValue value) -
trunk/Source/JavaScriptCore/runtime/StringConstructor.cpp
r79177 r82173 68 68 static EncodedJSValue JSC_HOST_CALL constructWithStringConstructor(ExecState* exec) 69 69 { 70 JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject(); 70 71 if (!exec->argumentCount()) 71 return JSValue::encode(new (exec) StringObject(exec, exec->lexicalGlobalObject()->stringObjectStructure()));72 return JSValue::encode(new (exec) StringObject(exec, exec->lexicalGlobalObject()->stringObjectStructure(), exec->argument(0).toString(exec)));72 return JSValue::encode(new (exec) StringObject(exec, globalObject->stringObjectStructure())); 73 return JSValue::encode(new (exec) StringObject(exec, globalObject->stringObjectStructure(), exec->argument(0).toString(exec))); 73 74 } 74 75 -
trunk/Source/JavaScriptCore/runtime/StringObject.h
r81272 r82173 32 32 StringObject(ExecState*, NonNullPassRefPtr<Structure>, const UString&); 33 33 34 static StringObject* create(ExecState*, JS String*);34 static StringObject* create(ExecState*, JSGlobalObject*, JSString*); 35 35 36 36 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); -
trunk/Source/JavaScriptGlue/ChangeLog
r82037 r82173 1 2011-03-25 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 instanceof Array test fails when using iframes 6 https://bugs.webkit.org/show_bug.cgi?id=17250 7 8 Up date for new toObject api 9 10 * UserObjectImp.cpp: 11 (UserObjectImp::toPrimitive): 12 (UserObjectImp::toBoolean): 13 (UserObjectImp::toNumber): 14 (UserObjectImp::toString): 15 1 16 2011-03-26 Adam Barth <abarth@webkit.org> 2 17 -
trunk/Source/JavaScriptGlue/UserObjectImp.cpp
r79132 r82173 168 168 { 169 169 JSValue result = jsUndefined(); 170 JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec ), exec);170 JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec, exec->lexicalGlobalObject()), exec); 171 171 CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0; 172 172 if (cfValue) { … … 205 205 { 206 206 bool result = false; 207 JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec ), exec);207 JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec, exec->lexicalGlobalObject()), exec); 208 208 CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0; 209 209 if (cfValue) … … 285 285 { 286 286 double result = 0; 287 JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec ), exec);287 JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec, exec->lexicalGlobalObject()), exec); 288 288 CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0; 289 289 if (cfValue) … … 319 319 { 320 320 UString result; 321 JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec ), exec);321 JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec, exec->lexicalGlobalObject()), exec); 322 322 CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0; 323 323 if (cfValue) -
trunk/Source/WebCore/ChangeLog
r82171 r82173 1 2011-03-28 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 instanceof Array test fails when using iframes 6 https://bugs.webkit.org/show_bug.cgi?id=17250 7 8 Update for new function and date apis 9 10 Test: fast/js/js-constructors-use-correct-global.html 11 12 * WebCore.xcodeproj/project.pbxproj: 13 * bindings/js/JSDOMBinding.cpp: 14 (WebCore::jsDateOrNull): 15 * bindings/js/JSLazyEventListener.cpp: 16 (WebCore::JSLazyEventListener::initializeJSFunction): 17 1 18 2011-03-28 Beth Dakin <bdakin@apple.com> 2 19 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp
r79616 r82173 484 484 if (!isfinite(value)) 485 485 return jsNull(); 486 return new (exec) DateInstance(exec, value);486 return new (exec) DateInstance(exec, exec->lexicalGlobalObject()->dateStructure(), value); 487 487 } 488 488 -
trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp
r82147 r82173 98 98 args.append(jsString(exec, m_code)); 99 99 100 JSObject* jsFunction = constructFunction(exec, args, Identifier(exec, stringToUString(m_functionName)), stringToUString(m_sourceURL), m_lineNumber); // FIXME: is globalExec ok?100 JSObject* jsFunction = constructFunction(exec, exec->lexicalGlobalObject(), args, Identifier(exec, stringToUString(m_functionName)), stringToUString(m_sourceURL), m_lineNumber); // FIXME: is globalExec ok? 101 101 if (exec->hadException()) { 102 102 exec->clearException(); -
trunk/Source/WebCore/bridge/qt/qt_runtime.cpp
r81272 r82173 884 884 double ms = gregorianDateTimeToMS(exec, dt, time.msec(), /*inputIsUTC*/ false); 885 885 886 return new (exec) DateInstance(exec, trunc(ms));886 return new (exec) DateInstance(exec, exec->lexicalGlobalObject()->dateStructure(), trunc(ms)); 887 887 } 888 888
Note: See TracChangeset
for help on using the changeset viewer.