Changeset 218412 in webkit


Ignore:
Timestamp:
Jun 16, 2017 2:02:37 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

Interpreter methods for mapping between Opcode and OpcodeID need not be instance methods.
https://bugs.webkit.org/show_bug.cgi?id=173491

Reviewed by Keith Miller.

The implementation are based on static data. There's no need to get the
interpreter instance. Hence, we can make these methods static and avoid doing
unnecessary work to compute the interpreter this pointer.

Also removed the unused isCallBytecode method.

  • bytecode/BytecodeBasicBlock.cpp:

(JSC::BytecodeBasicBlock::computeImpl):

  • bytecode/BytecodeDumper.cpp:

(JSC::BytecodeDumper<Block>::printGetByIdOp):
(JSC::BytecodeDumper<Block>::printGetByIdCacheStatus):
(JSC::BytecodeDumper<Block>::dumpBytecode):
(JSC::BytecodeDumper<Block>::dumpBlock):

  • bytecode/BytecodeLivenessAnalysis.cpp:

(JSC::BytecodeLivenessAnalysis::dumpResults):

  • bytecode/BytecodeLivenessAnalysisInlines.h:

(JSC::BytecodeLivenessPropagation<DerivedAnalysis>::stepOverInstruction):

  • bytecode/BytecodeRewriter.cpp:

(JSC::BytecodeRewriter::adjustJumpTargetsInFragment):

  • bytecode/CallLinkStatus.cpp:

(JSC::CallLinkStatus::computeFromLLInt):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::finishCreation):
(JSC::CodeBlock::propagateTransitions):
(JSC::CodeBlock::finalizeLLIntInlineCaches):
(JSC::CodeBlock::hasOpDebugForLineAndColumn):
(JSC::CodeBlock::usesOpcode):
(JSC::CodeBlock::valueProfileForBytecodeOffset):
(JSC::CodeBlock::arithProfileForPC):
(JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler):

  • bytecode/PreciseJumpTargets.cpp:

(JSC::getJumpTargetsForBytecodeOffset):
(JSC::computePreciseJumpTargetsInternal):
(JSC::findJumpTargetsForBytecodeOffset):

  • bytecode/PreciseJumpTargetsInlines.h:

(JSC::extractStoredJumpTargetsForBytecodeOffset):

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::UnlinkedCodeBlock::applyModification):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::getPredictionWithoutOSRExit):
(JSC::DFG::ByteCodeParser::parseBlock):

  • dfg/DFGCapabilities.cpp:

(JSC::DFG::capabilityLevel):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::Interpreter):
(JSC::Interpreter::isOpcode):
(): Deleted.

  • interpreter/Interpreter.h:

(JSC::Interpreter::getOpcode): Deleted.
(JSC::Interpreter::getOpcodeID): Deleted.
(JSC::Interpreter::isCallBytecode): Deleted.

  • interpreter/InterpreterInlines.h:

(JSC::Interpreter::getOpcode):
(JSC::Interpreter::getOpcodeID):

  • jit/JIT.cpp:

(JSC::JIT::privateCompileMainPass):
(JSC::JIT::privateCompileSlowCases):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emitNewFuncCommon):
(JSC::JIT::emitNewFuncExprCommon):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::emitSlow_op_put_by_val):
(JSC::JIT::privateCompilePutByVal):

  • jit/JITPropertyAccess32_64.cpp:

(JSC::JIT::emitSlow_op_put_by_val):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::llint_trace_operand):
(JSC::LLInt::llint_trace_value):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • profiler/ProfilerBytecodeSequence.cpp:

(JSC::Profiler::BytecodeSequence::BytecodeSequence):

