Changeset 218412 in webkit
- Timestamp:
- Jun 16, 2017, 2:02:37 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r218395 r218412 1 2017-06-16 Mark Lam <mark.lam@apple.com> 2 3 Interpreter methods for mapping between Opcode and OpcodeID need not be instance methods. 4 https://bugs.webkit.org/show_bug.cgi?id=173491 5 6 Reviewed by Keith Miller. 7 8 The implementation are based on static data. There's no need to get the 9 interpreter instance. Hence, we can make these methods static and avoid doing 10 unnecessary work to compute the interpreter this pointer. 11 12 Also removed the unused isCallBytecode method. 13 14 * bytecode/BytecodeBasicBlock.cpp: 15 (JSC::BytecodeBasicBlock::computeImpl): 16 * bytecode/BytecodeDumper.cpp: 17 (JSC::BytecodeDumper<Block>::printGetByIdOp): 18 (JSC::BytecodeDumper<Block>::printGetByIdCacheStatus): 19 (JSC::BytecodeDumper<Block>::dumpBytecode): 20 (JSC::BytecodeDumper<Block>::dumpBlock): 21 * bytecode/BytecodeLivenessAnalysis.cpp: 22 (JSC::BytecodeLivenessAnalysis::dumpResults): 23 * bytecode/BytecodeLivenessAnalysisInlines.h: 24 (JSC::BytecodeLivenessPropagation<DerivedAnalysis>::stepOverInstruction): 25 * bytecode/BytecodeRewriter.cpp: 26 (JSC::BytecodeRewriter::adjustJumpTargetsInFragment): 27 * bytecode/CallLinkStatus.cpp: 28 (JSC::CallLinkStatus::computeFromLLInt): 29 * bytecode/CodeBlock.cpp: 30 (JSC::CodeBlock::finishCreation): 31 (JSC::CodeBlock::propagateTransitions): 32 (JSC::CodeBlock::finalizeLLIntInlineCaches): 33 (JSC::CodeBlock::hasOpDebugForLineAndColumn): 34 (JSC::CodeBlock::usesOpcode): 35 (JSC::CodeBlock::valueProfileForBytecodeOffset): 36 (JSC::CodeBlock::arithProfileForPC): 37 (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler): 38 * bytecode/PreciseJumpTargets.cpp: 39 (JSC::getJumpTargetsForBytecodeOffset): 40 (JSC::computePreciseJumpTargetsInternal): 41 (JSC::findJumpTargetsForBytecodeOffset): 42 * bytecode/PreciseJumpTargetsInlines.h: 43 (JSC::extractStoredJumpTargetsForBytecodeOffset): 44 * bytecode/UnlinkedCodeBlock.cpp: 45 (JSC::UnlinkedCodeBlock::applyModification): 46 * dfg/DFGByteCodeParser.cpp: 47 (JSC::DFG::ByteCodeParser::getPredictionWithoutOSRExit): 48 (JSC::DFG::ByteCodeParser::parseBlock): 49 * dfg/DFGCapabilities.cpp: 50 (JSC::DFG::capabilityLevel): 51 * interpreter/Interpreter.cpp: 52 (JSC::Interpreter::Interpreter): 53 (JSC::Interpreter::isOpcode): 54 (): Deleted. 55 * interpreter/Interpreter.h: 56 (JSC::Interpreter::getOpcode): Deleted. 57 (JSC::Interpreter::getOpcodeID): Deleted. 58 (JSC::Interpreter::isCallBytecode): Deleted. 59 * interpreter/InterpreterInlines.h: 60 (JSC::Interpreter::getOpcode): 61 (JSC::Interpreter::getOpcodeID): 62 * jit/JIT.cpp: 63 (JSC::JIT::privateCompileMainPass): 64 (JSC::JIT::privateCompileSlowCases): 65 * jit/JITOpcodes.cpp: 66 (JSC::JIT::emitNewFuncCommon): 67 (JSC::JIT::emitNewFuncExprCommon): 68 * jit/JITPropertyAccess.cpp: 69 (JSC::JIT::emitSlow_op_put_by_val): 70 (JSC::JIT::privateCompilePutByVal): 71 * jit/JITPropertyAccess32_64.cpp: 72 (JSC::JIT::emitSlow_op_put_by_val): 73 * llint/LLIntSlowPaths.cpp: 74 (JSC::LLInt::llint_trace_operand): 75 (JSC::LLInt::llint_trace_value): 76 (JSC::LLInt::LLINT_SLOW_PATH_DECL): 77 * profiler/ProfilerBytecodeSequence.cpp: 78 (JSC::Profiler::BytecodeSequence::BytecodeSequence): 79 1 80 2017-06-16 Matt Lewis <jlewis3@apple.com> 2 81 -
trunk/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp
r209820 r218412 1 1 /* 2 * Copyright (C) 2013 , 2015Apple Inc. All rights reserved.2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 78 78 bool nextInstructionIsLeader = false; 79 79 80 Interpreter* interpreter = codeBlock->vm()->interpreter;81 80 for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount;) { 82 OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset]);81 OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset]); 83 82 unsigned opcodeLength = opcodeLengths[opcodeID]; 84 83 … … 115 114 bool fallsThrough = true; 116 115 for (unsigned bytecodeOffset = block->leaderOffset(); bytecodeOffset < block->leaderOffset() + block->totalLength();) { 117 OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset]);116 OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset]); 118 117 unsigned opcodeLength = opcodeLengths[opcodeID]; 119 118 // If we found a terminal bytecode, link to the exit block. -
trunk/Source/JavaScriptCore/bytecode/BytecodeDumper.cpp
r217840 r218412 1 1 /* 2 2 * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com> 3 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 361 362 { 362 363 const char* op; 363 switch ( vm()->interpreter->getOpcodeID(*it)) {364 switch (Interpreter::getOpcodeID(*it)) { 364 365 case op_get_by_id: 365 366 op = "get_by_id"; … … 423 424 UNUSED_PARAM(ident); // tell the compiler to shut up in certain platform configurations. 424 425 425 if ( vm()->interpreter->getOpcodeID(instruction[0]) == op_get_array_length)426 if (Interpreter::getOpcodeID(instruction[0]) == op_get_array_length) 426 427 out.printf(" llint(array_length)"); 427 428 else if (StructureID structureID = getStructureID(instruction[4])) { … … 430 431 dumpStructure(out, "struct", structure, ident); 431 432 out.printf(")"); 432 if ( vm()->interpreter->getOpcodeID(instruction[0]) == op_get_by_id_proto_load)433 if (Interpreter::getOpcodeID(instruction[0]) == op_get_by_id_proto_load) 433 434 out.printf(" proto(%p)", getPointer(instruction[6])); 434 435 } … … 612 613 int location = it - begin; 613 614 bool hasPrintedProfiling = false; 614 OpcodeID opcode = vm()->interpreter->getOpcodeID(*it);615 OpcodeID opcode = Interpreter::getOpcodeID(*it); 615 616 switch (opcode) { 616 617 case op_enter: { … … 1777 1778 void BytecodeDumper<Block>::dumpBlock(Block* block, const typename Block::UnpackedInstructions& instructions, PrintStream& out, const StubInfoMap& stubInfos, const CallLinkInfoMap& callLinkInfos) 1778 1779 { 1779 VM& vm = *block->vm();1780 1780 size_t instructionCount = 0; 1781 1781 1782 for (size_t i = 0; i < instructions.size(); i += opcodeLengths[ vm.interpreter->getOpcodeID(instructions[i])])1782 for (size_t i = 0; i < instructions.size(); i += opcodeLengths[Interpreter::getOpcodeID(instructions[i])]) 1783 1783 ++instructionCount; 1784 1784 -
trunk/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.cpp
r213209 r218412 1 1 /* 2 * Copyright (C) 2013 , 2015Apple Inc. All rights reserved.2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 140 140 CodeBlock* codeBlock = m_graph.codeBlock(); 141 141 dataLog("\nDumping bytecode liveness for ", *codeBlock, ":\n"); 142 Interpreter* interpreter = codeBlock->vm()->interpreter;143 142 Instruction* instructionsBegin = codeBlock->instructions().begin(); 144 143 unsigned i = 0; … … 197 196 codeBlock->dumpBytecode(WTF::dataFile(), instructionsBegin, currentInstruction); 198 197 199 OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode);198 OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode); 200 199 unsigned opcodeLength = opcodeLengths[opcodeID]; 201 200 bytecodeOffset += opcodeLength; -
trunk/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysisInlines.h
r205794 r218412 1 1 /* 2 * Copyright (C) 2013 , 2015Apple Inc. All rights reserved.2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #include "BytecodeLivenessAnalysis.h" 30 30 #include "CodeBlock.h" 31 #include "Interpreter .h"31 #include "InterpreterInlines.h" 32 32 #include "Operations.h" 33 33 … … 82 82 83 83 auto* codeBlock = graph.codeBlock(); 84 Interpreter* interpreter = codeBlock->vm()->interpreter;85 84 auto* instructionsBegin = graph.instructions().begin(); 86 85 auto* instruction = &instructionsBegin[bytecodeOffset]; 87 OpcodeID opcodeID = interpreter->getOpcodeID(*instruction);86 OpcodeID opcodeID = Interpreter::getOpcodeID(*instruction); 88 87 89 88 static_cast<DerivedAnalysis*>(this)->computeDefsForBytecodeOffset( -
trunk/Source/JavaScriptCore/bytecode/BytecodeRewriter.cpp
r205462 r218412 1 1 /* 2 2 * Copyright (C) 2016 Yusuke Suzuki <utatane.tea@gmail.com> 3 * Copyright (C) 2016 Apple Inc. All rights reserved.3 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 71 71 unsigned bytecodeOffset = finalOffset + fragmentOffset; 72 72 UnlinkedCodeBlock* codeBlock = m_graph.codeBlock(); 73 extractStoredJumpTargetsForBytecodeOffset(codeBlock, codeBlock->vm()->interpreter,instructionsBegin, fragmentOffset, [&](int32_t& label) {73 extractStoredJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, fragmentOffset, [&](int32_t& label) { 74 74 int absoluteOffset = adjustAbsoluteOffset(label); 75 75 label = absoluteOffset - static_cast<int>(bytecodeOffset); -
trunk/Source/JavaScriptCore/bytecode/CallLinkStatus.cpp
r208761 r218412 1 1 /* 2 * Copyright (C) 2012-201 6Apple Inc. All rights reserved.2 * Copyright (C) 2012-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 #include "DFGJITCode.h" 32 32 #include "InlineCallFrame.h" 33 #include "Interpreter .h"33 #include "InterpreterInlines.h" 34 34 #include "LLIntCallLinkInfo.h" 35 35 #include "JSCInlines.h" … … 67 67 #endif 68 68 69 VM& vm = *profiledBlock->vm();70 71 69 Instruction* instruction = profiledBlock->instructions().begin() + bytecodeIndex; 72 OpcodeID op = vm.interpreter->getOpcodeID(instruction[0].u.opcode);70 OpcodeID op = Interpreter::getOpcodeID(instruction[0].u.opcode); 73 71 if (op != op_call && op != op_construct && op != op_tail_call) 74 72 return CallLinkStatus(); -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r217108 r218412 528 528 unsigned opLength = opcodeLength(pc[0].u.opcode); 529 529 530 instructions[i] = vm.interpreter->getOpcode(pc[0].u.opcode);530 instructions[i] = Interpreter::getOpcode(pc[0].u.opcode); 531 531 for (size_t j = 1; j < opLength; ++j) { 532 532 if (sizeof(int32_t) != sizeof(intptr_t)) … … 1122 1122 bool allAreMarkedSoFar = true; 1123 1123 1124 Interpreter* interpreter = m_vm->interpreter;1125 1124 if (jitType() == JITCode::InterpreterThunk) { 1126 1125 const Vector<unsigned>& propertyAccessInstructions = m_unlinkedCode->propertyAccessInstructions(); 1127 1126 for (size_t i = 0; i < propertyAccessInstructions.size(); ++i) { 1128 1127 Instruction* instruction = &instructions()[propertyAccessInstructions[i]]; 1129 switch ( interpreter->getOpcodeID(instruction[0])) {1128 switch (Interpreter::getOpcodeID(instruction[0])) { 1130 1129 case op_put_by_id: { 1131 1130 StructureID oldStructureID = instruction[4].u.structureID; … … 1257 1256 void CodeBlock::finalizeLLIntInlineCaches() 1258 1257 { 1259 Interpreter* interpreter = m_vm->interpreter;1260 1258 const Vector<unsigned>& propertyAccessInstructions = m_unlinkedCode->propertyAccessInstructions(); 1261 1259 for (size_t size = propertyAccessInstructions.size(), i = 0; i < size; ++i) { 1262 1260 Instruction* curInstruction = &instructions()[propertyAccessInstructions[i]]; 1263 switch ( interpreter->getOpcodeID(curInstruction[0])) {1261 switch (Interpreter::getOpcodeID(curInstruction[0])) { 1264 1262 case op_get_by_id: 1265 1263 case op_get_by_id_proto_load: … … 1343 1341 } 1344 1342 default: 1345 OpcodeID opcodeID = interpreter->getOpcodeID(curInstruction[0]);1343 OpcodeID opcodeID = Interpreter::getOpcodeID(curInstruction[0]); 1346 1344 ASSERT_WITH_MESSAGE_UNUSED(opcodeID, false, "Unhandled opcode in CodeBlock::finalizeUnconditionally, %s(%d) at bc %u", opcodeNames[opcodeID], opcodeID, propertyAccessInstructions[i]); 1347 1345 } … … 1721 1719 bool CodeBlock::hasOpDebugForLineAndColumn(unsigned line, unsigned column) 1722 1720 { 1723 Interpreter* interpreter = vm()->interpreter;1724 1721 const Instruction* begin = instructions().begin(); 1725 1722 const Instruction* end = instructions().end(); 1726 1723 for (const Instruction* it = begin; it != end;) { 1727 OpcodeID opcodeID = interpreter->getOpcodeID(*it);1724 OpcodeID opcodeID = Interpreter::getOpcodeID(*it); 1728 1725 if (opcodeID == op_debug) { 1729 1726 unsigned bytecodeOffset = it - begin; … … 2667 2664 bool CodeBlock::usesOpcode(OpcodeID opcodeID) 2668 2665 { 2669 Interpreter* interpreter = vm()->interpreter;2670 2666 Instruction* instructionsBegin = instructions().begin(); 2671 2667 unsigned instructionCount = instructions().size(); 2672 2668 2673 2669 for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount; ) { 2674 switch ( interpreter->getOpcodeID(instructionsBegin[bytecodeOffset])) {2670 switch (Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset])) { 2675 2671 #define DEFINE_OP(curOpcode, length) \ 2676 2672 case curOpcode: \ … … 2717 2713 ValueProfile* CodeBlock::valueProfileForBytecodeOffset(int bytecodeOffset) 2718 2714 { 2719 OpcodeID opcodeID = m_vm->interpreter->getOpcodeID(instructions()[bytecodeOffset]);2715 OpcodeID opcodeID = Interpreter::getOpcodeID(instructions()[bytecodeOffset]); 2720 2716 unsigned length = opcodeLength(opcodeID); 2721 2717 return instructions()[bytecodeOffset + length - 1].u.profile; … … 2806 2802 ArithProfile* CodeBlock::arithProfileForPC(Instruction* pc) 2807 2803 { 2808 auto opcodeID = vm()->interpreter->getOpcodeID(pc[0]);2804 auto opcodeID = Interpreter::getOpcodeID(pc[0]); 2809 2805 switch (opcodeID) { 2810 2806 case op_negate: … … 2853 2849 // the next op_profile_control_flow will give us the text range of a single basic block. 2854 2850 size_t startIdx = bytecodeOffsets[i]; 2855 RELEASE_ASSERT( vm()->interpreter->getOpcodeID(instructions[startIdx]) == op_profile_control_flow);2851 RELEASE_ASSERT(Interpreter::getOpcodeID(instructions[startIdx]) == op_profile_control_flow); 2856 2852 int basicBlockStartOffset = instructions[startIdx + 1].u.operand; 2857 2853 int basicBlockEndOffset; 2858 2854 if (i + 1 < offsetsLength) { 2859 2855 size_t endIdx = bytecodeOffsets[i + 1]; 2860 RELEASE_ASSERT( vm()->interpreter->getOpcodeID(instructions[endIdx]) == op_profile_control_flow);2856 RELEASE_ASSERT(Interpreter::getOpcodeID(instructions[endIdx]) == op_profile_control_flow); 2861 2857 basicBlockEndOffset = instructions[endIdx + 1].u.operand - 1; 2862 2858 } else { -
trunk/Source/JavaScriptCore/bytecode/PreciseJumpTargets.cpp
r204994 r218412 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 34 34 35 35 template <size_t vectorSize, typename Block, typename Instruction> 36 static void getJumpTargetsForBytecodeOffset(Block* codeBlock, In terpreter* interpreter, Instruction* instructionsBegin, unsigned bytecodeOffset, Vector<unsigned, vectorSize>& out)36 static void getJumpTargetsForBytecodeOffset(Block* codeBlock, Instruction* instructionsBegin, unsigned bytecodeOffset, Vector<unsigned, vectorSize>& out) 37 37 { 38 OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset]);39 extractStoredJumpTargetsForBytecodeOffset(codeBlock, in terpreter, instructionsBegin, bytecodeOffset, [&](int32_t& relativeOffset) {38 OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset]); 39 extractStoredJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, bytecodeOffset, [&](int32_t& relativeOffset) { 40 40 out.append(bytecodeOffset + relativeOffset); 41 41 }); … … 66 66 } 67 67 68 Interpreter* interpreter = codeBlock->vm()->interpreter;69 68 for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount;) { 70 OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset]);71 getJumpTargetsForBytecodeOffset(codeBlock, in terpreter, instructionsBegin, bytecodeOffset, out);69 OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset]); 70 getJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, bytecodeOffset, out); 72 71 bytecodeOffset += opcodeLengths[opcodeID]; 73 72 } … … 112 111 void findJumpTargetsForBytecodeOffset(CodeBlock* codeBlock, Instruction* instructionsBegin, unsigned bytecodeOffset, Vector<unsigned, 1>& out) 113 112 { 114 getJumpTargetsForBytecodeOffset(codeBlock, codeBlock->vm()->interpreter,instructionsBegin, bytecodeOffset, out);113 getJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, bytecodeOffset, out); 115 114 } 116 115 117 116 void findJumpTargetsForBytecodeOffset(UnlinkedCodeBlock* codeBlock, UnlinkedInstruction* instructionsBegin, unsigned bytecodeOffset, Vector<unsigned, 1>& out) 118 117 { 119 getJumpTargetsForBytecodeOffset(codeBlock, codeBlock->vm()->interpreter,instructionsBegin, bytecodeOffset, out);118 getJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, bytecodeOffset, out); 120 119 } 121 120 -
trunk/Source/JavaScriptCore/bytecode/PreciseJumpTargetsInlines.h
r204994 r218412 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 34 34 template<typename Block, typename Instruction, typename Function> 35 inline void extractStoredJumpTargetsForBytecodeOffset(Block* codeBlock, In terpreter* interpreter, Instruction* instructionsBegin, unsigned bytecodeOffset, Function function)35 inline void extractStoredJumpTargetsForBytecodeOffset(Block* codeBlock, Instruction* instructionsBegin, unsigned bytecodeOffset, Function function) 36 36 { 37 OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset]);37 OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset]); 38 38 Instruction* current = instructionsBegin + bytecodeOffset; 39 39 switch (opcodeID) { -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
r217108 r218412 1 1 /* 2 * Copyright (C) 2012-201 3, 2015-2016Apple Inc. All Rights Reserved.2 * Copyright (C) 2012-2017 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 351 351 UnlinkedInstruction* current = instructionsBegin + bytecodeOffset; 352 352 OpcodeID opcodeID = current[0].u.opcode; 353 extractStoredJumpTargetsForBytecodeOffset(this, vm()->interpreter,instructionsBegin, bytecodeOffset, [&](int32_t& relativeOffset) {353 extractStoredJumpTargetsForBytecodeOffset(this, instructionsBegin, bytecodeOffset, [&](int32_t& relativeOffset) { 354 354 relativeOffset = rewriter.adjustJumpTarget(bytecodeOffset, bytecodeOffset + relativeOffset); 355 355 }); -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r218084 r218412 887 887 // to avoid a spurious OSR exit. 888 888 Instruction* instruction = m_inlineStackTop->m_profiledBlock->instructions().begin() + bytecodeIndex; 889 OpcodeID opcodeID = m_vm->interpreter->getOpcodeID(instruction->u.opcode);889 OpcodeID opcodeID = Interpreter::getOpcodeID(instruction->u.opcode); 890 890 891 891 switch (opcodeID) { … … 4063 4063 bool shouldContinueParsing = true; 4064 4064 4065 Interpreter* interpreter = m_vm->interpreter;4066 4065 Instruction* instructionsBegin = m_inlineStackTop->m_codeBlock->instructions().begin(); 4067 4066 unsigned blockBegin = m_currentIndex; … … 4116 4115 Instruction* currentInstruction = instructionsBegin + m_currentIndex; 4117 4116 m_currentInstruction = currentInstruction; // Some methods want to use this, and we'd rather not thread it through calls. 4118 OpcodeID opcodeID = interpreter->getOpcodeID(currentInstruction->u.opcode);4117 OpcodeID opcodeID = Interpreter::getOpcodeID(currentInstruction->u.opcode); 4119 4118 4120 4119 if (Options::verboseDFGByteCodeParsing()) -
trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp
r217993 r218412 31 31 #include "CodeBlock.h" 32 32 #include "DFGCommon.h" 33 #include "Interpreter .h"33 #include "InterpreterInlines.h" 34 34 #include "JSCInlines.h" 35 35 #include "Options.h" … … 270 270 CapabilityLevel capabilityLevel(CodeBlock* codeBlock) 271 271 { 272 Interpreter* interpreter = codeBlock->vm()->interpreter;273 272 Instruction* instructionsBegin = codeBlock->instructions().begin(); 274 273 unsigned instructionCount = codeBlock->instructions().size(); … … 276 275 277 276 for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount; ) { 278 switch ( interpreter->getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode)) {277 switch (Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode)) { 279 278 #define DEFINE_OP(opcode, length) \ 280 279 case opcode: { \ -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r217526 r218412 45 45 #include "ExceptionHelpers.h" 46 46 #include "FunctionCodeBlock.h" 47 #include "InterpreterInlines.h" 47 48 #include "JSArrayInlines.h" 48 49 #include "JSBoundFunction.h" … … 54 55 #include "JSWithScope.h" 55 56 #include "LLIntCLoop.h" 56 #include "LLIntData.h"57 57 #include "LLIntThunks.h" 58 58 #include "LiteralParser.h" … … 318 318 , m_cloopStack(vm) 319 319 #endif 320 #if ENABLE(COMPUTED_GOTO_OPCODES)321 , m_opcodeTable { LLInt::opcodeMap() }322 #if !USE(LLINT_EMBEDDED_OPCODE_ID) || !ASSERT_DISABLED323 , m_opcodeIDTable { opcodeIDTable() }324 #endif325 #endif326 320 { 327 321 #if !ASSERT_DISABLED 328 322 static std::once_flag assertOnceKey; 329 323 std::call_once(assertOnceKey, [this] { 330 for (unsigned i = 0; i < NUMBER_OF_BYTECODE_IDS; ++i) 331 RELEASE_ASSERT(getOpcodeID(m_opcodeTable[i]) == static_cast<OpcodeID>(i)); 324 for (unsigned i = 0; i < NUMBER_OF_BYTECODE_IDS; ++i) { 325 OpcodeID opcodeID = static_cast<OpcodeID>(i); 326 RELEASE_ASSERT(getOpcodeID(getOpcode(opcodeID)) == opcodeID); 327 } 332 328 }); 333 329 #endif // USE(LLINT_EMBEDDED_OPCODE_ID) … … 473 469 return opcode != HashTraits<Opcode>::emptyValue() 474 470 && !HashTraits<Opcode>::isDeletedValue(opcode) 475 && m_opcodeIDTable.contains(opcode);471 && opcodeIDTable().contains(opcode); 476 472 #else 477 473 return opcode >= 0 && opcode <= op_end; -
trunk/Source/JavaScriptCore/interpreter/Interpreter.h
r217526 r218412 102 102 #endif 103 103 104 Opcode getOpcode(OpcodeID id) 105 { 106 #if ENABLE(COMPUTED_GOTO_OPCODES) 107 return m_opcodeTable[id]; 108 #else 109 return id; 110 #endif 111 } 104 static inline Opcode getOpcode(OpcodeID); 112 105 113 OpcodeID getOpcodeID(Opcode opcode) 114 { 115 #if ENABLE(COMPUTED_GOTO_OPCODES) 116 ASSERT(isOpcode(opcode)); 117 #if USE(LLINT_EMBEDDED_OPCODE_ID) 118 // The OpcodeID is embedded in the int32_t word preceding the location of 119 // the LLInt code for the opcode (see the EMBED_OPCODE_ID_IF_NEEDED macro 120 // in LowLevelInterpreter.cpp). 121 MacroAssemblerCodePtr codePtr(reinterpret_cast<void*>(opcode)); 122 int32_t* opcodeIDAddress = reinterpret_cast<int32_t*>(codePtr.dataLocation()) - 1; 123 OpcodeID opcodeID = static_cast<OpcodeID>(*opcodeIDAddress); 124 ASSERT(opcodeID < NUMBER_OF_BYTECODE_IDS); 125 return opcodeID; 126 #else 127 return m_opcodeIDTable.get(opcode); 128 #endif // USE(LLINT_EMBEDDED_OPCODE_ID) 129 130 #else // not ENABLE(COMPUTED_GOTO_OPCODES) 131 return opcode; 132 #endif 133 } 134 135 OpcodeID getOpcodeID(const Instruction&); 136 OpcodeID getOpcodeID(const UnlinkedInstruction&); 106 static inline OpcodeID getOpcodeID(Opcode); 107 static inline OpcodeID getOpcodeID(const Instruction&); 108 static inline OpcodeID getOpcodeID(const UnlinkedInstruction&); 137 109 138 110 #if !ASSERT_DISABLED 139 bool isOpcode(Opcode);111 static bool isOpcode(Opcode); 140 112 #endif 141 113 … … 173 145 void dumpRegisters(CallFrame*); 174 146 175 bool isCallBytecode(Opcode opcode) { return opcode == getOpcode(op_call) || opcode == getOpcode(op_construct) || opcode == getOpcode(op_call_eval) || opcode == getOpcode(op_tail_call); }176 177 147 VM& m_vm; 178 148 #if !ENABLE(JIT) … … 181 151 182 152 #if ENABLE(COMPUTED_GOTO_OPCODES) 183 const Opcode* m_opcodeTable; // Maps OpcodeID => Opcode for compiling184 185 153 #if !USE(LLINT_EMBEDDED_OPCODE_ID) || !ASSERT_DISABLED 186 HashMap<Opcode, OpcodeID>& m_opcodeIDTable; // Maps Opcode => OpcodeID for decompiling 187 188 static HashMap<Opcode, OpcodeID>& opcodeIDTable(); 154 static HashMap<Opcode, OpcodeID>& opcodeIDTable(); // Maps Opcode => OpcodeID. 189 155 #endif // !USE(LLINT_EMBEDDED_OPCODE_ID) || !ASSERT_DISABLED 190 156 #endif // ENABLE(COMPUTED_GOTO_OPCODES) -
trunk/Source/JavaScriptCore/interpreter/InterpreterInlines.h
r204994 r218412 1 1 /* 2 2 * Copyright (C) 2016 Yusuke Suzuki <utatane.tea@gmail.com> 3 * Copyright (C) 2016 Apple Inc. All rights reserved.3 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 29 29 #include "Instruction.h" 30 30 #include "Interpreter.h" 31 #include "LLIntData.h" 31 32 #include "UnlinkedCodeBlock.h" 32 33 33 34 namespace JSC { 35 36 inline Opcode Interpreter::getOpcode(OpcodeID id) 37 { 38 return LLInt::getOpcode(id); 39 } 40 41 inline OpcodeID Interpreter::getOpcodeID(Opcode opcode) 42 { 43 #if ENABLE(COMPUTED_GOTO_OPCODES) 44 ASSERT(isOpcode(opcode)); 45 #if USE(LLINT_EMBEDDED_OPCODE_ID) 46 // The OpcodeID is embedded in the int32_t word preceding the location of 47 // the LLInt code for the opcode (see the EMBED_OPCODE_ID_IF_NEEDED macro 48 // in LowLevelInterpreter.cpp). 49 MacroAssemblerCodePtr codePtr(reinterpret_cast<void*>(opcode)); 50 int32_t* opcodeIDAddress = reinterpret_cast<int32_t*>(codePtr.dataLocation()) - 1; 51 OpcodeID opcodeID = static_cast<OpcodeID>(*opcodeIDAddress); 52 ASSERT(opcodeID < NUMBER_OF_BYTECODE_IDS); 53 return opcodeID; 54 #else 55 return opcodeIDTable().get(opcode); 56 #endif // USE(LLINT_EMBEDDED_OPCODE_ID) 57 58 #else // not ENABLE(COMPUTED_GOTO_OPCODES) 59 return opcode; 60 #endif 61 } 34 62 35 63 inline OpcodeID Interpreter::getOpcodeID(const Instruction& instruction) -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r217840 r218412 34 34 #include "CodeBlockWithJITType.h" 35 35 #include "DFGCapabilities.h" 36 #include "Interpreter .h"36 #include "InterpreterInlines.h" 37 37 #include "JITInlines.h" 38 38 #include "JITOperations.h" … … 227 227 m_disassembler->setForBytecodeMainPath(m_bytecodeOffset, label()); 228 228 Instruction* currentInstruction = instructionsBegin + m_bytecodeOffset; 229 ASSERT_WITH_MESSAGE( m_interpreter->isOpcode(currentInstruction->u.opcode), "privateCompileMainPass gone bad @ %d", m_bytecodeOffset);229 ASSERT_WITH_MESSAGE(Interpreter::isOpcode(currentInstruction->u.opcode), "privateCompileMainPass gone bad @ %d", m_bytecodeOffset); 230 230 231 231 m_pcToCodeOriginMapBuilder.appendItem(label(), CodeOrigin(m_bytecodeOffset)); … … 242 242 #endif 243 243 244 OpcodeID opcodeID = m_interpreter->getOpcodeID(currentInstruction->u.opcode);244 OpcodeID opcodeID = Interpreter::getOpcodeID(currentInstruction->u.opcode); 245 245 246 246 if (m_compilation) { … … 476 476 m_disassembler->setForBytecodeSlowPath(m_bytecodeOffset, label()); 477 477 478 switch ( m_interpreter->getOpcodeID(currentInstruction->u.opcode)) {478 switch (Interpreter::getOpcodeID(currentInstruction->u.opcode)) { 479 479 DEFINE_SLOWCASE_OP(op_add) 480 480 DEFINE_SLOWCASE_OP(op_bitand) -
trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp
r217846 r218412 32 32 #include "Exception.h" 33 33 #include "Heap.h" 34 #include "Interpreter .h"34 #include "InterpreterInlines.h" 35 35 #include "JITInlines.h" 36 36 #include "JSArray.h" … … 976 976 FunctionExecutable* funcExec = m_codeBlock->functionDecl(currentInstruction[3].u.operand); 977 977 978 OpcodeID opcodeID = m_vm->interpreter->getOpcodeID(currentInstruction->u.opcode);978 OpcodeID opcodeID = Interpreter::getOpcodeID(currentInstruction->u.opcode); 979 979 if (opcodeID == op_new_func) 980 980 callOperation(operationNewFunction, dst, regT0, funcExec); … … 1019 1019 1020 1020 FunctionExecutable* function = m_codeBlock->functionExpr(currentInstruction[3].u.operand); 1021 OpcodeID opcodeID = m_vm->interpreter->getOpcodeID(currentInstruction->u.opcode);1021 OpcodeID opcodeID = Interpreter::getOpcodeID(currentInstruction->u.opcode); 1022 1022 1023 1023 if (opcodeID == op_new_func_exp) -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp
r217202 r218412 1 1 /* 2 * Copyright (C) 2008 , 2009, 2014, 2015Apple Inc. All rights reserved.2 * Copyright (C) 2008-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 #include "GCAwareJITStubRoutine.h" 34 34 #include "GetterSetter.h" 35 #include "Interpreter .h"35 #include "InterpreterInlines.h" 36 36 #include "JITInlines.h" 37 37 #include "JSArray.h" … … 491 491 emitGetVirtualRegister(property, regT1); 492 492 emitGetVirtualRegister(value, regT2); 493 bool isDirect = m_interpreter->getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct;493 bool isDirect = Interpreter::getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct; 494 494 Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, regT0, regT1, regT2, byValInfo); 495 495 … … 1435 1435 } 1436 1436 1437 bool isDirect = m_interpreter->getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct;1437 bool isDirect = Interpreter::getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct; 1438 1438 if (!isDirect) { 1439 1439 byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB( -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
r217202 r218412 1 1 /* 2 * Copyright (C) 2008 , 2009, 2014, 2015Apple Inc. All rights reserved.2 * Copyright (C) 2008-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 #include "DirectArguments.h" 34 34 #include "GCAwareJITStubRoutine.h" 35 #include "Interpreter .h"35 #include "InterpreterInlines.h" 36 36 #include "JITInlines.h" 37 37 #include "JSArray.h" … … 551 551 Label slowPath = label(); 552 552 553 bool isDirect = m_interpreter->getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct;553 bool isDirect = Interpreter::getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct; 554 554 555 555 #if CPU(X86) -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r217944 r218412 40 40 #include "GetterSetter.h" 41 41 #include "HostCallReturnValue.h" 42 #include "Interpreter .h"42 #include "InterpreterInlines.h" 43 43 #include "IteratorOperations.h" 44 44 #include "JIT.h" … … 193 193 exec, 194 194 static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()), 195 exec->vm().interpreter->getOpcodeID(pc[0].u.opcode),195 Interpreter::getOpcodeID(pc[0].u.opcode), 196 196 fromWhere, 197 197 operand, … … 216 216 exec, 217 217 static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()), 218 exec->vm().interpreter->getOpcodeID(pc[0].u.opcode),218 Interpreter::getOpcodeID(pc[0].u.opcode), 219 219 fromWhere, 220 220 operand, … … 270 270 LLINT_SLOW_PATH_DECL(trace) 271 271 { 272 OpcodeID opcodeID = Interpreter::getOpcodeID(pc[0].u.opcode); 272 273 dataLogF("%p / %p: executing bc#%zu, %s, pc = %p\n", 273 274 exec->codeBlock(), 274 275 exec, 275 276 static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()), 276 opcodeNames[ exec->vm().interpreter->getOpcodeID(pc[0].u.opcode)], pc);277 if ( exec->vm().interpreter->getOpcodeID(pc[0].u.opcode)== op_enter) {277 opcodeNames[opcodeID], pc); 278 if (opcodeID == op_enter) { 278 279 dataLogF("Frame will eventually return to %p\n", exec->returnPC().value()); 279 280 *bitwise_cast<volatile char*>(exec->returnPC().value()); 280 281 } 281 if ( exec->vm().interpreter->getOpcodeID(pc[0].u.opcode)== op_ret) {282 if (opcodeID == op_ret) { 282 283 dataLogF("Will be returning to %p\n", exec->returnPC().value()); 283 284 dataLogF("The new cfr will be %p\n", exec->callerFrame()); … … 292 293 exec, 293 294 static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()), 294 exec->vm().interpreter->getOpcodeID(pc[0].u.opcode),295 Interpreter::getOpcodeID(pc[0].u.opcode), 295 296 exec->returnPC().value()); 296 297 LLINT_END_IMPL(); … … 1669 1670 LLINT_SLOW_PATH_DECL(count_opcode) 1670 1671 { 1671 OpcodeID opcodeID = exec->vm().interpreter->getOpcodeID(pc[0].u.opcode);1672 OpcodeID opcodeID = Interpreter::getOpcodeID(pc[0].u.opcode); 1672 1673 Data::opcodeStats(opcodeID).count++; 1673 1674 LLINT_END_IMPL(); … … 1676 1677 LLINT_SLOW_PATH_DECL(count_opcode_slow_path) 1677 1678 { 1678 OpcodeID opcodeID = exec->vm().interpreter->getOpcodeID(pc[0].u.opcode);1679 OpcodeID opcodeID = Interpreter::getOpcodeID(pc[0].u.opcode); 1679 1680 Data::opcodeStats(opcodeID).slowPathCount++; 1680 1681 LLINT_END_IMPL(); -
trunk/Source/JavaScriptCore/profiler/ProfilerBytecodeSequence.cpp
r208968 r218412 1 1 /* 2 * Copyright (C) 2012-201 4, 2016Apple Inc. All rights reserved.2 * Copyright (C) 2012-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 29 29 #include "CodeBlock.h" 30 #include "Interpreter .h"30 #include "InterpreterInlines.h" 31 31 #include "JSCInlines.h" 32 32 #include "JSGlobalObject.h" … … 56 56 out.reset(); 57 57 codeBlock->dumpBytecode(out, bytecodeIndex, stubInfos); 58 m_sequence.append(Bytecode(bytecodeIndex, codeBlock->vm()->interpreter->getOpcodeID(codeBlock->instructions()[bytecodeIndex].u.opcode), out.toCString())); 59 bytecodeIndex += opcodeLength( 60 codeBlock->vm()->interpreter->getOpcodeID( 61 codeBlock->instructions()[bytecodeIndex].u.opcode)); 58 OpcodeID opcodeID = Interpreter::getOpcodeID(codeBlock->instructions()[bytecodeIndex].u.opcode); 59 m_sequence.append(Bytecode(bytecodeIndex, opcodeID, out.toCString())); 60 bytecodeIndex += opcodeLength(opcodeID); 62 61 } 63 62 }
Note:
See TracChangeset
for help on using the changeset viewer.