Ignore:
Timestamp:
Feb 10, 2009, 12:43:32 AM (16 years ago)
Author:
[email protected]
Message:

2009-02-09 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Provide a class type for a generated block of JIT code.
Also changes the return address -> bytecode index map to
track the return addess as an unsigned offset into the code
instead of a ptrdiff_t in terms of voids - the latter is
equal to the actual offset / sizeof(void*), making it a
potentially lossy representation.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::PatchBuffer::returnAddressOffset):
  • assembler/X86Assembler.h: (JSC::X86Assembler::getCallReturnOffset):
  • bytecode/CodeBlock.h: (JSC::CallReturnOffsetToBytecodeIndex::CallReturnOffsetToBytecodeIndex): (JSC::getCallReturnOffset): (JSC::CodeBlock::getBytecodeIndex): (JSC::CodeBlock::jitCode): (JSC::CodeBlock::callReturnIndexVector):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::execute): (JSC::Interpreter::cti_vm_dontLazyLinkCall): (JSC::Interpreter::cti_vm_lazyLinkCall):
  • jit/JIT.cpp: (JSC::JIT::privateCompile):
  • jit/JIT.h: (JSC::):
  • jit/JITCall.cpp: (JSC::JIT::linkCall):
  • jit/JITCode.h: Added. (JSC::): (JSC::JITCode::JITCode): (JSC::JITCode::operator bool): (JSC::JITCode::addressForCall): (JSC::JITCode::offsetOf): (JSC::JITCode::execute):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecode/CodeBlock.h

    r40046 r40813  
    3333#include "EvalCodeCache.h"
    3434#include "Instruction.h"
     35#include "JITCode.h"
    3536#include "JSGlobalObject.h"
    3637#include "JumpTable.h"
     
    6667    // The code, and the associated pool from which it was allocated.
    6768    struct JITCodeRef {
    68         void* code;
     69        JITCode code;
    6970#ifndef NDEBUG
    7071        unsigned codeSize;
     
    162163    };
    163164
    164     struct PC {
    165         PC(ptrdiff_t nativePCOffset, unsigned bytecodeIndex)
    166             : nativePCOffset(nativePCOffset)
     165    // This structure is used to map from a call return location
     166    // (given as an offset in bytes into the JIT code) back to
     167    // the bytecode index of the corresponding bytecode operation.
     168    // This is then used to look up the corresponding handler.
     169    struct CallReturnOffsetToBytecodeIndex {
     170        CallReturnOffsetToBytecodeIndex(unsigned callReturnOffset, unsigned bytecodeIndex)
     171            : callReturnOffset(callReturnOffset)
    167172            , bytecodeIndex(bytecodeIndex)
    168173        {
    169174        }
    170175
    171         ptrdiff_t nativePCOffset;
     176        unsigned callReturnOffset;
    172177        unsigned bytecodeIndex;
    173178    };
     
    185190    }
    186191
    187     inline ptrdiff_t getNativePCOffset(PC* pc)
     192    inline unsigned getCallReturnOffset(CallReturnOffsetToBytecodeIndex* pc)
    188193    {
    189         return pc->nativePCOffset;
     194        return pc->callReturnOffset;
    190195    }
    191196
     
    312317        {
    313318            reparseForExceptionInfoIfNecessary(callFrame);
    314             ptrdiff_t nativePCOffset = reinterpret_cast<void**>(nativePC) - reinterpret_cast<void**>(m_jitCode.code);
    315             return binaryChop<PC, ptrdiff_t, getNativePCOffset>(m_exceptionInfo->m_pcVector.begin(), m_exceptionInfo->m_pcVector.size(), nativePCOffset)->bytecodeIndex;
     319            return binaryChop<CallReturnOffsetToBytecodeIndex, unsigned, getCallReturnOffset>(m_exceptionInfo->m_callReturnIndexVector.begin(), m_exceptionInfo->m_callReturnIndexVector.size(), m_jitCode.code.offsetOf(nativePC))->bytecodeIndex;
    316320        }
    317321
     
    326330#if ENABLE(JIT)
    327331        void setJITCode(JITCodeRef& jitCode);
    328         void* jitCode() { return m_jitCode.code; }
     332        JITCode jitCode() { return m_jitCode.code; }
    329333        ExecutablePool* executablePool() { return m_jitCode.executablePool.get(); }
    330334#endif
     
    391395
    392396#if ENABLE(JIT)
    393         Vector<PC>& pcVector() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_pcVector; }
     397        Vector<CallReturnOffsetToBytecodeIndex>& callReturnIndexVector() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_callReturnIndexVector; }
    394398#endif
    395399
     
    511515
    512516#if ENABLE(JIT)
    513             Vector<PC> m_pcVector;
     517            Vector<CallReturnOffsetToBytecodeIndex> m_callReturnIndexVector;
    514518#endif
    515519        };
Note: See TracChangeset for help on using the changeset viewer.