Changeset 59339 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- May 12, 2010, 9:01:56 PM (15 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/Arguments.h
r54022 r59339 221 221 ASSERT(!d()->registerArray); 222 222 223 size_t numParametersMinusThis = d()->functionExecutable-> generatedBytecode().m_numParameters - 1;224 size_t numVars = d()->functionExecutable-> generatedBytecode().m_numVars;223 size_t numParametersMinusThis = d()->functionExecutable->parameterCount(); 224 size_t numVars = d()->functionExecutable->variableCount(); 225 225 size_t numLocals = numVars + numParametersMinusThis; 226 226 -
trunk/JavaScriptCore/runtime/ArrayPrototype.cpp
r58824 r59339 77 77 // If the JIT is enabled then we need to preserve the invariant that every 78 78 // function with a CodeBlock also has JIT code. 79 callData.js.functionExecutable->jitCode (exec, callData.js.scopeChain);80 CodeBlock& codeBlock = callData.js.functionExecutable->generatedBytecode ();79 callData.js.functionExecutable->jitCodeForCall(exec, callData.js.scopeChain); 80 CodeBlock& codeBlock = callData.js.functionExecutable->generatedBytecodeForCall(); 81 81 #else 82 CodeBlock& codeBlock = callData.js.functionExecutable->bytecode (exec, callData.js.scopeChain);82 CodeBlock& codeBlock = callData.js.functionExecutable->bytecodeForCall(exec, callData.js.scopeChain); 83 83 #endif 84 84 -
trunk/JavaScriptCore/runtime/Executable.cpp
r54571 r59339 58 58 FunctionExecutable::~FunctionExecutable() 59 59 { 60 delete m_codeBlock; 60 delete m_codeBlockForCall; 61 delete m_codeBlockForConstruct; 61 62 } 62 63 … … 113 114 } 114 115 115 void FunctionExecutable::compile (ExecState*, ScopeChainNode* scopeChainNode)116 void FunctionExecutable::compileForCall(ExecState*, ScopeChainNode* scopeChainNode) 116 117 { 117 118 JSGlobalData* globalData = scopeChainNode->globalData; … … 125 126 JSGlobalObject* globalObject = scopeChain.globalObject(); 126 127 127 ASSERT(!m_codeBlock); 128 m_codeBlock = new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset()); 129 OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlock->symbolTable(), m_codeBlock)); 130 generator->generate(); 131 m_numParameters = m_codeBlock->m_numParameters; 132 ASSERT(m_numParameters); 133 m_numVariables = m_codeBlock->m_numVars; 128 ASSERT(!m_codeBlockForCall); 129 m_codeBlockForCall = new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset(), false); 130 OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlockForCall->symbolTable(), m_codeBlockForCall)); 131 generator->generate(); 132 m_numParametersForCall = m_codeBlockForCall->m_numParameters; 133 ASSERT(m_numParametersForCall); 134 m_numVariables = m_codeBlockForCall->m_numVars; 135 m_symbolTable = m_codeBlockForCall->sharedSymbolTable(); 134 136 135 137 body->destroyData(); 136 138 } 137 139 140 void FunctionExecutable::compileForConstruct(ExecState*, ScopeChainNode* scopeChainNode) 141 { 142 JSGlobalData* globalData = scopeChainNode->globalData; 143 RefPtr<FunctionBodyNode> body = globalData->parser->parse<FunctionBodyNode>(globalData, 0, 0, m_source); 144 if (m_forceUsesArguments) 145 body->setUsesArguments(); 146 body->finishParsing(m_parameters, m_name); 147 recordParse(body->features(), body->lineNo(), body->lastLine()); 148 149 ScopeChain scopeChain(scopeChainNode); 150 JSGlobalObject* globalObject = scopeChain.globalObject(); 151 152 ASSERT(!m_codeBlockForConstruct); 153 m_codeBlockForConstruct = new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset(), true); 154 OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlockForConstruct->symbolTable(), m_codeBlockForConstruct)); 155 generator->generate(); 156 m_numParametersForConstruct = m_codeBlockForConstruct->m_numParameters; 157 ASSERT(m_numParametersForConstruct); 158 m_numVariables = m_codeBlockForConstruct->m_numVars; 159 m_symbolTable = m_codeBlockForConstruct->sharedSymbolTable(); 160 161 body->destroyData(); 162 } 163 138 164 #if ENABLE(JIT) 139 165 … … 141 167 { 142 168 CodeBlock* codeBlock = &bytecode(exec, scopeChainNode); 143 m_jitCode = JIT::compile(scopeChainNode->globalData, codeBlock);169 m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, codeBlock); 144 170 145 171 #if !ENABLE(OPCODE_SAMPLING) … … 152 178 { 153 179 CodeBlock* codeBlock = &bytecode(exec, scopeChainNode); 154 m_jitCode = JIT::compile(scopeChainNode->globalData, codeBlock);180 m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, codeBlock); 155 181 156 182 #if !ENABLE(OPCODE_SAMPLING) … … 160 186 } 161 187 162 void FunctionExecutable::generateJITCode (ExecState* exec, ScopeChainNode* scopeChainNode)163 { 164 CodeBlock* codeBlock = &bytecode (exec, scopeChainNode);165 m_jitCode = JIT::compile(scopeChainNode->globalData, codeBlock);188 void FunctionExecutable::generateJITCodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode) 189 { 190 CodeBlock* codeBlock = &bytecodeForCall(exec, scopeChainNode); 191 m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, codeBlock); 166 192 167 193 #if !ENABLE(OPCODE_SAMPLING) … … 171 197 } 172 198 199 void FunctionExecutable::generateJITCodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode) 200 { 201 CodeBlock* codeBlock = &bytecodeForConstruct(exec, scopeChainNode); 202 m_jitCodeForConstruct = JIT::compile(scopeChainNode->globalData, codeBlock); 203 204 #if !ENABLE(OPCODE_SAMPLING) 205 if (!BytecodeGenerator::dumpsGeneratedCode()) 206 codeBlock->discardBytecode(); 207 #endif 208 } 209 173 210 #endif 174 211 175 212 void FunctionExecutable::markAggregate(MarkStack& markStack) 176 213 { 177 if (m_codeBlock) 178 m_codeBlock->markAggregate(markStack); 214 if (m_codeBlockForCall) 215 m_codeBlockForCall->markAggregate(markStack); 216 if (m_codeBlockForConstruct) 217 m_codeBlockForConstruct->markAggregate(markStack); 179 218 } 180 219 … … 189 228 JSGlobalObject* globalObject = scopeChain.globalObject(); 190 229 191 OwnPtr<CodeBlock> newCodeBlock(new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset() ));230 OwnPtr<CodeBlock> newCodeBlock(new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset(), codeBlock->m_isConstructor)); 192 231 globalData->functionCodeBlockBeingReparsed = newCodeBlock.get(); 193 232 … … 200 239 #if ENABLE(JIT) 201 240 JITCode newJITCode = JIT::compile(globalData, newCodeBlock.get()); 202 ASSERT( newJITCode.size() == generatedJITCode().size());241 ASSERT(codeBlock->m_isConstructor ? newJITCode.size() == generatedJITCodeForConstruct().size() : newJITCode.size() == generatedJITCodeForCall().size()); 203 242 #endif 204 243 … … 225 264 #if ENABLE(JIT) 226 265 JITCode newJITCode = JIT::compile(globalData, newCodeBlock.get()); 227 ASSERT(newJITCode.size() == generatedJITCode ().size());266 ASSERT(newJITCode.size() == generatedJITCodeForCall().size()); 228 267 #endif 229 268 … … 233 272 void FunctionExecutable::recompile(ExecState*) 234 273 { 235 delete m_codeBlock; 236 m_codeBlock = 0; 237 m_numParameters = NUM_PARAMETERS_NOT_COMPILED; 238 #if ENABLE(JIT) 239 m_jitCode = JITCode(); 274 delete m_codeBlockForCall; 275 m_codeBlockForCall = 0; 276 delete m_codeBlockForConstruct; 277 m_codeBlockForConstruct = 0; 278 m_numParametersForCall = NUM_PARAMETERS_NOT_COMPILED; 279 m_numParametersForConstruct = NUM_PARAMETERS_NOT_COMPILED; 280 #if ENABLE(JIT) 281 m_jitCodeForCall = JITCode(); 282 m_jitCodeForConstruct = JITCode(); 240 283 #endif 241 284 } -
trunk/JavaScriptCore/runtime/Executable.h
r58469 r59339 37 37 class Debugger; 38 38 class EvalCodeBlock; 39 class FunctionCodeBlock; 39 40 class ProgramCodeBlock; 40 41 class ScopeChainNode; … … 51 52 public: 52 53 ExecutableBase(int numParameters) 53 : m_numParameters(numParameters) 54 : m_numParametersForCall(numParameters) 55 , m_numParametersForConstruct(numParameters) 54 56 { 55 57 } … … 57 59 virtual ~ExecutableBase() {} 58 60 59 bool isHostFunction() const { return m_numParameters == NUM_PARAMETERS_IS_HOST; } 61 bool isHostFunction() const 62 { 63 ASSERT((m_numParametersForCall == NUM_PARAMETERS_IS_HOST) == (m_numParametersForConstruct == NUM_PARAMETERS_IS_HOST)); 64 return m_numParametersForCall == NUM_PARAMETERS_IS_HOST; 65 } 60 66 61 67 protected: 62 int m_numParameters; 68 int m_numParametersForCall; 69 int m_numParametersForConstruct; 63 70 64 71 #if ENABLE(JIT) 65 72 public: 66 JITCode& generatedJITCode() 67 { 68 ASSERT(m_jitCode); 69 return m_jitCode; 70 } 71 72 ExecutablePool* getExecutablePool() 73 { 74 return m_jitCode.getExecutablePool(); 73 JITCode& generatedJITCodeForCall() 74 { 75 ASSERT(m_jitCodeForCall); 76 return m_jitCodeForCall; 77 } 78 79 JITCode& generatedJITCodeForConstruct() 80 { 81 ASSERT(m_jitCodeForConstruct); 82 return m_jitCodeForConstruct; 75 83 } 76 84 77 85 protected: 78 JITCode m_jitCode; 86 JITCode m_jitCodeForCall; 87 JITCode m_jitCodeForConstruct; 79 88 #endif 80 89 }; … … 86 95 : ExecutableBase(NUM_PARAMETERS_IS_HOST) 87 96 { 88 m_jitCode = exec->globalData().jitStubs.ctiNativeCallThunk()->m_jitCode; 97 m_jitCodeForCall = exec->globalData().jitStubs.ctiNativeCallThunk()->m_jitCodeForCall; 98 m_jitCodeForConstruct = exec->globalData().jitStubs.ctiNativeCallThunk()->m_jitCodeForCall; // FIXME: this thunk should have a construct form 89 99 } 90 100 NativeExecutable(JITCode thunk) 91 101 : ExecutableBase(NUM_PARAMETERS_IS_HOST) 92 102 { 93 m_jitCode = thunk; 103 m_jitCodeForCall = thunk; 104 m_jitCodeForConstruct = thunk; 94 105 } 95 106 … … 193 204 JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode) 194 205 { 195 if (!m_jitCode )206 if (!m_jitCodeForCall) 196 207 generateJITCode(exec, scopeChainNode); 197 return m_jitCode ;208 return m_jitCodeForCall; 198 209 } 199 210 … … 239 250 JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode) 240 251 { 241 if (!m_jitCode )252 if (!m_jitCodeForCall) 242 253 generateJITCode(exec, scopeChainNode); 243 return m_jitCode ;254 return m_jitCodeForCall; 244 255 } 245 256 … … 269 280 } 270 281 271 CodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode)282 FunctionCodeBlock& bytecodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode) 272 283 { 273 284 ASSERT(scopeChainNode); 274 if (!m_codeBlock) 275 compile(exec, scopeChainNode); 276 return *m_codeBlock; 277 } 278 279 bool isGenerated() const 280 { 281 return m_codeBlock; 282 } 283 284 CodeBlock& generatedBytecode() 285 { 286 ASSERT(m_codeBlock); 287 return *m_codeBlock; 285 if (!m_codeBlockForCall) 286 compileForCall(exec, scopeChainNode); 287 return *m_codeBlockForCall; 288 } 289 290 bool isGeneratedForCall() const 291 { 292 return m_codeBlockForCall; 293 } 294 295 FunctionCodeBlock& generatedBytecodeForCall() 296 { 297 ASSERT(m_codeBlockForCall); 298 return *m_codeBlockForCall; 299 } 300 301 FunctionCodeBlock& bytecodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode) 302 { 303 ASSERT(scopeChainNode); 304 if (!m_codeBlockForConstruct) 305 compileForConstruct(exec, scopeChainNode); 306 return *m_codeBlockForConstruct; 307 } 308 309 bool isGeneratedForConstruct() const 310 { 311 return m_codeBlockForConstruct; 312 } 313 314 FunctionCodeBlock& generatedBytecodeForConstruct() 315 { 316 ASSERT(m_codeBlockForConstruct); 317 return *m_codeBlockForConstruct; 288 318 } 289 319 … … 292 322 size_t variableCount() const { return m_numVariables; } 293 323 UString paramString() const; 324 SharedSymbolTable* symbolTable() const { return m_symbolTable; } 294 325 295 326 void recompile(ExecState*); … … 303 334 , m_forceUsesArguments(forceUsesArguments) 304 335 , m_parameters(parameters) 305 , m_codeBlock(0) 336 , m_codeBlockForCall(0) 337 , m_codeBlockForConstruct(0) 306 338 , m_name(name) 307 339 , m_numVariables(0) 340 , m_symbolTable(0) 308 341 { 309 342 m_firstLine = firstLine; … … 315 348 , m_forceUsesArguments(forceUsesArguments) 316 349 , m_parameters(parameters) 317 , m_codeBlock(0) 350 , m_codeBlockForCall(0) 351 , m_codeBlockForConstruct(0) 318 352 , m_name(name) 319 353 , m_numVariables(0) 354 , m_symbolTable(0) 320 355 { 321 356 m_firstLine = firstLine; … … 323 358 } 324 359 325 void compile(ExecState*, ScopeChainNode*); 360 void compileForCall(ExecState*, ScopeChainNode*); 361 void compileForConstruct(ExecState*, ScopeChainNode*); 326 362 327 363 bool m_forceUsesArguments; 328 364 RefPtr<FunctionParameters> m_parameters; 329 CodeBlock* m_codeBlock; 365 FunctionCodeBlock* m_codeBlockForCall; 366 FunctionCodeBlock* m_codeBlockForConstruct; 330 367 Identifier m_name; 331 368 size_t m_numVariables; 369 SharedSymbolTable* m_symbolTable; 332 370 333 371 #if ENABLE(JIT) 334 372 public: 335 JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode) 336 { 337 if (!m_jitCode) 338 generateJITCode(exec, scopeChainNode); 339 return m_jitCode; 340 } 341 342 private: 343 void generateJITCode(ExecState*, ScopeChainNode*); 373 JITCode& jitCodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode) 374 { 375 if (!m_jitCodeForCall) 376 generateJITCodeForCall(exec, scopeChainNode); 377 return m_jitCodeForCall; 378 } 379 380 JITCode& jitCodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode) 381 { 382 if (!m_jitCodeForConstruct) 383 generateJITCodeForConstruct(exec, scopeChainNode); 384 return m_jitCodeForConstruct; 385 } 386 387 private: 388 void generateJITCodeForCall(ExecState*, ScopeChainNode*); 389 void generateJITCodeForConstruct(ExecState*, ScopeChainNode*); 344 390 #endif 345 391 }; -
trunk/JavaScriptCore/runtime/JSActivation.h
r58986 r59339 74 74 struct JSActivationData : public JSVariableObjectData { 75 75 JSActivationData(NonNullPassRefPtr<FunctionExecutable> _functionExecutable, Register* registers) 76 : JSVariableObjectData(_functionExecutable-> generatedBytecode().symbolTable(), registers)76 : JSVariableObjectData(_functionExecutable->symbolTable(), registers) 77 77 , functionExecutable(_functionExecutable) 78 78 { 79 79 // We have to manually ref and deref the symbol table as JSVariableObjectData 80 80 // doesn't know about SharedSymbolTable 81 functionExecutable-> generatedBytecode().sharedSymbolTable()->ref();81 functionExecutable->symbolTable()->ref(); 82 82 } 83 83 ~JSActivationData() -
trunk/JavaScriptCore/runtime/JSFunction.cpp
r58469 r59339 107 107 #if ENABLE(JIT_OPTIMIZE_CALL) 108 108 ASSERT(m_executable); 109 if (jsExecutable()->isGenerated()) 110 jsExecutable()->generatedBytecode().unlinkCallers(); 109 if (jsExecutable()->isGeneratedForCall()) 110 jsExecutable()->generatedBytecodeForCall().unlinkCallers(); 111 if (jsExecutable()->isGeneratedForConstruct()) 112 jsExecutable()->generatedBytecodeForConstruct().unlinkCallers(); 111 113 #endif 112 114 scopeChain().~ScopeChain(); // FIXME: Don't we need to do this in the interpreter too? … … 137 139 { 138 140 ASSERT(!isHostFunction()); 139 return exec->interpreter()->execute (jsExecutable(), exec, this, thisValue.toThisObject(exec), args, scopeChain().node(), exec->exceptionSlot());141 return exec->interpreter()->executeCall(jsExecutable(), exec, this, thisValue.toThisObject(exec), args, scopeChain().node(), exec->exceptionSlot()); 140 142 } 141 143 … … 278 280 JSObject* thisObj = new (exec) JSObject(structure); 279 281 280 JSValue result = exec->interpreter()->execute (jsExecutable(), exec, this, thisObj, args, scopeChain().node(), exec->exceptionSlot());282 JSValue result = exec->interpreter()->executeConstruct(jsExecutable(), exec, this, thisObj, args, scopeChain().node(), exec->exceptionSlot()); 281 283 if (exec->hadException() || !result.isObject()) 282 284 return thisObj; -
trunk/JavaScriptCore/runtime/JSGlobalData.cpp
r58712 r59339 247 247 initializingLazyNumericCompareFunction = true; 248 248 RefPtr<FunctionExecutable> function = FunctionExecutable::fromGlobalCode(Identifier(exec, "numericCompare"), exec, 0, makeSource(UString("(function (v1, v2) { return v1 - v2; })")), 0, 0); 249 lazyNumericCompareFunction = function->bytecode (exec, exec->scopeChain()).instructions();249 lazyNumericCompareFunction = function->bytecodeForCall(exec, exec->scopeChain()).instructions(); 250 250 initializingLazyNumericCompareFunction = false; 251 251 }
Note:
See TracChangeset
for help on using the changeset viewer.