Changeset 39070 in webkit for trunk/JavaScriptCore/jit/JIT.cpp
- Timestamp:
- Dec 6, 2008, 2:01:05 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/jit/JIT.cpp
r39061 r39070 185 185 , m_globalData(globalData) 186 186 , m_codeBlock(codeBlock) 187 , m_labels(codeBlock ? codeBlock->instructions .size() : 0)188 , m_propertyAccessCompilationInfo(codeBlock ? codeBlock-> propertyAccessInstructions.size() : 0)189 , m_callStructureStubCompilationInfo(codeBlock ? codeBlock-> callLinkInfos.size() : 0)187 , m_labels(codeBlock ? codeBlock->instructions().size() : 0) 188 , m_propertyAccessCompilationInfo(codeBlock ? codeBlock->numberOfPropertyAccessInstructions() : 0) 189 , m_callStructureStubCompilationInfo(codeBlock ? codeBlock->numberOfCallLinkInfos() : 0) 190 190 , m_lastResultBytecodeRegister(std::numeric_limits<int>::max()) 191 191 , m_jumpTargetsPosition(0) … … 266 266 void JIT::privateCompileMainPass() 267 267 { 268 Instruction* instruction = m_codeBlock->instructions .begin();269 unsigned instructionCount = m_codeBlock->instructions .size();268 Instruction* instruction = m_codeBlock->instructions().begin(); 269 unsigned instructionCount = m_codeBlock->instructions().size(); 270 270 271 271 unsigned propertyAccessInstructionIndex = 0; … … 320 320 } 321 321 case op_end: { 322 if (m_codeBlock->needsFullScopeChain )322 if (m_codeBlock->needsFullScopeChain()) 323 323 emitCTICall(i, Interpreter::cti_op_end); 324 324 emitGetVirtualRegister(instruction[i + 1].u.operand, X86::eax, i); … … 394 394 } 395 395 case op_put_by_id: { 396 compilePutByIdHotPath(instruction[i + 1].u.operand, &(m_codeBlock->identifier s[instruction[i + 2].u.operand]), instruction[i + 3].u.operand, i, propertyAccessInstructionIndex++);396 compilePutByIdHotPath(instruction[i + 1].u.operand, &(m_codeBlock->identifier(instruction[i + 2].u.operand)), instruction[i + 3].u.operand, i, propertyAccessInstructionIndex++); 397 397 i += 8; 398 398 break; 399 399 } 400 400 case op_get_by_id: { 401 compileGetByIdHotPath(instruction[i + 1].u.operand, instruction[i + 2].u.operand, &(m_codeBlock->identifier s[instruction[i + 3].u.operand]), i, propertyAccessInstructionIndex++);401 compileGetByIdHotPath(instruction[i + 1].u.operand, instruction[i + 2].u.operand, &(m_codeBlock->identifier(instruction[i + 3].u.operand)), i, propertyAccessInstructionIndex++); 402 402 i += 8; 403 403 break; … … 464 464 case op_del_by_id: { 465 465 emitPutCTIArgFromVirtualRegister(instruction[i + 2].u.operand, 0, X86::ecx); 466 Identifier* ident = &(m_codeBlock->identifier s[instruction[i + 3].u.operand]);466 Identifier* ident = &(m_codeBlock->identifier(instruction[i + 3].u.operand)); 467 467 emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 4); 468 468 emitCTICall(i, Interpreter::cti_op_del_by_id); … … 501 501 } 502 502 case op_new_func: { 503 FuncDeclNode* func = (m_codeBlock->functions[instruction[i + 2].u.operand]).get();503 FuncDeclNode* func = m_codeBlock->function(instruction[i + 2].u.operand); 504 504 emitPutCTIArgConstant(reinterpret_cast<unsigned>(func), 0); 505 505 emitCTICall(i, Interpreter::cti_op_new_func); … … 532 532 } 533 533 case op_get_scoped_var: { 534 int skip = instruction[i + 3].u.operand + m_codeBlock->needsFullScopeChain ;534 int skip = instruction[i + 3].u.operand + m_codeBlock->needsFullScopeChain(); 535 535 536 536 emitGetFromCallFrameHeader(RegisterFile::ScopeChain, X86::eax); … … 545 545 } 546 546 case op_put_scoped_var: { 547 int skip = instruction[i + 2].u.operand + m_codeBlock->needsFullScopeChain ;547 int skip = instruction[i + 2].u.operand + m_codeBlock->needsFullScopeChain(); 548 548 549 549 emitGetFromCallFrameHeader(RegisterFile::ScopeChain, X86::edx); … … 570 570 case op_ret: { 571 571 // We could JIT generate the deref, only calling out to C when the refcount hits zero. 572 if (m_codeBlock->needsFullScopeChain )572 if (m_codeBlock->needsFullScopeChain()) 573 573 emitCTICall(i, Interpreter::cti_op_ret_scopeChain); 574 574 … … 599 599 } 600 600 case op_resolve: { 601 Identifier* ident = &(m_codeBlock->identifier s[instruction[i + 2].u.operand]);601 Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand)); 602 602 emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0); 603 603 emitCTICall(i, Interpreter::cti_op_resolve); … … 642 642 } 643 643 case op_resolve_func: { 644 Identifier* ident = &(m_codeBlock->identifier s[instruction[i + 3].u.operand]);644 Identifier* ident = &(m_codeBlock->identifier(instruction[i + 3].u.operand)); 645 645 emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0); 646 646 emitCTICall(i, Interpreter::cti_op_resolve_func); … … 705 705 }; 706 706 case op_resolve_base: { 707 Identifier* ident = &(m_codeBlock->identifier s[instruction[i + 2].u.operand]);707 Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand)); 708 708 emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0); 709 709 emitCTICall(i, Interpreter::cti_op_resolve_base); … … 720 720 } 721 721 case op_resolve_skip: { 722 Identifier* ident = &(m_codeBlock->identifier s[instruction[i + 2].u.operand]);722 Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand)); 723 723 emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0); 724 emitPutCTIArgConstant(instruction[i + 3].u.operand + m_codeBlock->needsFullScopeChain , 4);724 emitPutCTIArgConstant(instruction[i + 3].u.operand + m_codeBlock->needsFullScopeChain(), 4); 725 725 emitCTICall(i, Interpreter::cti_op_resolve_skip); 726 726 emitPutVirtualRegister(instruction[i + 1].u.operand); … … 731 731 // Fast case 732 732 unsigned globalObject = asInteger(instruction[i + 2].u.jsCell); 733 Identifier* ident = &(m_codeBlock->identifier s[instruction[i + 3].u.operand]);733 Identifier* ident = &(m_codeBlock->identifier(instruction[i + 3].u.operand)); 734 734 void* structureAddress = reinterpret_cast<void*>(instruction + i + 4); 735 735 void* offsetAddr = reinterpret_cast<void*>(instruction + i + 5); … … 887 887 } 888 888 case op_unexpected_load: { 889 JSValue* v = m_codeBlock->unexpectedConstant s[instruction[i + 2].u.operand];889 JSValue* v = m_codeBlock->unexpectedConstant(instruction[i + 2].u.operand); 890 890 __ movl_i32r(asInteger(v), X86::eax); 891 891 emitPutVirtualRegister(instruction[i + 1].u.operand); … … 984 984 } 985 985 case op_resolve_with_base: { 986 Identifier* ident = &(m_codeBlock->identifier s[instruction[i + 3].u.operand]);986 Identifier* ident = &(m_codeBlock->identifier(instruction[i + 3].u.operand)); 987 987 emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0); 988 988 emitCTICall(i, Interpreter::cti_op_resolve_with_base); … … 993 993 } 994 994 case op_new_func_exp: { 995 FuncExprNode* func = (m_codeBlock->functionExpressions[instruction[i + 2].u.operand]).get();995 FuncExprNode* func = m_codeBlock->functionExpression(instruction[i + 2].u.operand); 996 996 emitPutCTIArgConstant(reinterpret_cast<unsigned>(func), 0); 997 997 emitCTICall(i, Interpreter::cti_op_new_func_exp); … … 1070 1070 } 1071 1071 case op_new_regexp: { 1072 RegExp* regExp = m_codeBlock->regexp s[instruction[i + 2].u.operand].get();1072 RegExp* regExp = m_codeBlock->regexp(instruction[i + 2].u.operand); 1073 1073 emitPutCTIArgConstant(reinterpret_cast<unsigned>(regExp), 0); 1074 1074 emitCTICall(i, Interpreter::cti_op_new_regexp); … … 1172 1172 } 1173 1173 case op_push_new_scope: { 1174 Identifier* ident = &(m_codeBlock->identifier s[instruction[i + 2].u.operand]);1174 Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand)); 1175 1175 emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 0); 1176 1176 emitPutCTIArgFromVirtualRegister(instruction[i + 3].u.operand, 4, X86::ecx); … … 1263 1263 case op_put_getter: { 1264 1264 emitPutCTIArgFromVirtualRegister(instruction[i + 1].u.operand, 0, X86::ecx); 1265 Identifier* ident = &(m_codeBlock->identifier s[instruction[i + 2].u.operand]);1265 Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand)); 1266 1266 emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 4); 1267 1267 emitPutCTIArgFromVirtualRegister(instruction[i + 3].u.operand, 8, X86::ecx); … … 1272 1272 case op_put_setter: { 1273 1273 emitPutCTIArgFromVirtualRegister(instruction[i + 1].u.operand, 0, X86::ecx); 1274 Identifier* ident = &(m_codeBlock->identifier s[instruction[i + 2].u.operand]);1274 Identifier* ident = &(m_codeBlock->identifier(instruction[i + 2].u.operand)); 1275 1275 emitPutCTIArgConstant(reinterpret_cast<unsigned>(ident), 4); 1276 1276 emitPutCTIArgFromVirtualRegister(instruction[i + 3].u.operand, 8, X86::ecx); … … 1280 1280 } 1281 1281 case op_new_error: { 1282 JSValue* message = m_codeBlock->unexpectedConstant s[instruction[i + 3].u.operand];1282 JSValue* message = m_codeBlock->unexpectedConstant(instruction[i + 3].u.operand); 1283 1283 emitPutCTIArgConstant(instruction[i + 2].u.operand, 0); 1284 1284 emitPutCTIArgConstant(asInteger(message), 4); … … 1359 1359 // registers to zap stale pointers, to avoid unnecessarily prolonging 1360 1360 // object lifetime and increasing GC pressure. 1361 size_t count = m_codeBlock-> numVars + m_codeBlock->constantRegisters.size();1361 size_t count = m_codeBlock->m_numVars + m_codeBlock->numberOfConstantRegisters(); 1362 1362 for (size_t j = 0; j < count; ++j) 1363 1363 emitInitRegister(j); … … 1370 1370 // registers to zap stale pointers, to avoid unnecessarily prolonging 1371 1371 // object lifetime and increasing GC pressure. 1372 size_t count = m_codeBlock-> numVars + m_codeBlock->constantRegisters.size();1372 size_t count = m_codeBlock->m_numVars + m_codeBlock->numberOfConstantRegisters(); 1373 1373 for (size_t j = 0; j < count; ++j) 1374 1374 emitInitRegister(j); … … 1381 1381 } 1382 1382 case op_create_arguments: { 1383 emitCTICall(i, (m_codeBlock-> numParameters == 1) ? Interpreter::cti_op_create_arguments_no_params : Interpreter::cti_op_create_arguments);1383 emitCTICall(i, (m_codeBlock->m_numParameters == 1) ? Interpreter::cti_op_create_arguments_no_params : Interpreter::cti_op_create_arguments); 1384 1384 i += 1; 1385 1385 break; … … 1433 1433 } 1434 1434 1435 ASSERT(propertyAccessInstructionIndex == m_codeBlock-> propertyAccessInstructions.size());1436 ASSERT(callLinkInfoIndex == m_codeBlock-> callLinkInfos.size());1435 ASSERT(propertyAccessInstructionIndex == m_codeBlock->numberOfPropertyAccessInstructions()); 1436 ASSERT(callLinkInfoIndex == m_codeBlock->numberOfCallLinkInfos()); 1437 1437 } 1438 1438 … … 1462 1462 unsigned callLinkInfoIndex = 0; 1463 1463 1464 Instruction* instruction = m_codeBlock->instructions .begin();1464 Instruction* instruction = m_codeBlock->instructions().begin(); 1465 1465 for (Vector<SlowCaseEntry>::iterator iter = m_slowCases.begin(); iter != m_slowCases.end(); ++iter) { 1466 1466 // FIXME: enable peephole optimizations for slow cases when applicable … … 1605 1605 } 1606 1606 case op_put_by_id: { 1607 compilePutByIdSlowCase(instruction[i + 1].u.operand, &(m_codeBlock->identifier s[instruction[i + 2].u.operand]), instruction[i + 3].u.operand, i, iter, propertyAccessInstructionIndex++);1607 compilePutByIdSlowCase(instruction[i + 1].u.operand, &(m_codeBlock->identifier(instruction[i + 2].u.operand)), instruction[i + 3].u.operand, i, iter, propertyAccessInstructionIndex++); 1608 1608 i += 8; 1609 1609 break; 1610 1610 } 1611 1611 case op_get_by_id: { 1612 compileGetByIdSlowCase(instruction[i + 1].u.operand, instruction[i + 2].u.operand, &(m_codeBlock->identifier s[instruction[i + 3].u.operand]), i, iter, propertyAccessInstructionIndex++);1612 compileGetByIdSlowCase(instruction[i + 1].u.operand, instruction[i + 2].u.operand, &(m_codeBlock->identifier(instruction[i + 3].u.operand)), i, iter, propertyAccessInstructionIndex++); 1613 1613 i += 8; 1614 1614 break; … … 1948 1948 } 1949 1949 1950 ASSERT(propertyAccessInstructionIndex == m_codeBlock-> propertyAccessInstructions.size());1951 ASSERT(callLinkInfoIndex == m_codeBlock-> callLinkInfos.size());1950 ASSERT(propertyAccessInstructionIndex == m_codeBlock->numberOfPropertyAccessInstructions()); 1951 ASSERT(callLinkInfoIndex == m_codeBlock->numberOfCallLinkInfos()); 1952 1952 } 1953 1953 … … 1958 1958 #endif 1959 1959 #if ENABLE(OPCODE_SAMPLING) 1960 __ movl_i32m(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions .begin()), m_interpreter->sampler()->sampleSlot());1960 __ movl_i32m(m_interpreter->sampler()->encodeSample(m_codeBlock->instructions().begin()), m_interpreter->sampler()->sampleSlot()); 1961 1961 #endif 1962 1962 … … 1967 1967 JmpSrc slowRegisterFileCheck; 1968 1968 JmpDst afterRegisterFileCheck; 1969 if (m_codeBlock->codeType == FunctionCode) {1969 if (m_codeBlock->codeType() == FunctionCode) { 1970 1970 // In the case of a fast linked call, we do not set this up in the caller. 1971 1971 emitPutImmediateToCallFrameHeader(m_codeBlock, RegisterFile::CodeBlock); 1972 1972 1973 1973 emitGetCTIParam(CTI_ARGS_registerFile, X86::eax); 1974 __ leal_mr(m_codeBlock-> numCalleeRegisters * sizeof(Register), X86::edi, X86::edx);1974 __ leal_mr(m_codeBlock->m_numCalleeRegisters * sizeof(Register), X86::edi, X86::edx); 1975 1975 __ cmpl_mr(FIELD_OFFSET(RegisterFile, m_end), X86::eax, X86::edx); 1976 1976 slowRegisterFileCheck = __ jg(); … … 1982 1982 privateCompileSlowCases(); 1983 1983 1984 if (m_codeBlock->codeType == FunctionCode) {1984 if (m_codeBlock->codeType() == FunctionCode) { 1985 1985 __ link(slowRegisterFileCheck, __ label()); 1986 1986 emitCTICall(0, Interpreter::cti_register_file_check); … … 2021 2021 } 2022 2022 2023 for (Vector<HandlerInfo>::iterator iter = m_codeBlock->exceptionHandlers.begin(); iter != m_codeBlock->exceptionHandlers.end(); ++iter) 2024 iter->nativeCode = __ getRelocatedAddress(code, m_labels[iter->target]); 2023 for (size_t i = 0; i < m_codeBlock->numberOfExceptionHandlers(); ++i) { 2024 HandlerInfo& handler = m_codeBlock->exceptionHandler(i); 2025 handler.nativeCode = __ getRelocatedAddress(code, m_labels[handler.target]); 2026 } 2025 2027 2026 2028 for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter) { 2027 2029 if (iter->to) 2028 2030 X86Assembler::link(code, iter->from, iter->to); 2029 m_codeBlock-> ctiReturnAddressVPCMap.add(__ getRelocatedAddress(code, iter->from), iter->bytecodeIndex);2031 m_codeBlock->jitReturnAddressVPCMap().add(__ getRelocatedAddress(code, iter->from), iter->bytecodeIndex); 2030 2032 } 2031 2033 … … 2034 2036 X86Assembler::linkAbsoluteAddress(code, iter->addrPosition, iter->target); 2035 2037 2036 for (unsigned i = 0; i < m_codeBlock-> propertyAccessInstructions.size(); ++i) {2037 StructureStubInfo& info = m_codeBlock->propertyAccessInstruction s[i];2038 for (unsigned i = 0; i < m_codeBlock->numberOfPropertyAccessInstructions(); ++i) { 2039 StructureStubInfo& info = m_codeBlock->propertyAccessInstruction(i); 2038 2040 info.callReturnLocation = X86Assembler::getRelocatedAddress(code, m_propertyAccessCompilationInfo[i].callReturnLocation); 2039 2041 info.hotPathBegin = X86Assembler::getRelocatedAddress(code, m_propertyAccessCompilationInfo[i].hotPathBegin); 2040 2042 } 2041 for (unsigned i = 0; i < m_codeBlock-> callLinkInfos.size(); ++i) {2042 CallLinkInfo& info = m_codeBlock->callLinkInfo s[i];2043 for (unsigned i = 0; i < m_codeBlock->numberOfCallLinkInfos(); ++i) { 2044 CallLinkInfo& info = m_codeBlock->callLinkInfo(i); 2043 2045 info.callReturnLocation = X86Assembler::getRelocatedAddress(code, m_callStructureStubCompilationInfo[i].callReturnLocation); 2044 2046 info.hotPathBegin = X86Assembler::getRelocatedAddress(code, m_callStructureStubCompilationInfo[i].hotPathBegin); … … 2047 2049 } 2048 2050 2049 m_codeBlock-> ctiCode = code;2051 m_codeBlock->setJITCode(code); 2050 2052 } 2051 2053 … … 2111 2113 2112 2114 // Check argCount matches callee arity. 2113 __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, numParameters), X86::eax);2115 __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, m_numParameters), X86::eax); 2114 2116 JmpSrc arityCheckOkay1 = __ je(); 2115 2117 __ popl_r(X86::ebx); … … 2153 2155 2154 2156 // Check argCount matches callee arity. 2155 __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, numParameters), X86::eax);2157 __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, m_numParameters), X86::eax); 2156 2158 JmpSrc arityCheckOkay2 = __ je(); 2157 2159 __ popl_r(X86::ebx); … … 2195 2197 2196 2198 // Check argCount matches callee arity. 2197 __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, numParameters), X86::eax);2199 __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, m_numParameters), X86::eax); 2198 2200 JmpSrc arityCheckOkay3 = __ je(); 2199 2201 __ popl_r(X86::ebx); … … 2212 2214 2213 2215 // load ctiCode from the new codeBlock. 2214 __ movl_mr(FIELD_OFFSET(CodeBlock, ctiCode), X86::eax, X86::eax);2216 __ movl_mr(FIELD_OFFSET(CodeBlock, m_jitCode), X86::eax, X86::eax); 2215 2217 2216 2218 __ jmp_r(X86::eax);
Note:
See TracChangeset
for help on using the changeset viewer.