Changeset 39070 in webkit for trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
- Timestamp:
- Dec 6, 2008, 2:01:05 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r39038 r39070 130 130 void BytecodeGenerator::generate() 131 131 { 132 m_codeBlock-> thisRegister = m_thisRegister.index();132 m_codeBlock->setThisRegister(m_thisRegister.index()); 133 133 134 134 m_scopeNode->emitBytecode(*this); … … 155 155 } 156 156 157 ++m_codeBlock-> numVars;157 ++m_codeBlock->m_numVars; 158 158 r0 = newRegister(); 159 159 return true; … … 179 179 void BytecodeGenerator::allocateConstants(size_t count) 180 180 { 181 m_codeBlock-> numConstants = count;181 m_codeBlock->m_numConstants = count; 182 182 if (!count) 183 183 return; … … 207 207 { 208 208 if (m_shouldEmitDebugHooks) 209 m_codeBlock-> needsFullScopeChain = true;209 m_codeBlock->setNeedsFullScopeChain(true); 210 210 211 211 emitOpcode(op_enter); 212 codeBlock-> globalData = m_globalData;212 codeBlock->setGlobalData(m_globalData); 213 213 214 214 // FIXME: Move code that modifies the global object to Interpreter::execute. 215 215 216 m_codeBlock-> numParameters = 1; // Allocate space for "this"216 m_codeBlock->m_numParameters = 1; // Allocate space for "this" 217 217 218 218 JSGlobalObject* globalObject = scopeChain.globalObject(); … … 221 221 222 222 // Shift register indexes in generated code to elide registers allocated by intermediate stack frames. 223 m_globalVarStorageOffset = -RegisterFile::CallFrameHeaderSize - m_codeBlock-> numParameters - registerFile->size();223 m_globalVarStorageOffset = -RegisterFile::CallFrameHeaderSize - m_codeBlock->m_numParameters - registerFile->size(); 224 224 225 225 // Add previously defined symbols to bookkeeping. … … 286 286 { 287 287 if (m_shouldEmitDebugHooks) 288 m_codeBlock-> needsFullScopeChain = true;289 290 codeBlock-> globalData = m_globalData;288 m_codeBlock->setNeedsFullScopeChain(true); 289 290 codeBlock->setGlobalData(m_globalData); 291 291 292 292 bool usesArguments = functionBody->usesArguments(); 293 codeBlock-> usesArguments = usesArguments;293 codeBlock->setUsesArguments(usesArguments); 294 294 if (usesArguments) { 295 295 m_argumentsRegister.setIndex(RegisterFile::OptionalCalleeArguments); … … 297 297 } 298 298 299 if (m_codeBlock->needsFullScopeChain ) {300 ++m_codeBlock-> numVars;299 if (m_codeBlock->needsFullScopeChain()) { 300 ++m_codeBlock->m_numVars; 301 301 m_activationRegisterIndex = newRegister()->index(); 302 302 emitOpcode(op_enter_with_activation); … … 328 328 m_thisRegister.setIndex(m_nextParameterIndex); 329 329 ++m_nextParameterIndex; 330 ++m_codeBlock-> numParameters;330 ++m_codeBlock->m_numParameters; 331 331 332 332 if (functionBody->usesThis()) { … … 357 357 { 358 358 if (m_shouldEmitDebugHooks) 359 m_codeBlock-> needsFullScopeChain = true;359 m_codeBlock->setNeedsFullScopeChain(true); 360 360 361 361 emitOpcode(op_enter); 362 codeBlock-> globalData = m_globalData;363 m_codeBlock-> numParameters = 1; // Allocate space for "this"362 codeBlock->setGlobalData(m_globalData); 363 m_codeBlock->m_numParameters = 1; // Allocate space for "this" 364 364 365 365 allocateConstants(evalNode->neededConstants()); … … 381 381 // each parameter, even if the parameter doesn't make it into the symbol table. 382 382 ++m_nextParameterIndex; 383 ++m_codeBlock-> numParameters;383 ++m_codeBlock->m_numParameters; 384 384 return result; 385 385 } … … 427 427 { 428 428 m_calleeRegisters.append(m_calleeRegisters.size()); 429 m_codeBlock-> numCalleeRegisters = max<int>(m_codeBlock->numCalleeRegisters, m_calleeRegisters.size());429 m_codeBlock->m_numCalleeRegisters = max<int>(m_codeBlock->m_numCalleeRegisters, m_calleeRegisters.size()); 430 430 return &m_calleeRegisters.last(); 431 431 } … … 444 444 RegisterID* BytecodeGenerator::highestUsedRegister() 445 445 { 446 size_t count = m_codeBlock-> numCalleeRegisters;446 size_t count = m_codeBlock->m_numCalleeRegisters; 447 447 while (m_calleeRegisters.size() < count) 448 448 newRegister(); … … 478 478 l0->setLocation(newLabelIndex); 479 479 480 if (m_codeBlock-> jumpTargets.size() != 0) {481 unsigned lastLabelIndex = m_codeBlock-> jumpTargets.last();480 if (m_codeBlock->numberOfJumpTargets()) { 481 unsigned lastLabelIndex = m_codeBlock->lastJumpTarget(); 482 482 ASSERT(lastLabelIndex <= newLabelIndex); 483 483 if (newLabelIndex == lastLabelIndex) { 484 484 // Peephole optimizations have already been disabled by emitting the last label 485 return l0; 486 } 487 } 488 489 m_codeBlock-> jumpTargets.append(newLabelIndex);485 return l0; 486 } 487 } 488 489 m_codeBlock->addJumpTarget(newLabelIndex); 490 490 491 491 // This disables peephole optimizations when an instruction is a jump target … … 671 671 { 672 672 // No need to explicitly unique function body nodes -- they're unique already. 673 int index = m_codeBlock->functions.size(); 674 m_codeBlock->functions.append(n); 675 return index; 673 return m_codeBlock->addFunction(n); 676 674 } 677 675 … … 679 677 { 680 678 // No need to explicitly unique function expression nodes -- they're unique already. 681 int index = m_codeBlock->functionExpressions.size(); 682 m_codeBlock->functionExpressions.append(n); 683 return index; 679 return m_codeBlock->addFunctionExpression(n); 684 680 } 685 681 … … 687 683 { 688 684 UString::Rep* rep = ident.ustring().rep(); 689 pair<IdentifierMap::iterator, bool> result = m_identifierMap.add(rep, m_codeBlock-> identifiers.size());685 pair<IdentifierMap::iterator, bool> result = m_identifierMap.add(rep, m_codeBlock->numberOfIdentifiers()); 690 686 if (result.second) // new entry 691 m_codeBlock-> identifiers.append(Identifier(m_globalData, rep));687 m_codeBlock->addIdentifier(Identifier(m_globalData, rep)); 692 688 693 689 return result.first->second; … … 702 698 ++m_nextConstantIndex; 703 699 704 m_codeBlock-> constantRegisters.append(v);700 m_codeBlock->addConstantRegister(v); 705 701 return &constant; 706 702 } … … 711 707 unsigned BytecodeGenerator::addUnexpectedConstant(JSValue* v) 712 708 { 713 int index = m_codeBlock->unexpectedConstants.size(); 714 m_codeBlock->unexpectedConstants.append(v); 715 return index; 709 return m_codeBlock->addUnexpectedConstant(v); 716 710 } 717 711 718 712 unsigned BytecodeGenerator::addRegExp(RegExp* r) 719 713 { 720 int index = m_codeBlock->regexps.size(); 721 m_codeBlock->regexps.append(r); 722 return index; 714 return m_codeBlock->addRegExp(r); 723 715 } 724 716 … … 795 787 && src1->isTemporary() 796 788 && m_codeBlock->isConstantRegisterIndex(src2->index()) 797 && m_codeBlock->constantRegister s[src2->index() - m_codeBlock->numVars].jsValue(m_scopeChain->globalObject()->globalExec())->isString()) {798 const UString& value = asString(m_codeBlock->constantRegister s[src2->index() - m_codeBlock->numVars].jsValue(m_scopeChain->globalObject()->globalExec()))->value();789 && m_codeBlock->constantRegister(src2->index() - m_codeBlock->m_numVars).jsValue(m_scopeChain->globalObject()->globalExec())->isString()) { 790 const UString& value = asString(m_codeBlock->constantRegister(src2->index() - m_codeBlock->m_numVars).jsValue(m_scopeChain->globalObject()->globalExec()))->value(); 799 791 if (value == "undefined") { 800 792 rewindUnaryOp(); … … 987 979 988 980 if (globalObject) { 989 m_codeBlock-> globalResolveInstructions.append(instructions().size());981 m_codeBlock->addGlobalResolveInstruction(instructions().size()); 990 982 emitOpcode(op_resolve_global); 991 983 instructions().append(dst->index()); … … 1067 1059 RegisterID* BytecodeGenerator::emitGetById(RegisterID* dst, RegisterID* base, const Identifier& property) 1068 1060 { 1069 m_codeBlock-> propertyAccessInstructions.append(instructions().size());1061 m_codeBlock->addPropertyAccessInstruction(instructions().size()); 1070 1062 1071 1063 emitOpcode(op_get_by_id); … … 1082 1074 RegisterID* BytecodeGenerator::emitPutById(RegisterID* base, const Identifier& property, RegisterID* value) 1083 1075 { 1084 m_codeBlock-> propertyAccessInstructions.append(instructions().size());1076 m_codeBlock->addPropertyAccessInstruction(instructions().size()); 1085 1077 1086 1078 emitOpcode(op_put_by_id); … … 1254 1246 1255 1247 emitExpressionInfo(divot, startOffset, endOffset); 1256 m_codeBlock-> callLinkInfos.append(CallLinkInfo());1248 m_codeBlock->addCallLinkInfo(); 1257 1249 1258 1250 // Emit call. … … 1278 1270 RegisterID* BytecodeGenerator::emitReturn(RegisterID* src) 1279 1271 { 1280 if (m_codeBlock->needsFullScopeChain ) {1272 if (m_codeBlock->needsFullScopeChain()) { 1281 1273 emitOpcode(op_tear_off_activation); 1282 1274 instructions().append(m_activationRegisterIndex); 1283 } else if (m_codeBlock->usesArguments && m_codeBlock->numParameters > 1)1275 } else if (m_codeBlock->usesArguments() && m_codeBlock->m_numParameters > 1) 1284 1276 emitOpcode(op_tear_off_arguments); 1285 1277 … … 1333 1325 1334 1326 emitExpressionInfo(divot, startOffset, endOffset); 1335 m_codeBlock-> callLinkInfos.append(CallLinkInfo());1327 m_codeBlock->addCallLinkInfo(); 1336 1328 1337 1329 emitOpcode(op_construct); … … 1552 1544 { 1553 1545 HandlerInfo info = { start->offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth, 0 }; 1554 exceptionHandlers().append(info);1546 m_codeBlock->addExceptionHandler(info); 1555 1547 emitOpcode(op_catch); 1556 1548 instructions().append(targetRegister->index());
Note:
See TracChangeset
for help on using the changeset viewer.