Changeset 59339 in webkit for trunk/JavaScriptCore/runtime/Executable.cpp
- Timestamp:
- May 12, 2010, 9:01:56 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.