Location:
trunk/Source/JavaScriptCore
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r218395 r218412  
     12017-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
    1802017-06-16  Matt Lewis  <jlewis3@apple.com>
    281
  • trunk/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp

    r209820 r218412  
    11/*
    2  * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7878    bool nextInstructionIsLeader = false;
    7979
    80     Interpreter* interpreter = codeBlock->vm()->interpreter;
    8180    for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount;) {
    82         OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset]);
     81        OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset]);
    8382        unsigned opcodeLength = opcodeLengths[opcodeID];
    8483
     
    115114        bool fallsThrough = true;
    116115        for (unsigned bytecodeOffset = block->leaderOffset(); bytecodeOffset < block->leaderOffset() + block->totalLength();) {
    117             OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset]);
     116            OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset]);
    118117            unsigned opcodeLength = opcodeLengths[opcodeID];
    119118            // If we found a terminal bytecode, link to the exit block.
  • trunk/Source/JavaScriptCore/bytecode/BytecodeDumper.cpp

    r217840 r218412  
    11/*
    22 * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
     3 * Copyright (C) 2017 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    361362{
    362363    const char* op;
    363     switch (vm()->interpreter->getOpcodeID(*it)) {
     364    switch (Interpreter::getOpcodeID(*it)) {
    364365    case op_get_by_id:
    365366        op = "get_by_id";
     
    423424    UNUSED_PARAM(ident); // tell the compiler to shut up in certain platform configurations.
    424425
    425     if (vm()->interpreter->getOpcodeID(instruction[0]) == op_get_array_length)
     426    if (Interpreter::getOpcodeID(instruction[0]) == op_get_array_length)
    426427        out.printf(" llint(array_length)");
    427428    else if (StructureID structureID = getStructureID(instruction[4])) {
     
    430431        dumpStructure(out, "struct", structure, ident);
    431432        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)
    433434            out.printf(" proto(%p)", getPointer(instruction[6]));
    434435    }
     
    612613    int location = it - begin;
    613614    bool hasPrintedProfiling = false;
    614     OpcodeID opcode = vm()->interpreter->getOpcodeID(*it);
     615    OpcodeID opcode = Interpreter::getOpcodeID(*it);
    615616    switch (opcode) {
    616617    case op_enter: {
     
    17771778void BytecodeDumper<Block>::dumpBlock(Block* block, const typename Block::UnpackedInstructions& instructions, PrintStream& out, const StubInfoMap& stubInfos, const CallLinkInfoMap& callLinkInfos)
    17781779{
    1779     VM& vm = *block->vm();
    17801780    size_t instructionCount = 0;
    17811781
    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])])
    17831783        ++instructionCount;
    17841784
  • trunk/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.cpp

    r213209 r218412  
    11/*
    2  * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    140140    CodeBlock* codeBlock = m_graph.codeBlock();
    141141    dataLog("\nDumping bytecode liveness for ", *codeBlock, ":\n");
    142     Interpreter* interpreter = codeBlock->vm()->interpreter;
    143142    Instruction* instructionsBegin = codeBlock->instructions().begin();
    144143    unsigned i = 0;
     
    197196            codeBlock->dumpBytecode(WTF::dataFile(), instructionsBegin, currentInstruction);
    198197
    199             OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode);
     198            OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode);
    200199            unsigned opcodeLength = opcodeLengths[opcodeID];
    201200            bytecodeOffset += opcodeLength;
  • trunk/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysisInlines.h

    r205794 r218412  
    11/*
    2  * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929#include "BytecodeLivenessAnalysis.h"
    3030#include "CodeBlock.h"
    31 #include "Interpreter.h"
     31#include "InterpreterInlines.h"
    3232#include "Operations.h"
    3333
     
    8282
    8383    auto* codeBlock = graph.codeBlock();
    84     Interpreter* interpreter = codeBlock->vm()->interpreter;
    8584    auto* instructionsBegin = graph.instructions().begin();
    8685    auto* instruction = &instructionsBegin[bytecodeOffset];
    87     OpcodeID opcodeID = interpreter->getOpcodeID(*instruction);
     86    OpcodeID opcodeID = Interpreter::getOpcodeID(*instruction);
    8887
    8988    static_cast<DerivedAnalysis*>(this)->computeDefsForBytecodeOffset(
  • trunk/Source/JavaScriptCore/bytecode/BytecodeRewriter.cpp

    r205462 r218412  
    11/*
    22 * 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.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    7171            unsigned bytecodeOffset = finalOffset + fragmentOffset;
    7272            UnlinkedCodeBlock* codeBlock = m_graph.codeBlock();
    73             extractStoredJumpTargetsForBytecodeOffset(codeBlock, codeBlock->vm()->interpreter, instructionsBegin, fragmentOffset, [&](int32_t& label) {
     73            extractStoredJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, fragmentOffset, [&](int32_t& label) {
    7474                int absoluteOffset = adjustAbsoluteOffset(label);
    7575                label = absoluteOffset - static_cast<int>(bytecodeOffset);
  • trunk/Source/JavaScriptCore/bytecode/CallLinkStatus.cpp

    r208761 r218412  
    11/*
    2  * Copyright (C) 2012-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131#include "DFGJITCode.h"
    3232#include "InlineCallFrame.h"
    33 #include "Interpreter.h"
     33#include "InterpreterInlines.h"
    3434#include "LLIntCallLinkInfo.h"
    3535#include "JSCInlines.h"
     
    6767#endif
    6868
    69     VM& vm = *profiledBlock->vm();
    70    
    7169    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);
    7371    if (op != op_call && op != op_construct && op != op_tail_call)
    7472        return CallLinkStatus();
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r217108 r218412  
    528528        unsigned opLength = opcodeLength(pc[0].u.opcode);
    529529
    530         instructions[i] = vm.interpreter->getOpcode(pc[0].u.opcode);
     530        instructions[i] = Interpreter::getOpcode(pc[0].u.opcode);
    531531        for (size_t j = 1; j < opLength; ++j) {
    532532            if (sizeof(int32_t) != sizeof(intptr_t))
     
    11221122    bool allAreMarkedSoFar = true;
    11231123       
    1124     Interpreter* interpreter = m_vm->interpreter;
    11251124    if (jitType() == JITCode::InterpreterThunk) {
    11261125        const Vector<unsigned>& propertyAccessInstructions = m_unlinkedCode->propertyAccessInstructions();
    11271126        for (size_t i = 0; i < propertyAccessInstructions.size(); ++i) {
    11281127            Instruction* instruction = &instructions()[propertyAccessInstructions[i]];
    1129             switch (interpreter->getOpcodeID(instruction[0])) {
     1128            switch (Interpreter::getOpcodeID(instruction[0])) {
    11301129            case op_put_by_id: {
    11311130                StructureID oldStructureID = instruction[4].u.structureID;
     
    12571256void CodeBlock::finalizeLLIntInlineCaches()
    12581257{
    1259     Interpreter* interpreter = m_vm->interpreter;
    12601258    const Vector<unsigned>& propertyAccessInstructions = m_unlinkedCode->propertyAccessInstructions();
    12611259    for (size_t size = propertyAccessInstructions.size(), i = 0; i < size; ++i) {
    12621260        Instruction* curInstruction = &instructions()[propertyAccessInstructions[i]];
    1263         switch (interpreter->getOpcodeID(curInstruction[0])) {
     1261        switch (Interpreter::getOpcodeID(curInstruction[0])) {
    12641262        case op_get_by_id:
    12651263        case op_get_by_id_proto_load:
     
    13431341        }
    13441342        default:
    1345             OpcodeID opcodeID = interpreter->getOpcodeID(curInstruction[0]);
     1343            OpcodeID opcodeID = Interpreter::getOpcodeID(curInstruction[0]);
    13461344            ASSERT_WITH_MESSAGE_UNUSED(opcodeID, false, "Unhandled opcode in CodeBlock::finalizeUnconditionally, %s(%d) at bc %u", opcodeNames[opcodeID], opcodeID, propertyAccessInstructions[i]);
    13471345        }
     
    17211719bool CodeBlock::hasOpDebugForLineAndColumn(unsigned line, unsigned column)
    17221720{
    1723     Interpreter* interpreter = vm()->interpreter;
    17241721    const Instruction* begin = instructions().begin();
    17251722    const Instruction* end = instructions().end();
    17261723    for (const Instruction* it = begin; it != end;) {
    1727         OpcodeID opcodeID = interpreter->getOpcodeID(*it);
     1724        OpcodeID opcodeID = Interpreter::getOpcodeID(*it);
    17281725        if (opcodeID == op_debug) {
    17291726            unsigned bytecodeOffset = it - begin;
     
    26672664bool CodeBlock::usesOpcode(OpcodeID opcodeID)
    26682665{
    2669     Interpreter* interpreter = vm()->interpreter;
    26702666    Instruction* instructionsBegin = instructions().begin();
    26712667    unsigned instructionCount = instructions().size();
    26722668   
    26732669    for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount; ) {
    2674         switch (interpreter->getOpcodeID(instructionsBegin[bytecodeOffset])) {
     2670        switch (Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset])) {
    26752671#define DEFINE_OP(curOpcode, length)        \
    26762672        case curOpcode:                     \
     
    27172713ValueProfile* CodeBlock::valueProfileForBytecodeOffset(int bytecodeOffset)
    27182714{
    2719     OpcodeID opcodeID = m_vm->interpreter->getOpcodeID(instructions()[bytecodeOffset]);
     2715    OpcodeID opcodeID = Interpreter::getOpcodeID(instructions()[bytecodeOffset]);
    27202716    unsigned length = opcodeLength(opcodeID);
    27212717    return instructions()[bytecodeOffset + length - 1].u.profile;
     
    28062802ArithProfile* CodeBlock::arithProfileForPC(Instruction* pc)
    28072803{
    2808     auto opcodeID = vm()->interpreter->getOpcodeID(pc[0]);
     2804    auto opcodeID = Interpreter::getOpcodeID(pc[0]);
    28092805    switch (opcodeID) {
    28102806    case op_negate:
     
    28532849        // the next op_profile_control_flow will give us the text range of a single basic block.
    28542850        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);
    28562852        int basicBlockStartOffset = instructions[startIdx + 1].u.operand;
    28572853        int basicBlockEndOffset;
    28582854        if (i + 1 < offsetsLength) {
    28592855            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);
    28612857            basicBlockEndOffset = instructions[endIdx + 1].u.operand - 1;
    28622858        } else {
  • trunk/Source/JavaScriptCore/bytecode/PreciseJumpTargets.cpp

    r204994 r218412  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3434
    3535template <size_t vectorSize, typename Block, typename Instruction>
    36 static void getJumpTargetsForBytecodeOffset(Block* codeBlock, Interpreter* interpreter, Instruction* instructionsBegin, unsigned bytecodeOffset, Vector<unsigned, vectorSize>& out)
     36static void getJumpTargetsForBytecodeOffset(Block* codeBlock, Instruction* instructionsBegin, unsigned bytecodeOffset, Vector<unsigned, vectorSize>& out)
    3737{
    38     OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset]);
    39     extractStoredJumpTargetsForBytecodeOffset(codeBlock, interpreter, instructionsBegin, bytecodeOffset, [&](int32_t& relativeOffset) {
     38    OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset]);
     39    extractStoredJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, bytecodeOffset, [&](int32_t& relativeOffset) {
    4040        out.append(bytecodeOffset + relativeOffset);
    4141    });
     
    6666    }
    6767
    68     Interpreter* interpreter = codeBlock->vm()->interpreter;
    6968    for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount;) {
    70         OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset]);
    71         getJumpTargetsForBytecodeOffset(codeBlock, interpreter, instructionsBegin, bytecodeOffset, out);
     69        OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset]);
     70        getJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, bytecodeOffset, out);
    7271        bytecodeOffset += opcodeLengths[opcodeID];
    7372    }
     
    112111void findJumpTargetsForBytecodeOffset(CodeBlock* codeBlock, Instruction* instructionsBegin, unsigned bytecodeOffset, Vector<unsigned, 1>& out)
    113112{
    114     getJumpTargetsForBytecodeOffset(codeBlock, codeBlock->vm()->interpreter, instructionsBegin, bytecodeOffset, out);
     113    getJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, bytecodeOffset, out);
    115114}
    116115
    117116void findJumpTargetsForBytecodeOffset(UnlinkedCodeBlock* codeBlock, UnlinkedInstruction* instructionsBegin, unsigned bytecodeOffset, Vector<unsigned, 1>& out)
    118117{
    119     getJumpTargetsForBytecodeOffset(codeBlock, codeBlock->vm()->interpreter, instructionsBegin, bytecodeOffset, out);
     118    getJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, bytecodeOffset, out);
    120119}
    121120
  • trunk/Source/JavaScriptCore/bytecode/PreciseJumpTargetsInlines.h

    r204994 r218412  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333
    3434template<typename Block, typename Instruction, typename Function>
    35 inline void extractStoredJumpTargetsForBytecodeOffset(Block* codeBlock, Interpreter* interpreter, Instruction* instructionsBegin, unsigned bytecodeOffset, Function function)
     35inline void extractStoredJumpTargetsForBytecodeOffset(Block* codeBlock, Instruction* instructionsBegin, unsigned bytecodeOffset, Function function)
    3636{
    37     OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset]);
     37    OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset]);
    3838    Instruction* current = instructionsBegin + bytecodeOffset;
    3939    switch (opcodeID) {
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp

    r217108 r218412  
    11/*
    2  * Copyright (C) 2012-2013, 2015-2016 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2012-2017 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    351351        UnlinkedInstruction* current = instructionsBegin + bytecodeOffset;
    352352        OpcodeID opcodeID = current[0].u.opcode;
    353         extractStoredJumpTargetsForBytecodeOffset(this, vm()->interpreter, instructionsBegin, bytecodeOffset, [&](int32_t& relativeOffset) {
     353        extractStoredJumpTargetsForBytecodeOffset(this, instructionsBegin, bytecodeOffset, [&](int32_t& relativeOffset) {
    354354            relativeOffset = rewriter.adjustJumpTarget(bytecodeOffset, bytecodeOffset + relativeOffset);
    355355        });
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r218084 r218412  
    887887        // to avoid a spurious OSR exit.
    888888        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);
    890890
    891891        switch (opcodeID) {
     
    40634063    bool shouldContinueParsing = true;
    40644064
    4065     Interpreter* interpreter = m_vm->interpreter;
    40664065    Instruction* instructionsBegin = m_inlineStackTop->m_codeBlock->instructions().begin();
    40674066    unsigned blockBegin = m_currentIndex;
     
    41164115        Instruction* currentInstruction = instructionsBegin + m_currentIndex;
    41174116        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);
    41194118       
    41204119        if (Options::verboseDFGByteCodeParsing())
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp

    r217993 r218412  
    3131#include "CodeBlock.h"
    3232#include "DFGCommon.h"
    33 #include "Interpreter.h"
     33#include "InterpreterInlines.h"
    3434#include "JSCInlines.h"
    3535#include "Options.h"
     
    270270CapabilityLevel capabilityLevel(CodeBlock* codeBlock)
    271271{
    272     Interpreter* interpreter = codeBlock->vm()->interpreter;
    273272    Instruction* instructionsBegin = codeBlock->instructions().begin();
    274273    unsigned instructionCount = codeBlock->instructions().size();
     
    276275   
    277276    for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount; ) {
    278         switch (interpreter->getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode)) {
     277        switch (Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode)) {
    279278#define DEFINE_OP(opcode, length) \
    280279        case opcode: { \
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r217526 r218412  
    4545#include "ExceptionHelpers.h"
    4646#include "FunctionCodeBlock.h"
     47#include "InterpreterInlines.h"
    4748#include "JSArrayInlines.h"
    4849#include "JSBoundFunction.h"
     
    5455#include "JSWithScope.h"
    5556#include "LLIntCLoop.h"
    56 #include "LLIntData.h"
    5757#include "LLIntThunks.h"
    5858#include "LiteralParser.h"
     
    318318    , m_cloopStack(vm)
    319319#endif
    320 #if ENABLE(COMPUTED_GOTO_OPCODES)
    321     , m_opcodeTable { LLInt::opcodeMap() }
    322 #if !USE(LLINT_EMBEDDED_OPCODE_ID) || !ASSERT_DISABLED
    323     , m_opcodeIDTable { opcodeIDTable() }
    324 #endif
    325 #endif
    326320{
    327321#if !ASSERT_DISABLED
    328322    static std::once_flag assertOnceKey;
    329323    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        }
    332328    });
    333329#endif // USE(LLINT_EMBEDDED_OPCODE_ID)
     
    473469    return opcode != HashTraits<Opcode>::emptyValue()
    474470        && !HashTraits<Opcode>::isDeletedValue(opcode)
    475         && m_opcodeIDTable.contains(opcode);
     471        && opcodeIDTable().contains(opcode);
    476472#else
    477473    return opcode >= 0 && opcode <= op_end;
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.h

    r217526 r218412  
    102102#endif
    103103       
    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);
    112105
    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&);
    137109
    138110#if !ASSERT_DISABLED
    139         bool isOpcode(Opcode);
     111        static bool isOpcode(Opcode);
    140112#endif
    141113
     
    173145        void dumpRegisters(CallFrame*);
    174146       
    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 
    177147        VM& m_vm;
    178148#if !ENABLE(JIT)
     
    181151       
    182152#if ENABLE(COMPUTED_GOTO_OPCODES)
    183         const Opcode* m_opcodeTable; // Maps OpcodeID => Opcode for compiling
    184 
    185153#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.
    189155#endif // !USE(LLINT_EMBEDDED_OPCODE_ID) || !ASSERT_DISABLED
    190156#endif // ENABLE(COMPUTED_GOTO_OPCODES)
  • trunk/Source/JavaScriptCore/interpreter/InterpreterInlines.h

    r204994 r218412  
    11/*
    22 * 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.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    2929#include "Instruction.h"
    3030#include "Interpreter.h"
     31#include "LLIntData.h"
    3132#include "UnlinkedCodeBlock.h"
    3233
    3334namespace JSC {
     35
     36inline Opcode Interpreter::getOpcode(OpcodeID id)
     37{
     38    return LLInt::getOpcode(id);
     39}
     40
     41inline 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}
    3462
    3563inline OpcodeID Interpreter::getOpcodeID(const Instruction& instruction)
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r217840 r218412  
    3434#include "CodeBlockWithJITType.h"
    3535#include "DFGCapabilities.h"
    36 #include "Interpreter.h"
     36#include "InterpreterInlines.h"
    3737#include "JITInlines.h"
    3838#include "JITOperations.h"
     
    227227            m_disassembler->setForBytecodeMainPath(m_bytecodeOffset, label());
    228228        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);
    230230
    231231        m_pcToCodeOriginMapBuilder.appendItem(label(), CodeOrigin(m_bytecodeOffset));
     
    242242#endif
    243243       
    244         OpcodeID opcodeID = m_interpreter->getOpcodeID(currentInstruction->u.opcode);
     244        OpcodeID opcodeID = Interpreter::getOpcodeID(currentInstruction->u.opcode);
    245245
    246246        if (m_compilation) {
     
    476476            m_disassembler->setForBytecodeSlowPath(m_bytecodeOffset, label());
    477477
    478         switch (m_interpreter->getOpcodeID(currentInstruction->u.opcode)) {
     478        switch (Interpreter::getOpcodeID(currentInstruction->u.opcode)) {
    479479        DEFINE_SLOWCASE_OP(op_add)
    480480        DEFINE_SLOWCASE_OP(op_bitand)
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r217846 r218412  
    3232#include "Exception.h"
    3333#include "Heap.h"
    34 #include "Interpreter.h"
     34#include "InterpreterInlines.h"
    3535#include "JITInlines.h"
    3636#include "JSArray.h"
     
    976976    FunctionExecutable* funcExec = m_codeBlock->functionDecl(currentInstruction[3].u.operand);
    977977
    978     OpcodeID opcodeID = m_vm->interpreter->getOpcodeID(currentInstruction->u.opcode);
     978    OpcodeID opcodeID = Interpreter::getOpcodeID(currentInstruction->u.opcode);
    979979    if (opcodeID == op_new_func)
    980980        callOperation(operationNewFunction, dst, regT0, funcExec);
     
    10191019       
    10201020    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);
    10221022
    10231023    if (opcodeID == op_new_func_exp)
  • trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp

    r217202 r218412  
    11/*
    2  * Copyright (C) 2008, 2009, 2014, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333#include "GCAwareJITStubRoutine.h"
    3434#include "GetterSetter.h"
    35 #include "Interpreter.h"
     35#include "InterpreterInlines.h"
    3636#include "JITInlines.h"
    3737#include "JSArray.h"
     
    491491    emitGetVirtualRegister(property, regT1);
    492492    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;
    494494    Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, regT0, regT1, regT2, byValInfo);
    495495
     
    14351435    }
    14361436   
    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;
    14381438    if (!isDirect) {
    14391439        byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
  • trunk/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp

    r217202 r218412  
    11/*
    2  * Copyright (C) 2008, 2009, 2014, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333#include "DirectArguments.h"
    3434#include "GCAwareJITStubRoutine.h"
    35 #include "Interpreter.h"
     35#include "InterpreterInlines.h"
    3636#include "JITInlines.h"
    3737#include "JSArray.h"
     
    551551    Label slowPath = label();
    552552   
    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;
    554554
    555555#if CPU(X86)
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r217944 r218412  
    4040#include "GetterSetter.h"
    4141#include "HostCallReturnValue.h"
    42 #include "Interpreter.h"
     42#include "InterpreterInlines.h"
    4343#include "IteratorOperations.h"
    4444#include "JIT.h"
     
    193193            exec,
    194194            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),
    196196            fromWhere,
    197197            operand,
     
    216216        exec,
    217217        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),
    219219        fromWhere,
    220220        operand,
     
    270270LLINT_SLOW_PATH_DECL(trace)
    271271{
     272    OpcodeID opcodeID = Interpreter::getOpcodeID(pc[0].u.opcode);
    272273    dataLogF("%p / %p: executing bc#%zu, %s, pc = %p\n",
    273274            exec->codeBlock(),
    274275            exec,
    275276            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) {
    278279        dataLogF("Frame will eventually return to %p\n", exec->returnPC().value());
    279280        *bitwise_cast<volatile char*>(exec->returnPC().value());
    280281    }
    281     if (exec->vm().interpreter->getOpcodeID(pc[0].u.opcode) == op_ret) {
     282    if (opcodeID == op_ret) {
    282283        dataLogF("Will be returning to %p\n", exec->returnPC().value());
    283284        dataLogF("The new cfr will be %p\n", exec->callerFrame());
     
    292293            exec,
    293294            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),
    295296            exec->returnPC().value());
    296297    LLINT_END_IMPL();
     
    16691670LLINT_SLOW_PATH_DECL(count_opcode)
    16701671{
    1671     OpcodeID opcodeID = exec->vm().interpreter->getOpcodeID(pc[0].u.opcode);
     1672    OpcodeID opcodeID = Interpreter::getOpcodeID(pc[0].u.opcode);
    16721673    Data::opcodeStats(opcodeID).count++;
    16731674    LLINT_END_IMPL();
     
    16761677LLINT_SLOW_PATH_DECL(count_opcode_slow_path)
    16771678{
    1678     OpcodeID opcodeID = exec->vm().interpreter->getOpcodeID(pc[0].u.opcode);
     1679    OpcodeID opcodeID = Interpreter::getOpcodeID(pc[0].u.opcode);
    16791680    Data::opcodeStats(opcodeID).slowPathCount++;
    16801681    LLINT_END_IMPL();
  • trunk/Source/JavaScriptCore/profiler/ProfilerBytecodeSequence.cpp

    r208968 r218412  
    11/*
    2  * Copyright (C) 2012-2014, 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828
    2929#include "CodeBlock.h"
    30 #include "Interpreter.h"
     30#include "InterpreterInlines.h"
    3131#include "JSCInlines.h"
    3232#include "JSGlobalObject.h"
     
    5656        out.reset();
    5757        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);
    6261    }
    6362}
Note: See TracChangeset for help on using the changeset viewer.