Changeset 38148 in webkit for trunk/JavaScriptCore
- Timestamp:
- Nov 5, 2008, 7:26:30 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r38146 r38148 1 2008-11-05 Gavin Barraclough <[email protected]> 2 3 Reviewed by Maciej Stachowiak. 4 5 https://bugs.webkit.org/show_bug.cgi?id=22094 6 7 Fix for bug where the callee incorrectly recieves the caller's lexical 8 global object as this, rather than its own. Implementation closely 9 follows the spec, passing jsNull, checking in the callee and replacing 10 with the global object where necessary. 11 12 * VM/CTI.cpp: 13 (JSC::CTI::compileOpCall): 14 * VM/Machine.cpp: 15 (JSC::Machine::cti_op_call_NotJSFunction): 16 (JSC::Machine::cti_op_call_eval): 17 * runtime/JSCell.h: 18 (JSC::JSValue::toThisObject): 19 * runtime/JSImmediate.cpp: 20 (JSC::JSImmediate::toThisObject): 21 * runtime/JSImmediate.h: 22 1 23 2008-11-05 Kevin Ollivier <[email protected]> 2 24 -
trunk/JavaScriptCore/VM/CTI.cpp
r38012 r38148 629 629 if (opcodeID != op_construct) { 630 630 int thisVal = instruction[3].u.operand; 631 if (thisVal == missingThisObjectMarker()) { 632 // FIXME: should this be loaded dynamically off m_callFrame? 633 m_jit.movl_i32m(asInteger(m_callFrame->globalThisValue()), firstArg * sizeof(Register), X86::edi); 634 } else { 631 if (thisVal == missingThisObjectMarker()) 632 m_jit.movl_i32m(asInteger(jsNull()), firstArg * sizeof(Register), X86::edi); 633 else { 635 634 emitGetArg(thisVal, X86::eax); 636 635 emitPutResult(firstArg); -
trunk/JavaScriptCore/VM/Machine.cpp
r38137 r38148 4819 4819 { 4820 4820 SamplingTool::HostCallRecord callRecord(CTI_SAMPLER); 4821 returnValue = callData.native.function(callFrame, asObject(funcVal), argv[0].jsValue(callFrame), argList); 4821 4822 // All host methods should be calling toThisObject, but this is not presently the case. 4823 JSValue* thisValue = argv[0].jsValue(callFrame); 4824 if (thisValue == jsNull()) 4825 thisValue = callFrame->globalThisValue(); 4826 4827 returnValue = callData.native.function(callFrame, asObject(funcVal), thisValue, argList); 4822 4828 } 4823 4829 ARG_setCallFrame(previousCallFrame); … … 5645 5651 5646 5652 if (baseVal == scopeChain->globalObject() && funcVal == scopeChain->globalObject()->evalFunction()) { 5647 JSObject* thisObject = asObject(callFrame[codeBlock->thisRegister].jsValue(callFrame));5653 JSObject* thisObject = callFrame[codeBlock->thisRegister].jsValue(callFrame)->toThisObject(callFrame); 5648 5654 JSValue* exceptionValue = noValue(); 5649 5655 JSValue* result = machine->callEval(callFrame, thisObject, scopeChain, registerFile, registerOffset - RegisterFile::CallFrameHeaderSize - argCount, argCount, exceptionValue); -
trunk/JavaScriptCore/runtime/JSCell.h
r38137 r38148 285 285 { 286 286 if (UNLIKELY(JSImmediate::isImmediate(asValue()))) 287 return JSImmediate::to Object(asValue(), exec);287 return JSImmediate::toThisObject(asValue(), exec); 288 288 return asCell()->toThisObject(exec); 289 289 } -
trunk/JavaScriptCore/runtime/JSImmediate.cpp
r37938 r38148 32 32 33 33 namespace JSC { 34 35 JSObject* JSImmediate::toThisObject(JSValue* v, ExecState* exec) 36 { 37 ASSERT(isImmediate(v)); 38 if (isNumber(v)) 39 return constructNumberFromImmediateNumber(exec, v); 40 if (isBoolean(v)) 41 return constructBooleanFromImmediateBoolean(exec, v); 42 if (v == jsNull()) 43 return exec->globalThisValue(); 44 45 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v->isNull()); 46 exec->setException(exception); 47 return new (exec) JSNotAnObject(exec, exception); 48 } 34 49 35 50 JSObject* JSImmediate::toObject(JSValue* v, ExecState* exec) -
trunk/JavaScriptCore/runtime/JSImmediate.h
r37938 r38148 234 234 static bool toBoolean(JSValue*); 235 235 static JSObject* toObject(JSValue*, ExecState*); 236 static JSObject* toThisObject(JSValue*, ExecState*); 236 237 static UString toString(JSValue*); 237 238
Note:
See TracChangeset
for help on using the changeset viewer.