Changeset 95666 in webkit
- Timestamp:
- Sep 21, 2011 12:59:39 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r95663 r95666 1 2011-09-21 Gavin Barraclough <barraclough@apple.com> 2 3 Replace jsFunctionVPtr compares with a type check on the Structure. 4 https://bugs.webkit.org/show_bug.cgi?id=68557 5 6 Reviewed by Oliver Hunt. 7 8 This will permit calls to still optimize to subclasses of JSFunction 9 that have the correct type (but a different C++ vptr). 10 11 This patch stops passing the globalData into numerous functions. 12 13 * dfg/DFGByteCodeParser.cpp: 14 (JSC::DFG::ByteCodeParser::parseBlock): 15 * dfg/DFGGraph.h: 16 (JSC::DFG::Graph::isFunctionConstant): 17 (JSC::DFG::Graph::valueOfFunctionConstant): 18 * dfg/DFGJITCompiler.h: 19 (JSC::DFG::JITCompiler::isFunctionConstant): 20 (JSC::DFG::JITCompiler::valueOfFunctionConstant): 21 * dfg/DFGOperations.cpp: 22 * interpreter/Interpreter.cpp: 23 (JSC::Interpreter::privateExecute): 24 * jit/JIT.h: 25 * jit/JITCall.cpp: 26 (JSC::JIT::compileOpCallVarargs): 27 (JSC::JIT::compileOpCallSlowCase): 28 * jit/JITCall32_64.cpp: 29 (JSC::JIT::compileOpCallVarargs): 30 (JSC::JIT::compileOpCallSlowCase): 31 * jit/JITInlineMethods.h: 32 (JSC::JIT::emitJumpIfNotType): 33 * jit/JITStubs.cpp: 34 (JSC::DEFINE_STUB_FUNCTION): 35 * runtime/Executable.h: 36 (JSC::isHostFunction): 37 * runtime/JSFunction.h: 38 (JSC::JSFunction::createStructure): 39 * runtime/JSObject.cpp: 40 (JSC::JSObject::put): 41 (JSC::JSObject::putWithAttributes): 42 * runtime/JSObject.h: 43 (JSC::getJSFunction): 44 (JSC::JSObject::putDirect): 45 (JSC::JSObject::putDirectWithoutTransition): 46 * runtime/JSType.h: 47 1 48 2011-09-21 Geoffrey Garen <ggaren@apple.com> 2 49 -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r95594 r95666 1306 1306 case op_call: { 1307 1307 NodeIndex callTarget = get(currentInstruction[1].u.operand); 1308 if (m_graph.isFunctionConstant(m_codeBlock, *m_globalData,callTarget)) {1308 if (m_graph.isFunctionConstant(m_codeBlock, callTarget)) { 1309 1309 int argCount = currentInstruction[2].u.operand; 1310 1310 int registerOffset = currentInstruction[3].u.operand; … … 1321 1321 } 1322 1322 1323 DFG::Intrinsic intrinsic = m_graph.valueOfFunctionConstant(m_codeBlock, *m_globalData,callTarget)->executable()->intrinsic();1323 DFG::Intrinsic intrinsic = m_graph.valueOfFunctionConstant(m_codeBlock, callTarget)->executable()->intrinsic(); 1324 1324 1325 1325 if (handleIntrinsic(usesResult, resultOperand, intrinsic, firstArg, lastArg)) { -
trunk/Source/JavaScriptCore/dfg/DFGGraph.h
r95523 r95666 272 272 return at(nodeIndex).isBooleanConstant(codeBlock); 273 273 } 274 bool isFunctionConstant(CodeBlock* codeBlock, JSGlobalData& globalData,NodeIndex nodeIndex)274 bool isFunctionConstant(CodeBlock* codeBlock, NodeIndex nodeIndex) 275 275 { 276 276 if (!isJSConstant(nodeIndex)) 277 277 return false; 278 if (!getJSFunction( globalData,valueOfJSConstant(codeBlock, nodeIndex)))278 if (!getJSFunction(valueOfJSConstant(codeBlock, nodeIndex))) 279 279 return false; 280 280 return true; … … 299 299 return valueOfJSConstantNode(codeBlock, nodeIndex).getBoolean(); 300 300 } 301 JSFunction* valueOfFunctionConstant(CodeBlock* codeBlock, JSGlobalData& globalData,NodeIndex nodeIndex)302 { 303 JSCell* function = getJSFunction( globalData,valueOfJSConstant(codeBlock, nodeIndex));301 JSFunction* valueOfFunctionConstant(CodeBlock* codeBlock, NodeIndex nodeIndex) 302 { 303 JSCell* function = getJSFunction(valueOfJSConstant(codeBlock, nodeIndex)); 304 304 ASSERT(function); 305 305 return asFunction(function); -
trunk/Source/JavaScriptCore/dfg/DFGJITCompiler.h
r95326 r95666 252 252 bool isNumberConstant(NodeIndex nodeIndex) { return graph().isNumberConstant(codeBlock(), nodeIndex); } 253 253 bool isBooleanConstant(NodeIndex nodeIndex) { return graph().isBooleanConstant(codeBlock(), nodeIndex); } 254 bool isFunctionConstant(NodeIndex nodeIndex) { return graph().isFunctionConstant(codeBlock(), *globalData(),nodeIndex); }254 bool isFunctionConstant(NodeIndex nodeIndex) { return graph().isFunctionConstant(codeBlock(), nodeIndex); } 255 255 // Helper methods get constant values from nodes. 256 256 JSValue valueOfJSConstant(NodeIndex nodeIndex) { return graph().valueOfJSConstant(codeBlock(), nodeIndex); } … … 258 258 double valueOfNumberConstant(NodeIndex nodeIndex) { return graph().valueOfNumberConstant(codeBlock(), nodeIndex); } 259 259 bool valueOfBooleanConstant(NodeIndex nodeIndex) { return graph().valueOfBooleanConstant(codeBlock(), nodeIndex); } 260 JSFunction* valueOfFunctionConstant(NodeIndex nodeIndex) { return graph().valueOfFunctionConstant(codeBlock(), *globalData(),nodeIndex); }260 JSFunction* valueOfFunctionConstant(NodeIndex nodeIndex) { return graph().valueOfFunctionConstant(codeBlock(), nodeIndex); } 261 261 262 262 // These methods JIT generate dynamic, debug-only checks - akin to ASSERTs. -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r95340 r95666 520 520 JSGlobalData* globalData = &exec->globalData(); 521 521 JSValue calleeAsValue = execCallee->calleeAsValue(); 522 JSCell* calleeAsFunctionCell = getJSFunction( *globalData,calleeAsValue);522 JSCell* calleeAsFunctionCell = getJSFunction(calleeAsValue); 523 523 if (!calleeAsFunctionCell) 524 524 return handleHostCall(execCallee, calleeAsValue, kind); … … 569 569 { 570 570 ExecState* exec = execCallee->callerFrame(); 571 JSGlobalData* globalData = &exec->globalData();572 571 JSValue calleeAsValue = execCallee->calleeAsValue(); 573 JSCell* calleeAsFunctionCell = getJSFunction( *globalData,calleeAsValue);572 JSCell* calleeAsFunctionCell = getJSFunction(calleeAsValue); 574 573 if (UNLIKELY(!calleeAsFunctionCell)) 575 574 return handleHostCall(execCallee, calleeAsValue, kind); -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r95139 r95666 4170 4170 JSValue funcVal = callFrame->r(func).jsValue(); 4171 4171 4172 if (isHostFunction( callFrame->globalData(),funcVal, globalFuncEval)) {4172 if (isHostFunction(funcVal, globalFuncEval)) { 4173 4173 Register* newCallFrame = callFrame->registers() + registerOffset; 4174 4174 Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount; -
trunk/Source/JavaScriptCore/jit/JIT.h
r95484 r95666 313 313 void emitLoadInt32ToDouble(unsigned index, FPRegisterID value); 314 314 Jump emitJumpIfNotObject(RegisterID structureReg); 315 Jump emitJumpIfNotType(RegisterID baseReg, RegisterID scratchReg, JSType); 315 316 316 317 void testPrototype(JSValue, JumpList& failureCases); -
trunk/Source/JavaScriptCore/jit/JITCall.cpp
r93466 r95666 76 76 // Check for JSFunctions. 77 77 emitJumpSlowCaseIfNotJSCell(regT0); 78 addSlowCase( branchPtr(NotEqual, Address(regT0), TrustedImmPtr(m_globalData->jsFunctionVPtr)));78 addSlowCase(emitJumpIfNotType(regT0, regT3, JSFunctionType)); 79 79 80 80 // Speculatively roll the callframe, assuming argCount will match the arity. … … 172 172 // Fast check for JS function. 173 173 Jump callLinkFailNotObject = emitJumpIfNotJSCell(regT0); 174 Jump callLinkFailNotJSFunction = branchPtr(NotEqual, Address(regT0), TrustedImmPtr(m_globalData->jsFunctionVPtr));174 Jump callLinkFailNotJSFunction = emitJumpIfNotType(regT0, regT3, JSFunctionType); 175 175 176 176 // Speculatively roll the callframe, assuming argCount will match the arity. -
trunk/Source/JavaScriptCore/jit/JITCall32_64.cpp
r94688 r95666 73 73 74 74 emitJumpSlowCaseIfNotJSCell(callee, regT1); 75 addSlowCase( branchPtr(NotEqual, Address(regT0), TrustedImmPtr(m_globalData->jsFunctionVPtr)));75 addSlowCase(emitJumpIfNotType(regT0, regT1, JSFunctionType)); 76 76 77 77 // Speculatively roll the callframe, assuming argCount will match the arity. … … 257 257 // Fast check for JS function. 258 258 Jump callLinkFailNotObject = branch32(NotEqual, regT1, TrustedImm32(JSValue::CellTag)); 259 Jump callLinkFailNotJSFunction = branchPtr(NotEqual, Address(regT0), TrustedImmPtr(m_globalData->jsFunctionVPtr));259 Jump callLinkFailNotJSFunction = emitJumpIfNotType(regT0, regT1, JSFunctionType); 260 260 261 261 // Speculatively roll the callframe, assuming argCount will match the arity. -
trunk/Source/JavaScriptCore/jit/JITInlineMethods.h
r95559 r95666 327 327 } 328 328 329 ALWAYS_INLINE JIT::Jump JIT::emitJumpIfNotType(RegisterID baseReg, RegisterID scratchReg, JSType type) 330 { 331 loadPtr(Address(baseReg, JSCell::structureOffset()), scratchReg); 332 return branch8(NotEqual, Address(scratchReg, Structure::typeInfoTypeOffset()), TrustedImm32(type)); 333 } 334 329 335 #if ENABLE(SAMPLING_FLAGS) 330 336 ALWAYS_INLINE void JIT::setSamplingFlag(int32_t flag) -
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r95399 r95666 3390 3390 int argCount = stackFrame.args[2].int32(); 3391 3391 3392 if (!isHostFunction( callFrame->globalData(),funcVal, globalFuncEval))3392 if (!isHostFunction(funcVal, globalFuncEval)) 3393 3393 return JSValue::encode(JSValue()); 3394 3394 -
trunk/Source/JavaScriptCore/runtime/Executable.h
r95313 r95666 621 621 } 622 622 623 inline bool isHostFunction(JS GlobalData& globalData, JSValue value, NativeFunction nativeFunction)623 inline bool isHostFunction(JSValue value, NativeFunction nativeFunction) 624 624 { 625 JSFunction* function = static_cast<JSFunction*>(getJSFunction( globalData,value));625 JSFunction* function = static_cast<JSFunction*>(getJSFunction(value)); 626 626 if (!function || !function->isHostFunction()) 627 627 return false; -
trunk/Source/JavaScriptCore/runtime/JSFunction.h
r95205 r95666 120 120 { 121 121 ASSERT(globalObject); 122 return Structure::create(globalData, globalObject, prototype, TypeInfo( ObjectType, StructureFlags), &s_info);122 return Structure::create(globalData, globalObject, prototype, TypeInfo(JSFunctionType, StructureFlags), &s_info); 123 123 } 124 124 -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r95503 r95666 129 129 prototype = obj->prototype(); 130 130 if (prototype.isNull()) { 131 if (!putDirectInternal(globalData, propertyName, value, 0, true, slot, getJSFunction( globalData,value)) && slot.isStrictMode())131 if (!putDirectInternal(globalData, propertyName, value, 0, true, slot, getJSFunction(value)) && slot.isStrictMode()) 132 132 throwTypeError(exec, StrictModeReadonlyPropertyWriteError); 133 133 return; … … 172 172 } 173 173 174 if (!putDirectInternal(globalData, propertyName, value, 0, true, slot, getJSFunction( globalData,value)) && slot.isStrictMode())174 if (!putDirectInternal(globalData, propertyName, value, 0, true, slot, getJSFunction(value)) && slot.isStrictMode()) 175 175 throwTypeError(exec, StrictModeReadonlyPropertyWriteError); 176 176 return; … … 185 185 void JSObject::putWithAttributes(JSGlobalData* globalData, const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot) 186 186 { 187 putDirectInternal(*globalData, propertyName, value, attributes, checkReadOnly, slot, getJSFunction( *globalData,value));187 putDirectInternal(*globalData, propertyName, value, attributes, checkReadOnly, slot, getJSFunction(value)); 188 188 } 189 189 … … 191 191 { 192 192 PutPropertySlot slot; 193 putDirectInternal(*globalData, propertyName, value, attributes, true, slot, getJSFunction( *globalData,value));193 putDirectInternal(*globalData, propertyName, value, attributes, true, slot, getJSFunction(value)); 194 194 } 195 195 … … 202 202 { 203 203 JSGlobalData& globalData = exec->globalData(); 204 putDirectInternal(globalData, propertyName, value, attributes, checkReadOnly, slot, getJSFunction( globalData,value));204 putDirectInternal(globalData, propertyName, value, attributes, checkReadOnly, slot, getJSFunction(value)); 205 205 } 206 206 … … 209 209 PutPropertySlot slot; 210 210 JSGlobalData& globalData = exec->globalData(); 211 putDirectInternal(globalData, propertyName, value, attributes, true, slot, getJSFunction( globalData,value));211 putDirectInternal(globalData, propertyName, value, attributes, true, slot, getJSFunction(value)); 212 212 } 213 213 -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r95516 r95666 40 40 namespace JSC { 41 41 42 inline JSCell* getJSFunction(JS GlobalData& globalData, JSValue value)42 inline JSCell* getJSFunction(JSValue value) 43 43 { 44 if (value.isCell() && (value.asCell()-> vptr() == globalData.jsFunctionVPtr))44 if (value.isCell() && (value.asCell()->structure()->typeInfo().type() == JSFunctionType)) 45 45 return value.asCell(); 46 46 return 0; … … 703 703 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); 704 704 705 return putDirectInternal(globalData, propertyName, value, attributes, checkReadOnly, slot, getJSFunction( globalData,value));705 return putDirectInternal(globalData, propertyName, value, attributes, checkReadOnly, slot, getJSFunction(value)); 706 706 } 707 707 … … 709 709 { 710 710 PutPropertySlot slot; 711 putDirectInternal(globalData, propertyName, value, attributes, false, slot, getJSFunction( globalData,value));711 putDirectInternal(globalData, propertyName, value, attributes, false, slot, getJSFunction(value)); 712 712 } 713 713 714 714 inline bool JSObject::putDirect(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) 715 715 { 716 return putDirectInternal(globalData, propertyName, value, 0, false, slot, getJSFunction( globalData,value));716 return putDirectInternal(globalData, propertyName, value, 0, false, slot, getJSFunction(value)); 717 717 } 718 718 … … 720 720 { 721 721 size_t currentCapacity = structure()->propertyStorageCapacity(); 722 size_t offset = structure()->addPropertyWithoutTransition(globalData, propertyName, attributes, getJSFunction( globalData,value));722 size_t offset = structure()->addPropertyWithoutTransition(globalData, propertyName, attributes, getJSFunction(value)); 723 723 if (currentCapacity != structure()->propertyStorageCapacity()) 724 724 allocatePropertyStorage(globalData, currentCapacity, structure()->propertyStorageCapacity()); -
trunk/Source/JavaScriptCore/runtime/JSType.h
r95358 r95666 41 41 ObjectType = 10, 42 42 FinalObjectType = 11, 43 JSFunctionType = 12, 43 44 }; 44 45
Note: See TracChangeset
for help on using the changeset viewer.