diff options
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.h')
-rw-r--r-- | src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.h | 144 |
1 files changed, 84 insertions, 60 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.h b/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.h index 517bd27..ac29c6c 100644 --- a/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.h +++ b/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.h @@ -32,6 +32,7 @@ #include "EvalCodeCache.h" #include "Instruction.h" +#include "JITCode.h" #include "JSGlobalObject.h" #include "JumpTable.h" #include "Nodes.h" @@ -58,29 +59,10 @@ namespace JSC { uint32_t target; uint32_t scopeDepth; #if ENABLE(JIT) - void* nativeCode; + MacroAssembler::CodeLocationLabel nativeCode; #endif }; -#if ENABLE(JIT) - // The code, and the associated pool from which it was allocated. - struct JITCodeRef { - void* code; - RefPtr<ExecutablePool> executablePool; - - JITCodeRef() - : code(0) - { - } - - JITCodeRef(void* code, PassRefPtr<ExecutablePool> executablePool) - : code(code) - , executablePool(executablePool) - { - } - }; -#endif - struct ExpressionRangeInfo { enum { MaxOffset = (1 << 7) - 1, @@ -108,19 +90,15 @@ namespace JSC { #if ENABLE(JIT) struct CallLinkInfo { CallLinkInfo() - : callReturnLocation(0) - , hotPathBegin(0) - , hotPathOther(0) - , coldPathOther(0) - , callee(0) + : callee(0) { } unsigned bytecodeIndex; - void* callReturnLocation; - void* hotPathBegin; - void* hotPathOther; - void* coldPathOther; + MacroAssembler::CodeLocationNearCall callReturnLocation; + MacroAssembler::CodeLocationDataLabelPtr hotPathBegin; + MacroAssembler::CodeLocationNearCall hotPathOther; + MacroAssembler::CodeLocationLabel coldPathOther; CodeBlock* callee; unsigned position; @@ -128,6 +106,17 @@ namespace JSC { bool isLinked() { return callee; } }; + struct MethodCallLinkInfo { + MethodCallLinkInfo() + : cachedStructure(0) + { + } + + MacroAssembler::CodeLocationCall callReturnLocation; + MacroAssembler::CodeLocationDataLabelPtr structureLabel; + Structure* cachedStructure; + }; + struct FunctionRegisterInfo { FunctionRegisterInfo(unsigned bytecodeOffset, int functionRegisterIndex) : bytecodeOffset(bytecodeOffset) @@ -140,24 +129,30 @@ namespace JSC { }; struct GlobalResolveInfo { - GlobalResolveInfo() + GlobalResolveInfo(unsigned bytecodeOffset) : structure(0) , offset(0) + , bytecodeOffset(bytecodeOffset) { } Structure* structure; unsigned offset; + unsigned bytecodeOffset; }; - struct PC { - PC(ptrdiff_t nativePCOffset, unsigned bytecodeIndex) - : nativePCOffset(nativePCOffset) + // This structure is used to map from a call return location + // (given as an offset in bytes into the JIT code) back to + // the bytecode index of the corresponding bytecode operation. + // This is then used to look up the corresponding handler. + struct CallReturnOffsetToBytecodeIndex { + CallReturnOffsetToBytecodeIndex(unsigned callReturnOffset, unsigned bytecodeIndex) + : callReturnOffset(callReturnOffset) , bytecodeIndex(bytecodeIndex) { } - ptrdiff_t nativePCOffset; + unsigned callReturnOffset; unsigned bytecodeIndex; }; @@ -165,17 +160,22 @@ namespace JSC { inline void* getStructureStubInfoReturnLocation(StructureStubInfo* structureStubInfo) { - return structureStubInfo->callReturnLocation; + return structureStubInfo->callReturnLocation.calleeReturnAddressValue(); } inline void* getCallLinkInfoReturnLocation(CallLinkInfo* callLinkInfo) { - return callLinkInfo->callReturnLocation; + return callLinkInfo->callReturnLocation.calleeReturnAddressValue(); + } + + inline void* getMethodCallLinkInfoReturnLocation(MethodCallLinkInfo* methodCallLinkInfo) + { + return methodCallLinkInfo->callReturnLocation.calleeReturnAddressValue(); } - inline ptrdiff_t getNativePCOffset(PC* pc) + inline unsigned getCallReturnOffset(CallReturnOffsetToBytecodeIndex* pc) { - return pc->nativePCOffset; + return pc->callReturnOffset; } // Binary chop algorithm, calls valueAtPosition on pre-sorted elements in array, @@ -242,7 +242,7 @@ namespace JSC { return true; if (isConstantRegisterIndex(index)) - return !JSImmediate::isImmediate(getConstant(index)); + return getConstant(index).isCell(); return false; } @@ -252,9 +252,9 @@ namespace JSC { return index >= m_numVars && index < m_numVars + m_numConstants; } - ALWAYS_INLINE JSValuePtr getConstant(int index) + ALWAYS_INLINE JSValue getConstant(int index) { - return m_constantRegisters[index - m_numVars].getJSValue(); + return m_constantRegisters[index - m_numVars].jsValue(); } ALWAYS_INLINE bool isTemporaryRegisterIndex(int index) @@ -297,24 +297,31 @@ namespace JSC { return *(binaryChop<CallLinkInfo, void*, getCallLinkInfoReturnLocation>(m_callLinkInfos.begin(), m_callLinkInfos.size(), returnAddress)); } - unsigned getBytecodeIndex(void* nativePC) + MethodCallLinkInfo& getMethodCallLinkInfo(void* returnAddress) { - ptrdiff_t nativePCOffset = reinterpret_cast<void**>(nativePC) - reinterpret_cast<void**>(m_jitCode.code); - return binaryChop<PC, ptrdiff_t, getNativePCOffset>(m_pcVector.begin(), m_pcVector.size(), nativePCOffset)->bytecodeIndex; + return *(binaryChop<MethodCallLinkInfo, void*, getMethodCallLinkInfoReturnLocation>(m_methodCallLinkInfos.begin(), m_methodCallLinkInfos.size(), returnAddress)); } + unsigned getBytecodeIndex(CallFrame* callFrame, void* nativePC) + { + reparseForExceptionInfoIfNecessary(callFrame); + return binaryChop<CallReturnOffsetToBytecodeIndex, unsigned, getCallReturnOffset>(m_exceptionInfo->m_callReturnIndexVector.begin(), m_exceptionInfo->m_callReturnIndexVector.size(), ownerNode()->generatedJITCode().offsetOf(nativePC))->bytecodeIndex; + } + bool functionRegisterForBytecodeOffset(unsigned bytecodeOffset, int& functionRegisterIndex); #endif + void setIsNumericCompareFunction(bool isNumericCompareFunction) { m_isNumericCompareFunction = isNumericCompareFunction; } + bool isNumericCompareFunction() { return m_isNumericCompareFunction; } + Vector<Instruction>& instructions() { return m_instructions; } #ifndef NDEBUG void setInstructionCount(unsigned instructionCount) { m_instructionCount = instructionCount; } #endif #if ENABLE(JIT) - void setJITCode(JITCodeRef& jitCode); - void* jitCode() { return m_jitCode.code; } - ExecutablePool* executablePool() { return m_jitCode.executablePool.get(); } + void setJITCode(JITCode); + ExecutablePool* executablePool() { return ownerNode()->getExecutablePool(); } #endif ScopeNode* ownerNode() const { return m_ownerNode; } @@ -343,22 +350,25 @@ namespace JSC { #if !ENABLE(JIT) void addPropertyAccessInstruction(unsigned propertyAccessInstruction) { m_propertyAccessInstructions.append(propertyAccessInstruction); } - void addGlobalResolveInstruction(unsigned globalResolveInstructions) { m_globalResolveInstructions.append(globalResolveInstructions); } + void addGlobalResolveInstruction(unsigned globalResolveInstruction) { m_globalResolveInstructions.append(globalResolveInstruction); } + bool hasGlobalResolveInstructionAtBytecodeOffset(unsigned bytecodeOffset); #else size_t numberOfStructureStubInfos() const { return m_structureStubInfos.size(); } void addStructureStubInfo(const StructureStubInfo& stubInfo) { m_structureStubInfos.append(stubInfo); } StructureStubInfo& structureStubInfo(int index) { return m_structureStubInfos[index]; } - void addGlobalResolveInfo() { m_globalResolveInfos.append(GlobalResolveInfo()); } + void addGlobalResolveInfo(unsigned globalResolveInstruction) { m_globalResolveInfos.append(GlobalResolveInfo(globalResolveInstruction)); } GlobalResolveInfo& globalResolveInfo(int index) { return m_globalResolveInfos[index]; } + bool hasGlobalResolveInfoAtBytecodeOffset(unsigned bytecodeOffset); size_t numberOfCallLinkInfos() const { return m_callLinkInfos.size(); } void addCallLinkInfo() { m_callLinkInfos.append(CallLinkInfo()); } CallLinkInfo& callLinkInfo(int index) { return m_callLinkInfos[index]; } - void addFunctionRegisterInfo(unsigned bytecodeOffset, int functionIndex) { createRareDataIfNecessary(); m_rareData->m_functionRegisterInfos.append(FunctionRegisterInfo(bytecodeOffset, functionIndex)); } + void addMethodCallLinkInfos(unsigned n) { m_methodCallLinkInfos.grow(n); } + MethodCallLinkInfo& methodCallLinkInfo(int index) { return m_methodCallLinkInfos[index]; } - Vector<PC>& pcVector() { return m_pcVector; } + void addFunctionRegisterInfo(unsigned bytecodeOffset, int functionIndex) { createRareDataIfNecessary(); m_rareData->m_functionRegisterInfos.append(FunctionRegisterInfo(bytecodeOffset, functionIndex)); } #endif // Exception handling support @@ -367,6 +377,7 @@ namespace JSC { void addExceptionHandler(const HandlerInfo& hanler) { createRareDataIfNecessary(); return m_rareData->m_exceptionHandlers.append(hanler); } HandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; } + bool hasExceptionInfo() const { return m_exceptionInfo; } void clearExceptionInfo() { m_exceptionInfo.clear(); } void addExpressionInfo(const ExpressionRangeInfo& expressionInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_expressionInfo.append(expressionInfo); } @@ -376,6 +387,10 @@ namespace JSC { void addLineInfo(const LineInfo& lineInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_lineInfo.append(lineInfo); } LineInfo& lastLineInfo() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_lineInfo.last(); } +#if ENABLE(JIT) + Vector<CallReturnOffsetToBytecodeIndex>& callReturnIndexVector() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_callReturnIndexVector; } +#endif + // Constant Pool size_t numberOfIdentifiers() const { return m_identifiers.size(); } @@ -392,8 +407,10 @@ namespace JSC { unsigned addFunction(FuncDeclNode* n) { createRareDataIfNecessary(); unsigned size = m_rareData->m_functions.size(); m_rareData->m_functions.append(n); return size; } FuncDeclNode* function(int index) const { ASSERT(m_rareData); return m_rareData->m_functions[index].get(); } - unsigned addUnexpectedConstant(JSValuePtr v) { createRareDataIfNecessary(); unsigned size = m_rareData->m_unexpectedConstants.size(); m_rareData->m_unexpectedConstants.append(v); return size; } - JSValuePtr unexpectedConstant(int index) const { ASSERT(m_rareData); return m_rareData->m_unexpectedConstants[index]; } + bool hasFunctions() const { return m_functionExpressions.size() || (m_rareData && m_rareData->m_functions.size()); } + + unsigned addUnexpectedConstant(JSValue v) { createRareDataIfNecessary(); unsigned size = m_rareData->m_unexpectedConstants.size(); m_rareData->m_unexpectedConstants.append(v); return size; } + JSValue unexpectedConstant(int index) const { ASSERT(m_rareData); return m_rareData->m_unexpectedConstants[index]; } unsigned addRegExp(RegExp* r) { createRareDataIfNecessary(); unsigned size = m_rareData->m_regexps.size(); m_rareData->m_regexps.append(r); return size; } RegExp* regexp(int index) const { ASSERT(m_rareData); return m_rareData->m_regexps[index].get(); } @@ -451,15 +468,13 @@ namespace JSC { #ifndef NDEBUG unsigned m_instructionCount; #endif -#if ENABLE(JIT) - JITCodeRef m_jitCode; -#endif int m_thisRegister; bool m_needsFullScopeChain; bool m_usesEval; bool m_usesArguments; + bool m_isNumericCompareFunction; CodeType m_codeType; @@ -473,9 +488,8 @@ namespace JSC { Vector<StructureStubInfo> m_structureStubInfos; Vector<GlobalResolveInfo> m_globalResolveInfos; Vector<CallLinkInfo> m_callLinkInfos; + Vector<MethodCallLinkInfo> m_methodCallLinkInfos; Vector<CallLinkInfo*> m_linkedCallerList; - - Vector<PC> m_pcVector; #endif Vector<unsigned> m_jumpTargets; @@ -491,6 +505,10 @@ namespace JSC { Vector<ExpressionRangeInfo> m_expressionInfo; Vector<LineInfo> m_lineInfo; Vector<GetByIdExceptionInfo> m_getByIdExceptionInfo; + +#if ENABLE(JIT) + Vector<CallReturnOffsetToBytecodeIndex> m_callReturnIndexVector; +#endif }; OwnPtr<ExceptionInfo> m_exceptionInfo; @@ -499,7 +517,7 @@ namespace JSC { // Rare Constants Vector<RefPtr<FuncDeclNode> > m_functions; - Vector<JSValuePtr> m_unexpectedConstants; + Vector<JSValue> m_unexpectedConstants; Vector<RefPtr<RegExp> > m_regexps; // Jump Tables @@ -542,10 +560,16 @@ namespace JSC { class EvalCodeBlock : public ProgramCodeBlock { public: - EvalCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider) + EvalCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, int baseScopeDepth) : ProgramCodeBlock(ownerNode, EvalCode, globalObject, sourceProvider) + , m_baseScopeDepth(baseScopeDepth) { } + + int baseScopeDepth() const { return m_baseScopeDepth; } + + private: + int m_baseScopeDepth; }; } // namespace JSC |