WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
the patch
blah.patch (text/plain), 55.71 KB, created by
Filip Pizlo
on 2013-03-27 14:07:45 PDT
(
hide
)
Description:
the patch
Filename:
MIME Type:
Creator:
Filip Pizlo
Created:
2013-03-27 14:07:45 PDT
Size:
55.71 KB
patch
obsolete
>Index: Source/JavaScriptCore/ChangeLog >=================================================================== >--- Source/JavaScriptCore/ChangeLog (revision 147009) >+++ Source/JavaScriptCore/ChangeLog (working copy) >@@ -1,3 +1,129 @@ >+2013-03-27 Filip Pizlo <fpizlo@apple.com> >+ >+ JITCode should abstract exactly how the JIT code is structured and where it was allocated >+ https://bugs.webkit.org/show_bug.cgi?id=113437 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ JITCode is now a virtual base class, which will allow different JITs to have radically >+ different memory allocation and management conventions in the future. It will also >+ make it easier to store JIT-specific meta-data in CodeBlock just by putting it into >+ an appropriate JITCode subclass. >+ >+ For now there is one subclass, DirectJITCode, which just behaves like JITCode used to >+ behave. >+ >+ * assembler/RepatchBuffer.h: >+ (JSC::RepatchBuffer::RepatchBuffer): >+ * bytecode/CodeBlock.cpp: >+ (JSC::CodeBlock::resetStubInternal): >+ (JSC::CodeBlock::bytecodeOffset): >+ (JSC::CodeBlock::codeOriginForReturn): >+ * bytecode/CodeBlock.h: >+ (JSC::CodeBlock::setJITCode): >+ (JSC::CodeBlock::getJITCode): >+ (JSC::CodeBlock::getJITType): >+ (CodeBlock): >+ * dfg/DFGDriver.cpp: >+ (JSC::DFG::compile): >+ (JSC::DFG::tryCompile): >+ (JSC::DFG::tryCompileFunction): >+ * dfg/DFGDriver.h: >+ (DFG): >+ (JSC::DFG::tryCompile): >+ (JSC::DFG::tryCompileFunction): >+ * dfg/DFGJITCompiler.cpp: >+ (JSC::DFG::JITCompiler::compile): >+ (JSC::DFG::JITCompiler::compileFunction): >+ * dfg/DFGJITCompiler.h: >+ (JITCompiler): >+ * dfg/DFGOSREntry.cpp: >+ (JSC::DFG::prepareOSREntry): >+ * dfg/DFGOSRExit.cpp: >+ (JSC::DFG::OSRExit::codeLocationForRepatch): >+ * dfg/DFGOSRExitCompiler32_64.cpp: >+ (JSC::DFG::OSRExitCompiler::compileExit): >+ * dfg/DFGOSRExitCompiler64.cpp: >+ (JSC::DFG::OSRExitCompiler::compileExit): >+ * dfg/DFGOperations.cpp: >+ * interpreter/Interpreter.cpp: >+ (JSC::Interpreter::execute): >+ (JSC::Interpreter::executeCall): >+ (JSC::Interpreter::executeConstruct): >+ * jit/JIT.cpp: >+ (JSC::JIT::privateCompile): >+ * jit/JIT.h: >+ (JSC::JIT::compile): >+ (JIT): >+ * jit/JITCode.cpp: >+ (JSC): >+ (JSC::JITCode::JITCode): >+ (JSC::JITCode::~JITCode): >+ (JSC::JITCode::execute): >+ (JSC::JITCode::hostFunction): >+ (JSC::DirectJITCode::DirectJITCode): >+ (JSC::DirectJITCode::~DirectJITCode): >+ (JSC::DirectJITCode::addressForCall): >+ (JSC::DirectJITCode::executableAddressAtOffset): >+ (JSC::DirectJITCode::dataAddressAtOffset): >+ (JSC::DirectJITCode::offsetOf): >+ (JSC::DirectJITCode::size): >+ (JSC::DirectJITCode::contains): >+ * jit/JITCode.h: >+ (JSC): >+ (JITCode): >+ (JSC::JITCode::bottomTierJIT): >+ (JSC::JITCode::topTierJIT): >+ (JSC::JITCode::nextTierJIT): >+ (JSC::JITCode::isOptimizingJIT): >+ (JSC::JITCode::isBaselineCode): >+ (JSC::JITCode::jitType): >+ (JSC::JITCode::jitTypeFor): >+ (JSC::JITCode::executableAddress): >+ (JSC::JITCode::start): >+ (JSC::JITCode::end): >+ (DirectJITCode): >+ * jit/JITDriver.h: >+ (JSC::jitCompileIfAppropriate): >+ (JSC::jitCompileFunctionIfAppropriate): >+ * jit/JITStubs.cpp: >+ (JSC::lazyLinkFor): >+ (JSC::DEFINE_STUB_FUNCTION): >+ * jit/ThunkGenerators.cpp: >+ (JSC::virtualForGenerator): >+ * llint/LLIntEntrypoints.cpp: >+ (JSC::LLInt::getFunctionEntrypoint): >+ (JSC::LLInt::getEvalEntrypoint): >+ (JSC::LLInt::getProgramEntrypoint): >+ * llint/LLIntEntrypoints.h: >+ (JSC): >+ (LLInt): >+ (JSC::LLInt::getEntrypoint): >+ * llint/LLIntSlowPaths.cpp: >+ (JSC::LLInt::jitCompileAndSetHeuristics): >+ (JSC::LLInt::entryOSR): >+ (JSC::LLInt::LLINT_SLOW_PATH_DECL): >+ * runtime/Executable.cpp: >+ (JSC::EvalExecutable::compileInternal): >+ (JSC::ProgramExecutable::compileInternal): >+ (JSC::FunctionExecutable::compileForCallInternal): >+ (JSC::FunctionExecutable::compileForConstructInternal): >+ * runtime/Executable.h: >+ (JSC::ExecutableBase::generatedJITCodeForCall): >+ (JSC::ExecutableBase::generatedJITCodeForConstruct): >+ (JSC::ExecutableBase::generatedJITCodeFor): >+ (ExecutableBase): >+ (JSC::ExecutableBase::hostCodeEntryFor): >+ (JSC::ExecutableBase::jsCodeEntryFor): >+ (JSC::ExecutableBase::jsCodeWithArityCheckEntryFor): >+ (JSC::NativeExecutable::create): >+ (JSC::NativeExecutable::finishCreation): >+ (JSC::EvalExecutable::generatedJITCode): >+ (JSC::ProgramExecutable::generatedJITCode): >+ * runtime/ExecutionHarness.h: >+ (JSC::prepareForExecution): >+ (JSC::prepareFunctionForExecution): >+ > 2013-03-19 Filip Pizlo <fpizlo@apple.com> > > It's called "Hash Consing" not "Hash Consting" >Index: Source/JavaScriptCore/assembler/RepatchBuffer.h >=================================================================== >--- Source/JavaScriptCore/assembler/RepatchBuffer.h (revision 146422) >+++ Source/JavaScriptCore/assembler/RepatchBuffer.h (working copy) >@@ -46,9 +46,9 @@ class RepatchBuffer { > public: > RepatchBuffer(CodeBlock* codeBlock) > { >- JITCode& code = codeBlock->getJITCode(); >- m_start = code.start(); >- m_size = code.size(); >+ RefPtr<JITCode> code = codeBlock->getJITCode(); >+ m_start = code->start(); >+ m_size = code->size(); > > ExecutableAllocator::makeWritable(m_start, m_size); > } >Index: Source/JavaScriptCore/bytecode/CodeBlock.cpp >=================================================================== >--- Source/JavaScriptCore/bytecode/CodeBlock.cpp (revision 146422) >+++ Source/JavaScriptCore/bytecode/CodeBlock.cpp (working copy) >@@ -2442,13 +2442,13 @@ void CodeBlock::resetStubInternal(Repatc > dataLog("Clearing structure cache (kind ", static_cast<int>(stubInfo.accessType), ") in ", *this, ".\n"); > > if (isGetByIdAccess(accessType)) { >- if (getJITCode().jitType() == JITCode::DFGJIT) >+ if (getJITType() == JITCode::DFGJIT) > DFG::dfgResetGetByID(repatchBuffer, stubInfo); > else > JIT::resetPatchGetById(repatchBuffer, &stubInfo); > } else { > ASSERT(isPutByIdAccess(accessType)); >- if (getJITCode().jitType() == JITCode::DFGJIT) >+ if (getJITType() == JITCode::DFGJIT) > DFG::dfgResetPutByID(repatchBuffer, stubInfo); > else > JIT::resetPatchPutById(repatchBuffer, &stubInfo); >@@ -2754,8 +2754,8 @@ unsigned CodeBlock::bytecodeOffset(ExecS > if (!callIndices.size()) > return 1; > >- if (getJITCode().getExecutableMemory()->contains(returnAddress.value())) { >- unsigned callReturnOffset = getJITCode().offsetOf(returnAddress.value()); >+ if (getJITCode()->contains(returnAddress.value())) { >+ unsigned callReturnOffset = getJITCode()->offsetOf(returnAddress.value()); > CallReturnOffsetToBytecodeOffset* result = > binarySearch<CallReturnOffsetToBytecodeOffset, unsigned>( > callIndices, callIndices.size(), callReturnOffset, getCallReturnOffset); >@@ -2777,12 +2777,12 @@ bool CodeBlock::codeOriginForReturn(Retu > if (!hasCodeOrigins()) > return false; > >- if (!getJITCode().getExecutableMemory()->contains(returnAddress.value())) { >+ if (!getJITCode()->contains(returnAddress.value())) { > codeOrigin = findClosureCallForReturnPC(returnAddress)->codeOrigin(); > return true; > } > >- unsigned offset = getJITCode().offsetOf(returnAddress.value()); >+ unsigned offset = getJITCode()->offsetOf(returnAddress.value()); > CodeOriginAtCallReturnOffset* entry = > tryBinarySearch<CodeOriginAtCallReturnOffset, unsigned>( > codeOrigins(), codeOrigins().size(), offset, >Index: Source/JavaScriptCore/bytecode/CodeBlock.h >=================================================================== >--- Source/JavaScriptCore/bytecode/CodeBlock.h (revision 146422) >+++ Source/JavaScriptCore/bytecode/CodeBlock.h (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. > * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca> > * > * Redistribution and use in source and binary forms, with or without >@@ -421,21 +421,20 @@ namespace JSC { > int argumentIndexAfterCapture(size_t argument); > > #if ENABLE(JIT) >- void setJITCode(const JITCode& code, MacroAssemblerCodePtr codeWithArityCheck) >+ void setJITCode(PassRefPtr<JITCode> code, MacroAssemblerCodePtr codeWithArityCheck) > { > m_jitCode = code; > m_jitCodeWithArityCheck = codeWithArityCheck; > #if ENABLE(DFG_JIT) >- if (m_jitCode.jitType() == JITCode::DFGJIT) { >+ if (JITCode::jitTypeFor(m_jitCode) == JITCode::DFGJIT) { > createDFGDataIfNecessary(); > m_globalData->heap.m_dfgCodeBlocks.m_set.add(this); > } > #endif > } >- JITCode& getJITCode() { return m_jitCode; } >+ PassRefPtr<JITCode> getJITCode() { return m_jitCode; } > MacroAssemblerCodePtr getJITCodeWithArityCheck() { return m_jitCodeWithArityCheck; } >- JITCode::JITType getJITType() const { return m_jitCode.jitType(); } >- ExecutableMemoryHandle* executableMemory() { return getJITCode().getExecutableMemory(); } >+ JITCode::JITType getJITType() const { return JITCode::jitTypeFor(m_jitCode); } > virtual JSObject* compileOptimized(ExecState*, JSScope*, unsigned bytecodeIndex) = 0; > virtual void jettison() = 0; > enum JITCompilationResult { AlreadyCompiled, CouldNotCompile, CompiledSuccessfully }; >@@ -1171,7 +1170,7 @@ namespace JSC { > Vector<StructureStubInfo> m_structureStubInfos; > Vector<ByValInfo> m_byValInfos; > Vector<CallLinkInfo> m_callLinkInfos; >- JITCode m_jitCode; >+ RefPtr<JITCode> m_jitCode; > MacroAssemblerCodePtr m_jitCodeWithArityCheck; > SentinelLinkedList<CallLinkInfo, BasicRawSentinelNode<CallLinkInfo> > m_incomingCalls; > #endif >Index: Source/JavaScriptCore/dfg/DFGDriver.cpp >=================================================================== >--- Source/JavaScriptCore/dfg/DFGDriver.cpp (revision 146422) >+++ Source/JavaScriptCore/dfg/DFGDriver.cpp (working copy) >@@ -62,7 +62,7 @@ unsigned getNumCompilations() > } > > enum CompileMode { CompileFunction, CompileOther }; >-inline bool compile(CompileMode compileMode, ExecState* exec, CodeBlock* codeBlock, JITCode& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck, unsigned osrEntryBytecodeIndex) >+inline bool compile(CompileMode compileMode, ExecState* exec, CodeBlock* codeBlock, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck, unsigned osrEntryBytecodeIndex) > { > SamplingRegion samplingRegion("DFG Compilation (Driver)"); > >@@ -169,12 +169,12 @@ inline bool compile(CompileMode compileM > return result; > } > >-bool tryCompile(ExecState* exec, CodeBlock* codeBlock, JITCode& jitCode, unsigned bytecodeIndex) >+bool tryCompile(ExecState* exec, CodeBlock* codeBlock, RefPtr<JITCode>& jitCode, unsigned bytecodeIndex) > { > return compile(CompileOther, exec, codeBlock, jitCode, 0, bytecodeIndex); > } > >-bool tryCompileFunction(ExecState* exec, CodeBlock* codeBlock, JITCode& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, unsigned bytecodeIndex) >+bool tryCompileFunction(ExecState* exec, CodeBlock* codeBlock, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, unsigned bytecodeIndex) > { > return compile(CompileFunction, exec, codeBlock, jitCode, &jitCodeWithArityCheck, bytecodeIndex); > } >Index: Source/JavaScriptCore/dfg/DFGDriver.h >=================================================================== >--- Source/JavaScriptCore/dfg/DFGDriver.h (revision 146422) >+++ Source/JavaScriptCore/dfg/DFGDriver.h (working copy) >@@ -41,11 +41,11 @@ namespace DFG { > JS_EXPORT_PRIVATE unsigned getNumCompilations(); > > #if ENABLE(DFG_JIT) >-bool tryCompile(ExecState*, CodeBlock*, JITCode&, unsigned bytecodeIndex); >-bool tryCompileFunction(ExecState*, CodeBlock*, JITCode&, MacroAssemblerCodePtr& jitCodeWithArityCheck, unsigned bytecodeIndex); >+bool tryCompile(ExecState*, CodeBlock*, RefPtr<JITCode>&, unsigned bytecodeIndex); >+bool tryCompileFunction(ExecState*, CodeBlock*, RefPtr<JITCode>&, MacroAssemblerCodePtr& jitCodeWithArityCheck, unsigned bytecodeIndex); > #else >-inline bool tryCompile(ExecState*, CodeBlock*, JITCode&, unsigned) { return false; } >-inline bool tryCompileFunction(ExecState*, CodeBlock*, JITCode&, MacroAssemblerCodePtr&, unsigned) { return false; } >+inline bool tryCompile(ExecState*, CodeBlock*, RefPtr<JITCode>&, unsigned) { return false; } >+inline bool tryCompileFunction(ExecState*, CodeBlock*, RefPtr<JITCode>&, MacroAssemblerCodePtr&, unsigned) { return false; } > #endif > > } } // namespace JSC::DFG >Index: Source/JavaScriptCore/dfg/DFGJITCompiler.cpp >=================================================================== >--- Source/JavaScriptCore/dfg/DFGJITCompiler.cpp (revision 146422) >+++ Source/JavaScriptCore/dfg/DFGJITCompiler.cpp (working copy) >@@ -240,7 +240,7 @@ void JITCompiler::link(LinkBuffer& linkB > codeBlock()->shrinkToFit(CodeBlock::LateShrink); > } > >-bool JITCompiler::compile(JITCode& entry) >+bool JITCompiler::compile(RefPtr<JITCode>& entry) > { > SamplingRegion samplingRegion("DFG Backend"); > >@@ -271,13 +271,13 @@ bool JITCompiler::compile(JITCode& entry > if (m_graph.m_compilation) > m_disassembler->reportToProfiler(m_graph.m_compilation.get(), linkBuffer); > >- entry = JITCode( >+ entry = adoptRef(new DirectJITCode( > linkBuffer.finalizeCodeWithoutDisassembly(), >- JITCode::DFGJIT); >+ JITCode::DFGJIT)); > return true; > } > >-bool JITCompiler::compileFunction(JITCode& entry, MacroAssemblerCodePtr& entryWithArityCheck) >+bool JITCompiler::compileFunction(RefPtr<JITCode>& entry, MacroAssemblerCodePtr& entryWithArityCheck) > { > SamplingRegion samplingRegion("DFG Backend"); > >@@ -365,9 +365,9 @@ bool JITCompiler::compileFunction(JITCod > m_disassembler->reportToProfiler(m_graph.m_compilation.get(), linkBuffer); > > entryWithArityCheck = linkBuffer.locationOf(arityCheck); >- entry = JITCode( >+ entry = adoptRef(new DirectJITCode( > linkBuffer.finalizeCodeWithoutDisassembly(), >- JITCode::DFGJIT); >+ JITCode::DFGJIT)); > return true; > } > >Index: Source/JavaScriptCore/dfg/DFGJITCompiler.h >=================================================================== >--- Source/JavaScriptCore/dfg/DFGJITCompiler.h (revision 146422) >+++ Source/JavaScriptCore/dfg/DFGJITCompiler.h (working copy) >@@ -245,8 +245,8 @@ class JITCompiler : public CCallHelpers > public: > JITCompiler(Graph& dfg); > >- bool compile(JITCode& entry); >- bool compileFunction(JITCode& entry, MacroAssemblerCodePtr& entryWithArityCheck); >+ bool compile(RefPtr<JITCode>& entry); >+ bool compileFunction(RefPtr<JITCode>& entry, MacroAssemblerCodePtr& entryWithArityCheck); > > // Accessors for properties. > Graph& graph() { return m_graph; } >Index: Source/JavaScriptCore/dfg/DFGOSREntry.cpp >=================================================================== >--- Source/JavaScriptCore/dfg/DFGOSREntry.cpp (revision 146422) >+++ Source/JavaScriptCore/dfg/DFGOSREntry.cpp (working copy) >@@ -156,7 +156,7 @@ void* prepareOSREntry(ExecState* exec, C > > // 5) Find and return the destination machine code address. > >- void* result = codeBlock->getJITCode().executableAddressAtOffset(entry->m_machineCodeOffset); >+ void* result = codeBlock->getJITCode()->executableAddressAtOffset(entry->m_machineCodeOffset); > > #if ENABLE(JIT_VERBOSE_OSR) > dataLogF(" OSR returning machine code address %p.\n", result); >Index: Source/JavaScriptCore/dfg/DFGOSRExit.cpp >=================================================================== >--- Source/JavaScriptCore/dfg/DFGOSRExit.cpp (revision 146422) >+++ Source/JavaScriptCore/dfg/DFGOSRExit.cpp (working copy) >@@ -62,7 +62,7 @@ MacroAssembler::Jump OSRExit::getPatchab > > CodeLocationJump OSRExit::codeLocationForRepatch(CodeBlock* dfgCodeBlock) const > { >- return CodeLocationJump(dfgCodeBlock->getJITCode().dataAddressAtOffset(m_patchableCodeOffset)); >+ return CodeLocationJump(dfgCodeBlock->getJITCode()->dataAddressAtOffset(m_patchableCodeOffset)); > } > > void OSRExit::correctJump(LinkBuffer& linkBuffer) >Index: Source/JavaScriptCore/dfg/DFGOSRExitCompiler32_64.cpp >=================================================================== >--- Source/JavaScriptCore/dfg/DFGOSRExitCompiler32_64.cpp (revision 146422) >+++ Source/JavaScriptCore/dfg/DFGOSRExitCompiler32_64.cpp (working copy) >@@ -646,7 +646,7 @@ void OSRExitCompiler::compileExit(const > ASSERT(mapping); > ASSERT(mapping->m_bytecodeIndex == returnBytecodeIndex); > >- void* jumpTarget = baselineCodeBlockForCaller->getJITCode().executableAddressAtOffset(mapping->m_machineCodeOffset); >+ void* jumpTarget = baselineCodeBlockForCaller->getJITCode()->executableAddressAtOffset(mapping->m_machineCodeOffset); > > GPRReg callerFrameGPR; > if (inlineCallFrame->caller.inlineCallFrame) { >@@ -757,7 +757,7 @@ void OSRExitCompiler::compileExit(const > ASSERT(mapping); > ASSERT(mapping->m_bytecodeIndex == exit.m_codeOrigin.bytecodeIndex); > >- void* jumpTarget = baselineCodeBlock->getJITCode().executableAddressAtOffset(mapping->m_machineCodeOffset); >+ void* jumpTarget = baselineCodeBlock->getJITCode()->executableAddressAtOffset(mapping->m_machineCodeOffset); > > ASSERT(GPRInfo::regT2 != GPRInfo::cachedResultRegister && GPRInfo::regT2 != GPRInfo::cachedResultRegister2); > >Index: Source/JavaScriptCore/dfg/DFGOSRExitCompiler64.cpp >=================================================================== >--- Source/JavaScriptCore/dfg/DFGOSRExitCompiler64.cpp (revision 146422) >+++ Source/JavaScriptCore/dfg/DFGOSRExitCompiler64.cpp (working copy) >@@ -610,7 +610,7 @@ void OSRExitCompiler::compileExit(const > ASSERT(mapping); > ASSERT(mapping->m_bytecodeIndex == returnBytecodeIndex); > >- void* jumpTarget = baselineCodeBlockForCaller->getJITCode().executableAddressAtOffset(mapping->m_machineCodeOffset); >+ void* jumpTarget = baselineCodeBlockForCaller->getJITCode()->executableAddressAtOffset(mapping->m_machineCodeOffset); > > GPRReg callerFrameGPR; > if (inlineCallFrame->caller.inlineCallFrame) { >@@ -700,7 +700,7 @@ void OSRExitCompiler::compileExit(const > ASSERT(mapping); > ASSERT(mapping->m_bytecodeIndex == exit.m_codeOrigin.bytecodeIndex); > >- void* jumpTarget = baselineCodeBlock->getJITCode().executableAddressAtOffset(mapping->m_machineCodeOffset); >+ void* jumpTarget = baselineCodeBlock->getJITCode()->executableAddressAtOffset(mapping->m_machineCodeOffset); > > ASSERT(GPRInfo::regT1 != GPRInfo::cachedResultRegister); > >Index: Source/JavaScriptCore/dfg/DFGOperations.cpp >=================================================================== >--- Source/JavaScriptCore/dfg/DFGOperations.cpp (revision 146422) >+++ Source/JavaScriptCore/dfg/DFGOperations.cpp (working copy) >@@ -1089,7 +1089,7 @@ inline char* linkFor(ExecState* execCall > MacroAssemblerCodePtr codePtr; > CodeBlock* codeBlock = 0; > if (executable->isHostFunction()) >- codePtr = executable->generatedJITCodeFor(kind).addressForCall(); >+ codePtr = executable->generatedJITCodeFor(kind)->addressForCall(); > else { > FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable); > JSObject* error = functionExecutable->compileFor(execCallee, callee->scope(), kind); >@@ -1101,7 +1101,7 @@ inline char* linkFor(ExecState* execCall > if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters())) > codePtr = functionExecutable->generatedJITCodeWithArityCheckFor(kind); > else >- codePtr = functionExecutable->generatedJITCodeFor(kind).addressForCall(); >+ codePtr = functionExecutable->generatedJITCodeFor(kind)->addressForCall(); > } > CallLinkInfo& callLinkInfo = exec->codeBlock()->getCallLinkInfo(execCallee->returnPC()); > if (!callLinkInfo.seenOnce()) >@@ -1166,7 +1166,7 @@ static bool attemptToOptimizeClosureCall > return false; > > ASSERT(callee->executable()->hasJITCodeForCall()); >- MacroAssemblerCodePtr codePtr = callee->executable()->generatedJITCodeForCall().addressForCall(); >+ MacroAssemblerCodePtr codePtr = callee->executable()->generatedJITCodeForCall()->addressForCall(); > > CodeBlock* codeBlock; > if (callee->executable()->isHostFunction()) >Index: Source/JavaScriptCore/interpreter/Interpreter.cpp >=================================================================== >--- Source/JavaScriptCore/interpreter/Interpreter.cpp (revision 146422) >+++ Source/JavaScriptCore/interpreter/Interpreter.cpp (working copy) >@@ -984,7 +984,7 @@ failedJSONP: > #if ENABLE(LLINT_C_LOOP) > result = LLInt::CLoop::execute(newCallFrame, llint_program_prologue); > #elif ENABLE(JIT) >- result = program->generatedJITCode().execute(&m_stack, newCallFrame, &globalData); >+ result = program->generatedJITCode()->execute(&m_stack, newCallFrame, &globalData); > #endif // ENABLE(JIT) > } > >@@ -1056,7 +1056,7 @@ JSValue Interpreter::executeCall(CallFra > #if ENABLE(LLINT_C_LOOP) > result = LLInt::CLoop::execute(newCallFrame, llint_function_for_call_prologue); > #elif ENABLE(JIT) >- result = callData.js.functionExecutable->generatedJITCodeForCall().execute(&m_stack, newCallFrame, &globalData); >+ result = callData.js.functionExecutable->generatedJITCodeForCall()->execute(&m_stack, newCallFrame, &globalData); > #endif // ENABLE(JIT) > } else > result = JSValue::decode(callData.native.function(newCallFrame)); >@@ -1131,7 +1131,7 @@ JSObject* Interpreter::executeConstruct( > #if ENABLE(LLINT_C_LOOP) > result = LLInt::CLoop::execute(newCallFrame, llint_function_for_construct_prologue); > #elif ENABLE(JIT) >- result = constructData.js.functionExecutable->generatedJITCodeForConstruct().execute(&m_stack, newCallFrame, &globalData); >+ result = constructData.js.functionExecutable->generatedJITCodeForConstruct()->execute(&m_stack, newCallFrame, &globalData); > #endif // ENABLE(JIT) > } else { > result = JSValue::decode(constructData.native.function(newCallFrame)); >@@ -1226,7 +1226,7 @@ JSValue Interpreter::execute(CallFrameCl > #if ENABLE(LLINT_C_LOOP) > result = LLInt::CLoop::execute(closure.newCallFrame, llint_function_for_call_prologue); > #elif ENABLE(JIT) >- result = closure.functionExecutable->generatedJITCodeForCall().execute(&m_stack, closure.newCallFrame, &globalData); >+ result = closure.functionExecutable->generatedJITCodeForCall()->execute(&m_stack, closure.newCallFrame, &globalData); > #endif // ENABLE(JIT) > } > >@@ -1322,7 +1322,7 @@ JSValue Interpreter::execute(EvalExecuta > #if ENABLE(LLINT_C_LOOP) > result = LLInt::CLoop::execute(newCallFrame, llint_eval_prologue); > #elif ENABLE(JIT) >- result = eval->generatedJITCode().execute(&m_stack, newCallFrame, &globalData); >+ result = eval->generatedJITCode()->execute(&m_stack, newCallFrame, &globalData); > #endif // ENABLE(JIT) > } > >Index: Source/JavaScriptCore/jit/JIT.cpp >=================================================================== >--- Source/JavaScriptCore/jit/JIT.cpp (revision 146422) >+++ Source/JavaScriptCore/jit/JIT.cpp (working copy) >@@ -617,7 +617,7 @@ ALWAYS_INLINE void PropertyStubCompilati > } > } > >-JITCode JIT::privateCompile(CodePtr* functionEntryArityCheck, JITCompilationEffort effort) >+PassRefPtr<JITCode> JIT::privateCompile(CodePtr* functionEntryArityCheck, JITCompilationEffort effort) > { > #if ENABLE(JIT_VERBOSE_OSR) > printf("Compiling JIT code!\n"); >@@ -747,7 +747,7 @@ JITCode JIT::privateCompile(CodePtr* fun > > LinkBuffer patchBuffer(*m_globalData, this, m_codeBlock, effort); > if (patchBuffer.didFailToAllocate()) >- return JITCode(); >+ return PassRefPtr<JITCode>(); > > // Translate vPC offsets into addresses in JIT generated code, for switch tables. > for (unsigned i = 0; i < m_switches.size(); ++i) { >@@ -854,7 +854,7 @@ JITCode JIT::privateCompile(CodePtr* fun > dataLogF("JIT generated code for %p at [%p, %p).\n", m_codeBlock, result.executableMemory()->start(), result.executableMemory()->end()); > #endif > >- return JITCode(result, JITCode::BaselineJIT); >+ return adoptRef(new DirectJITCode(result, JITCode::BaselineJIT)); > } > > void JIT::linkFor(JSFunction* callee, CodeBlock* callerCodeBlock, CodeBlock* calleeCodeBlock, JIT::CodePtr code, CallLinkInfo* callLinkInfo, JSGlobalData* globalData, CodeSpecializationKind kind) >Index: Source/JavaScriptCore/jit/JIT.h >=================================================================== >--- Source/JavaScriptCore/jit/JIT.h (revision 146422) >+++ Source/JavaScriptCore/jit/JIT.h (working copy) >@@ -302,7 +302,7 @@ namespace JSC { > static const int patchPutByIdDefaultOffset = 256; > > public: >- static JITCode compile(JSGlobalData* globalData, CodeBlock* codeBlock, JITCompilationEffort effort, CodePtr* functionEntryArityCheck = 0) >+ static PassRefPtr<JITCode> compile(JSGlobalData* globalData, CodeBlock* codeBlock, JITCompilationEffort effort, CodePtr* functionEntryArityCheck = 0) > { > return JIT(globalData, codeBlock).privateCompile(functionEntryArityCheck, effort); > } >@@ -407,7 +407,7 @@ namespace JSC { > void privateCompileMainPass(); > void privateCompileLinkPass(); > void privateCompileSlowCases(); >- JITCode privateCompile(CodePtr* functionEntryArityCheck, JITCompilationEffort); >+ PassRefPtr<JITCode> privateCompile(CodePtr* functionEntryArityCheck, JITCompilationEffort); > > void privateCompileClosureCall(CallLinkInfo*, CodeBlock* calleeCodeBlock, Structure*, ExecutableBase*, MacroAssemblerCodePtr); > >Index: Source/JavaScriptCore/jit/JITCode.cpp >=================================================================== >--- Source/JavaScriptCore/jit/JITCode.cpp (revision 146422) >+++ Source/JavaScriptCore/jit/JITCode.cpp (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2008, 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 2008, 2012, 2013 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -28,6 +28,73 @@ > > #include <wtf/PrintStream.h> > >+namespace JSC { >+ >+JITCode::JITCode(JITType jitType) >+ : m_jitType(jitType) >+{ >+} >+ >+JITCode::~JITCode() >+{ >+} >+ >+JSValue JITCode::execute(JSStack* stack, CallFrame* callFrame, JSGlobalData* globalData) >+{ >+ JSValue result = JSValue::decode(ctiTrampoline(executableAddress(), stack, callFrame, 0, 0, globalData)); >+ return globalData->exception ? jsNull() : result; >+} >+ >+PassRefPtr<JITCode> JITCode::hostFunction(JITCode::CodeRef code) >+{ >+ return adoptRef(new DirectJITCode(code, HostCallThunk)); >+} >+ >+DirectJITCode::DirectJITCode(const JITCode::CodeRef ref, JITType jitType) >+ : JITCode(jitType) >+ , m_ref(ref) >+{ >+} >+ >+DirectJITCode::~DirectJITCode() >+{ >+} >+ >+JITCode::CodePtr DirectJITCode::addressForCall() >+{ >+ return m_ref.code(); >+} >+ >+void* DirectJITCode::executableAddressAtOffset(size_t offset) >+{ >+ return reinterpret_cast<char*>(m_ref.code().executableAddress()) + offset; >+} >+ >+void* DirectJITCode::dataAddressAtOffset(size_t offset) >+{ >+ ASSERT(offset <= size()); // use <= instead of < because it is valid to ask for an address at the exclusive end of the code. >+ return reinterpret_cast<char*>(m_ref.code().dataLocation()) + offset; >+} >+ >+unsigned DirectJITCode::offsetOf(void* pointerIntoCode) >+{ >+ intptr_t result = reinterpret_cast<intptr_t>(pointerIntoCode) - reinterpret_cast<intptr_t>(m_ref.code().executableAddress()); >+ ASSERT(static_cast<intptr_t>(static_cast<unsigned>(result)) == result); >+ return static_cast<unsigned>(result); >+} >+ >+size_t DirectJITCode::size() >+{ >+ return m_ref.size(); >+} >+ >+bool DirectJITCode::contains(void* address) >+{ >+ return m_ref.executableMemory()->contains(address); >+} >+ >+} // namespace JSC >+ > namespace WTF { > > void printInternal(PrintStream& out, JSC::JITCode::JITType type) >Index: Source/JavaScriptCore/jit/JITCode.h >=================================================================== >--- Source/JavaScriptCore/jit/JITCode.h (revision 146422) >+++ Source/JavaScriptCore/jit/JITCode.h (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2008, 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 2008, 2012, 2013 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -38,155 +38,97 @@ > namespace JSC { > > #if ENABLE(JIT) >- class JSGlobalData; >- class JSStack; >+class JSGlobalData; >+class JSStack; > #endif >+ >+class JITCode : public RefCounted<JITCode> { >+public: >+ typedef MacroAssemblerCodeRef CodeRef; >+ typedef MacroAssemblerCodePtr CodePtr; >+ >+ enum JITType { None, HostCallThunk, InterpreterThunk, BaselineJIT, DFGJIT }; > >- class JITCode { >-#if ENABLE(JIT) || ENABLE(LLINT) >- typedef MacroAssemblerCodeRef CodeRef; >- typedef MacroAssemblerCodePtr CodePtr; >-#else >- JITCode() { } >-#endif >- public: >- enum JITType { None, HostCallThunk, InterpreterThunk, BaselineJIT, DFGJIT }; >- >- static JITType bottomTierJIT() >- { >- return BaselineJIT; >- } >- >- static JITType topTierJIT() >- { >- return DFGJIT; >- } >- >- static JITType nextTierJIT(JITType jitType) >- { >- ASSERT_UNUSED(jitType, jitType == BaselineJIT || jitType == DFGJIT); >- return DFGJIT; >- } >- >- static bool isOptimizingJIT(JITType jitType) >- { >- return jitType == DFGJIT; >- } >- >- static bool isBaselineCode(JITType jitType) >- { >- return jitType == InterpreterThunk || jitType == BaselineJIT; >- } >- >-#if ENABLE(JIT) || ENABLE(LLINT) >- JITCode() >- : m_jitType(None) >- { >- } >- >- JITCode(const CodeRef ref, JITType jitType) >- : m_ref(ref) >- , m_jitType(jitType) >- { >- ASSERT(jitType != None); >- } >- >- bool operator !() const >- { >- return !m_ref; >- } >- >- CodePtr addressForCall() >- { >- return m_ref.code(); >- } >- >- void* executableAddressAtOffset(size_t offset) const >- { >- ASSERT(offset < size()); >- return reinterpret_cast<char*>(m_ref.code().executableAddress()) + offset; >- } >- >- void* executableAddress() const >- { >- return executableAddressAtOffset(0); >- } >- >- void* dataAddressAtOffset(size_t offset) const >- { >- ASSERT(offset <= size()); // use <= instead of < because it is valid to ask for an address at the exclusive end of the code. >- return reinterpret_cast<char*>(m_ref.code().dataLocation()) + offset; >- } >- >- // This function returns the offset in bytes of 'pointerIntoCode' into >- // this block of code. The pointer provided must be a pointer into this >- // block of code. It is ASSERTed that no codeblock >4gb in size. >- unsigned offsetOf(void* pointerIntoCode) >- { >- intptr_t result = reinterpret_cast<intptr_t>(pointerIntoCode) - reinterpret_cast<intptr_t>(m_ref.code().executableAddress()); >- ASSERT(static_cast<intptr_t>(static_cast<unsigned>(result)) == result); >- return static_cast<unsigned>(result); >- } >+ static JITType bottomTierJIT() >+ { >+ return BaselineJIT; >+ } >+ >+ static JITType topTierJIT() >+ { >+ return DFGJIT; >+ } >+ >+ static JITType nextTierJIT(JITType jitType) >+ { >+ ASSERT_UNUSED(jitType, jitType == BaselineJIT || jitType == DFGJIT); >+ return DFGJIT; >+ } >+ >+ static bool isOptimizingJIT(JITType jitType) >+ { >+ return jitType == DFGJIT; >+ } >+ >+ static bool isBaselineCode(JITType jitType) >+ { >+ return jitType == InterpreterThunk || jitType == BaselineJIT; >+ } >+ >+protected: >+ JITCode(JITType jitType); >+ >+public: >+ virtual ~JITCode(); >+ >+ JITType jitType() const >+ { >+ return m_jitType; >+ } >+ >+ template<typename PointerType> >+ static JITType jitTypeFor(PointerType jitCode) >+ { >+ if (!jitCode) >+ return None; >+ return jitCode->jitType(); >+ } >+ >+ virtual CodePtr addressForCall() = 0; >+ virtual void* executableAddressAtOffset(size_t offset) = 0; >+ void* executableAddress() { return executableAddressAtOffset(0); } >+ virtual void* dataAddressAtOffset(size_t offset) = 0; >+ virtual unsigned offsetOf(void* pointerIntoCode) = 0; >+ >+ JSValue execute(JSStack*, CallFrame*, JSGlobalData*); >+ >+ void* start() { return dataAddressAtOffset(0); } >+ virtual size_t size() = 0; >+ void* end() { return reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(start()) + size()); } >+ >+ virtual bool contains(void*) = 0; > >-#if ENABLE(JIT) >- // Execute the code! >- inline JSValue execute(JSStack* stack, CallFrame* callFrame, JSGlobalData* globalData) >- { >- JSValue result = JSValue::decode(ctiTrampoline(m_ref.code().executableAddress(), stack, callFrame, 0, 0, globalData)); >- return globalData->exception ? jsNull() : result; >- } >-#endif >+ static PassRefPtr<JITCode> hostFunction(CodeRef); > >- void* start() const >- { >- return m_ref.code().dataLocation(); >- } >- >- size_t size() const >- { >- ASSERT(m_ref.code().executableAddress()); >- return m_ref.size(); >- } >- >- bool tryToDisassemble(const char* prefix) const >- { >- return m_ref.tryToDisassemble(prefix); >- } >- >- ExecutableMemoryHandle* getExecutableMemory() >- { >- return m_ref.executableMemory(); >- } >- >- JITType jitType() const >- { >- return m_jitType; >- } >- >- // Host functions are a bit special; they have a m_code pointer but they >- // do not individully ref the executable pool containing the trampoline. >- static JITCode HostFunction(CodeRef code) >- { >- return JITCode(code, HostCallThunk); >- } >- >- void clear() >- { >- m_ref.~CodeRef(); >- new (NotNull, &m_ref) CodeRef(); >- } >- >- private: >- JITCode(PassRefPtr<ExecutableMemoryHandle> executableMemory, JITType jitType) >- : m_ref(executableMemory) >- , m_jitType(jitType) >- { >- } >- >- CodeRef m_ref; >- JITType m_jitType; >-#endif // ENABLE(JIT) || ENABLE(LLINT) >- }; >+private: >+ JITType m_jitType; >+}; >+ >+class DirectJITCode : public JITCode { >+public: >+ DirectJITCode(const CodeRef ref, JITType jitType); >+ ~DirectJITCode(); >+ >+ CodePtr addressForCall(); >+ void* executableAddressAtOffset(size_t offset); >+ void* dataAddressAtOffset(size_t offset); >+ unsigned offsetOf(void* pointerIntoCode); >+ size_t size(); >+ bool contains(void*); >+ >+private: >+ CodeRef m_ref; >+}; > > } // namespace JSC > >Index: Source/JavaScriptCore/jit/JITDriver.h >=================================================================== >--- Source/JavaScriptCore/jit/JITDriver.h (revision 146422) >+++ Source/JavaScriptCore/jit/JITDriver.h (working copy) >@@ -38,7 +38,7 @@ > namespace JSC { > > template<typename CodeBlockType> >-inline bool jitCompileIfAppropriate(ExecState* exec, OwnPtr<CodeBlockType>& codeBlock, JITCode& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort) >+inline bool jitCompileIfAppropriate(ExecState* exec, OwnPtr<CodeBlockType>& codeBlock, RefPtr<JITCode>& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort) > { > JSGlobalData& globalData = exec->globalData(); > >@@ -50,7 +50,7 @@ inline bool jitCompileIfAppropriate(Exec > > codeBlock->unlinkIncomingCalls(); > >- JITCode oldJITCode = jitCode; >+ RefPtr<JITCode> oldJITCode = jitCode; > > bool dfgCompiled = false; > if (jitType == JITCode::DFGJIT) >@@ -75,7 +75,7 @@ inline bool jitCompileIfAppropriate(Exec > return true; > } > >-inline bool jitCompileFunctionIfAppropriate(ExecState* exec, OwnPtr<FunctionCodeBlock>& codeBlock, JITCode& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort) >+inline bool jitCompileFunctionIfAppropriate(ExecState* exec, OwnPtr<FunctionCodeBlock>& codeBlock, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort) > { > JSGlobalData& globalData = exec->globalData(); > >@@ -87,7 +87,7 @@ inline bool jitCompileFunctionIfAppropri > > codeBlock->unlinkIncomingCalls(); > >- JITCode oldJITCode = jitCode; >+ RefPtr<JITCode> oldJITCode = jitCode; > MacroAssemblerCodePtr oldJITCodeWithArityCheck = jitCodeWithArityCheck; > > bool dfgCompiled = false; >Index: Source/JavaScriptCore/jit/JITStubs.cpp >=================================================================== >--- Source/JavaScriptCore/jit/JITStubs.cpp (revision 146422) >+++ Source/JavaScriptCore/jit/JITStubs.cpp (working copy) >@@ -2140,7 +2140,7 @@ inline void* lazyLinkFor(CallFrame* call > callFrame->setCodeBlock(0); > > if (executable->isHostFunction()) >- codePtr = executable->generatedJITCodeFor(kind).addressForCall(); >+ codePtr = executable->generatedJITCodeFor(kind)->addressForCall(); > else { > FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable); > if (JSObject* error = functionExecutable->compileFor(callFrame, callee->scope(), kind)) { >@@ -2152,7 +2152,7 @@ inline void* lazyLinkFor(CallFrame* call > || callLinkInfo->callType == CallLinkInfo::CallVarargs) > codePtr = functionExecutable->generatedJITCodeWithArityCheckFor(kind); > else >- codePtr = functionExecutable->generatedJITCodeFor(kind).addressForCall(); >+ codePtr = functionExecutable->generatedJITCodeFor(kind)->addressForCall(); > } > > if (!callLinkInfo->seenOnce()) >@@ -2203,7 +2203,7 @@ DEFINE_STUB_FUNCTION(void*, vm_lazyLinkC > shouldLink = true; > > ASSERT(executable->hasJITCodeForCall()); >- codePtr = executable->generatedJITCodeForCall().addressForCall(); >+ codePtr = executable->generatedJITCodeForCall()->addressForCall(); > if (!callee->executable()->isHostFunction()) { > calleeCodeBlock = &jsCast<FunctionExecutable*>(executable)->generatedBytecodeForCall(); > if (callFrame->argumentCountIncludingThis() < static_cast<size_t>(calleeCodeBlock->numParameters())) { >@@ -2212,7 +2212,7 @@ DEFINE_STUB_FUNCTION(void*, vm_lazyLinkC > } > } > } else if (callee->isHostFunction()) >- codePtr = executable->generatedJITCodeForCall().addressForCall(); >+ codePtr = executable->generatedJITCodeForCall()->addressForCall(); > else { > // Need to clear the code block before compilation, because compilation can GC. > callFrame->setCodeBlock(0); >Index: Source/JavaScriptCore/jit/ThunkGenerators.cpp >=================================================================== >--- Source/JavaScriptCore/jit/ThunkGenerators.cpp (revision 146422) >+++ Source/JavaScriptCore/jit/ThunkGenerators.cpp (working copy) >@@ -139,6 +139,11 @@ static MacroAssemblerCodeRef virtualForG > > hasCodeBlock1.link(&jit); > jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::regT2, FunctionExecutable::offsetOfJITCodeWithArityCheckFor(kind)), JSInterfaceJIT::regT0); >+#if !ASSERT_DISABLED >+ JSInterfaceJIT::Jump ok = jit.branchTestPtr(JSInterfaceJIT::NonZero, JSInterfaceJIT::regT0); >+ jit.breakpoint(); >+ ok.link(&jit); >+#endif > jit.jump(JSInterfaceJIT::regT0); > > slowCase.link(&jit); >Index: Source/JavaScriptCore/llint/LLIntEntrypoints.cpp >=================================================================== >--- Source/JavaScriptCore/llint/LLIntEntrypoints.cpp (revision 146422) >+++ Source/JavaScriptCore/llint/LLIntEntrypoints.cpp (working copy) >@@ -37,53 +37,53 @@ > > namespace JSC { namespace LLInt { > >-void getFunctionEntrypoint(JSGlobalData& globalData, CodeSpecializationKind kind, JITCode& jitCode, MacroAssemblerCodePtr& arityCheck) >+void getFunctionEntrypoint(JSGlobalData& globalData, CodeSpecializationKind kind, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& arityCheck) > { > if (!globalData.canUseJIT()) { > if (kind == CodeForCall) { >- jitCode = JITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_call_prologue), JITCode::InterpreterThunk); >+ jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_call_prologue), JITCode::InterpreterThunk)); > arityCheck = MacroAssemblerCodePtr::createLLIntCodePtr(llint_function_for_call_arity_check); > return; > } > > ASSERT(kind == CodeForConstruct); >- jitCode = JITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_construct_prologue), JITCode::InterpreterThunk); >+ jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_construct_prologue), JITCode::InterpreterThunk)); > arityCheck = MacroAssemblerCodePtr::createLLIntCodePtr(llint_function_for_construct_arity_check); > return; > } > > #if ENABLE(JIT) > if (kind == CodeForCall) { >- jitCode = JITCode(globalData.getCTIStub(functionForCallEntryThunkGenerator), JITCode::InterpreterThunk); >+ jitCode = adoptRef(new DirectJITCode(globalData.getCTIStub(functionForCallEntryThunkGenerator), JITCode::InterpreterThunk)); > arityCheck = globalData.getCTIStub(functionForCallArityCheckThunkGenerator).code(); > return; > } > > ASSERT(kind == CodeForConstruct); >- jitCode = JITCode(globalData.getCTIStub(functionForConstructEntryThunkGenerator), JITCode::InterpreterThunk); >+ jitCode = adoptRef(new DirectJITCode(globalData.getCTIStub(functionForConstructEntryThunkGenerator), JITCode::InterpreterThunk)); > arityCheck = globalData.getCTIStub(functionForConstructArityCheckThunkGenerator).code(); > #endif // ENABLE(JIT) > } > >-void getEvalEntrypoint(JSGlobalData& globalData, JITCode& jitCode) >+void getEvalEntrypoint(JSGlobalData& globalData, RefPtr<JITCode>& jitCode) > { > if (!globalData.canUseJIT()) { >- jitCode = JITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_eval_prologue), JITCode::InterpreterThunk); >+ jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_eval_prologue), JITCode::InterpreterThunk)); > return; > } > #if ENABLE(JIT) >- jitCode = JITCode(globalData.getCTIStub(evalEntryThunkGenerator), JITCode::InterpreterThunk); >+ jitCode = adoptRef(new DirectJITCode(globalData.getCTIStub(evalEntryThunkGenerator), JITCode::InterpreterThunk)); > #endif > } > >-void getProgramEntrypoint(JSGlobalData& globalData, JITCode& jitCode) >+void getProgramEntrypoint(JSGlobalData& globalData, RefPtr<JITCode>& jitCode) > { > if (!globalData.canUseJIT()) { >- jitCode = JITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_program_prologue), JITCode::InterpreterThunk); >+ jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_program_prologue), JITCode::InterpreterThunk)); > return; > } > #if ENABLE(JIT) >- jitCode = JITCode(globalData.getCTIStub(programEntryThunkGenerator), JITCode::InterpreterThunk); >+ jitCode = adoptRef(new DirectJITCode(globalData.getCTIStub(programEntryThunkGenerator), JITCode::InterpreterThunk)); > #endif > } > >Index: Source/JavaScriptCore/llint/LLIntEntrypoints.h >=================================================================== >--- Source/JavaScriptCore/llint/LLIntEntrypoints.h (revision 146422) >+++ Source/JavaScriptCore/llint/LLIntEntrypoints.h (working copy) >@@ -31,11 +31,12 @@ > #if ENABLE(LLINT) > > #include "CodeSpecializationKind.h" >+#include "JITCode.h" >+#include <wtf/RefPtr.h> > > namespace JSC { > > class EvalCodeBlock; >-class JITCode; > class JSGlobalData; > class MacroAssemblerCodePtr; > class MacroAssemblerCodeRef; >@@ -43,16 +44,16 @@ class ProgramCodeBlock; > > namespace LLInt { > >-void getFunctionEntrypoint(JSGlobalData&, CodeSpecializationKind, JITCode&, MacroAssemblerCodePtr& arityCheck); >-void getEvalEntrypoint(JSGlobalData&, JITCode&); >-void getProgramEntrypoint(JSGlobalData&, JITCode&); >+void getFunctionEntrypoint(JSGlobalData&, CodeSpecializationKind, RefPtr<JITCode>&, MacroAssemblerCodePtr& arityCheck); >+void getEvalEntrypoint(JSGlobalData&, RefPtr<JITCode>&); >+void getProgramEntrypoint(JSGlobalData&, RefPtr<JITCode>&); > >-inline void getEntrypoint(JSGlobalData& globalData, EvalCodeBlock*, JITCode& jitCode) >+inline void getEntrypoint(JSGlobalData& globalData, EvalCodeBlock*, RefPtr<JITCode>& jitCode) > { > getEvalEntrypoint(globalData, jitCode); > } > >-inline void getEntrypoint(JSGlobalData& globalData, ProgramCodeBlock*, JITCode& jitCode) >+inline void getEntrypoint(JSGlobalData& globalData, ProgramCodeBlock*, RefPtr<JITCode>& jitCode) > { > getProgramEntrypoint(globalData, jitCode); > } >Index: Source/JavaScriptCore/llint/LLIntSlowPaths.cpp >=================================================================== >--- Source/JavaScriptCore/llint/LLIntSlowPaths.cpp (revision 146422) >+++ Source/JavaScriptCore/llint/LLIntSlowPaths.cpp (working copy) >@@ -287,7 +287,7 @@ inline bool jitCompileAndSetHeuristics(C > #endif > return false; > } >- >+ > CodeBlock::JITCompilationResult result = codeBlock->jitCompile(exec); > switch (result) { > case CodeBlock::AlreadyCompiled: >@@ -330,7 +330,7 @@ static SlowPathReturnType entryOSR(ExecS > LLINT_RETURN_TWO(0, exec); > > if (kind == Prologue) >- LLINT_RETURN_TWO(codeBlock->getJITCode().executableAddressAtOffset(0), exec); >+ LLINT_RETURN_TWO(codeBlock->getJITCode()->executableAddress(), exec); > ASSERT(kind == ArityCheck); > LLINT_RETURN_TWO(codeBlock->getJITCodeWithArityCheck().executableAddress(), exec); > } >@@ -384,7 +384,7 @@ LLINT_SLOW_PATH_DECL(loop_osr) > ASSERT(mapping); > ASSERT(mapping->m_bytecodeIndex == static_cast<unsigned>(pc - codeBlock->instructions().begin())); > >- void* jumpTarget = codeBlock->getJITCode().executableAddressAtOffset(mapping->m_machineCodeOffset); >+ void* jumpTarget = codeBlock->getJITCode()->executableAddressAtOffset(mapping->m_machineCodeOffset); > ASSERT(jumpTarget); > > LLINT_RETURN_TWO(jumpTarget, exec); >Index: Source/JavaScriptCore/runtime/Executable.cpp >=================================================================== >--- Source/JavaScriptCore/runtime/Executable.cpp (revision 146422) >+++ Source/JavaScriptCore/runtime/Executable.cpp (working copy) >@@ -228,7 +228,7 @@ JSObject* EvalExecutable::compileInterna > #endif > > #if ENABLE(JIT) >- Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_evalCodeBlock) + m_jitCodeForCall.size()); >+ Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_evalCodeBlock) + m_jitCodeForCall->size()); > #else > Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_evalCodeBlock)); > #endif >@@ -329,7 +329,7 @@ JSObject* ProgramExecutable::compileInte > #endif > > #if ENABLE(JIT) >- Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_programCodeBlock) + m_jitCodeForCall.size()); >+ Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_programCodeBlock) + m_jitCodeForCall->size()); > #else > Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_programCodeBlock)); > #endif >@@ -540,7 +540,7 @@ JSObject* FunctionExecutable::compileFor > #endif > > #if ENABLE(JIT) >- Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForCall) + m_jitCodeForCall.size()); >+ Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForCall) + m_jitCodeForCall->size()); > #else > Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForCall)); > #endif >@@ -576,7 +576,7 @@ JSObject* FunctionExecutable::compileFor > #endif > > #if ENABLE(JIT) >- Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForConstruct) + m_jitCodeForConstruct.size()); >+ Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForConstruct) + m_jitCodeForConstruct->size()); > #else > Heap::heap(this)->reportExtraMemoryCost(sizeof(*m_codeBlockForConstruct)); > #endif >Index: Source/JavaScriptCore/runtime/Executable.h >=================================================================== >--- Source/JavaScriptCore/runtime/Executable.h (revision 146422) >+++ Source/JavaScriptCore/runtime/Executable.h (working copy) >@@ -117,19 +117,19 @@ namespace JSC { > static void clearCodeVirtual(ExecutableBase*); > > #if ENABLE(JIT) >- JITCode& generatedJITCodeForCall() >+ PassRefPtr<JITCode> generatedJITCodeForCall() > { > ASSERT(m_jitCodeForCall); > return m_jitCodeForCall; > } > >- JITCode& generatedJITCodeForConstruct() >+ PassRefPtr<JITCode> generatedJITCodeForConstruct() > { > ASSERT(m_jitCodeForConstruct); > return m_jitCodeForConstruct; > } > >- JITCode& generatedJITCodeFor(CodeSpecializationKind kind) >+ PassRefPtr<JITCode> generatedJITCodeFor(CodeSpecializationKind kind) > { > if (kind == CodeForCall) > return generatedJITCodeForCall(); >@@ -177,14 +177,6 @@ namespace JSC { > return hasJITCodeForConstruct(); > } > >- static ptrdiff_t offsetOfJITCodeFor(CodeSpecializationKind kind) >- { >- if (kind == CodeForCall) >- return OBJECT_OFFSETOF(ExecutableBase, m_jitCodeForCall); >- ASSERT(kind == CodeForConstruct); >- return OBJECT_OFFSETOF(ExecutableBase, m_jitCodeForConstruct); >- } >- > static ptrdiff_t offsetOfJITCodeWithArityCheckFor(CodeSpecializationKind kind) > { > if (kind == CodeForCall) >@@ -215,29 +207,29 @@ namespace JSC { > #if ENABLE(JIT) || ENABLE(LLINT_C_LOOP) > MacroAssemblerCodePtr hostCodeEntryFor(CodeSpecializationKind kind) > { >- #if ENABLE(JIT) >- return generatedJITCodeFor(kind).addressForCall(); >- #else >+#if ENABLE(JIT) >+ return generatedJITCodeFor(kind)->addressForCall(); >+#else > return LLInt::CLoop::hostCodeEntryFor(kind); >- #endif >+#endif > } > > MacroAssemblerCodePtr jsCodeEntryFor(CodeSpecializationKind kind) > { >- #if ENABLE(JIT) >- return generatedJITCodeFor(kind).addressForCall(); >- #else >+#if ENABLE(JIT) >+ return generatedJITCodeFor(kind)->addressForCall(); >+#else > return LLInt::CLoop::jsCodeEntryFor(kind); >- #endif >+#endif > } > > MacroAssemblerCodePtr jsCodeWithArityCheckEntryFor(CodeSpecializationKind kind) > { >- #if ENABLE(JIT) >+#if ENABLE(JIT) > return generatedJITCodeWithArityCheckFor(kind); >- #else >+#else > return LLInt::CLoop::jsCodeEntryWithArityCheckFor(kind); >- #endif >+#endif > } > > static void* catchRoutineFor(HandlerInfo* handler, Instruction* catchPCForInterpreter) >@@ -257,8 +249,8 @@ namespace JSC { > ExecutableBase* m_next; > > #if ENABLE(JIT) >- JITCode m_jitCodeForCall; >- JITCode m_jitCodeForConstruct; >+ RefPtr<JITCode> m_jitCodeForCall; >+ RefPtr<JITCode> m_jitCodeForConstruct; > MacroAssemblerCodePtr m_jitCodeForCallWithArityCheck; > MacroAssemblerCodePtr m_jitCodeForConstructWithArityCheck; > #endif >@@ -276,10 +268,10 @@ namespace JSC { > NativeExecutable* executable; > if (!callThunk) { > executable = new (NotNull, allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, function, constructor); >- executable->finishCreation(globalData, JITCode(), JITCode(), intrinsic); >+ executable->finishCreation(globalData, 0, 0, intrinsic); > } else { > executable = new (NotNull, allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, function, constructor); >- executable->finishCreation(globalData, JITCode::HostFunction(callThunk), JITCode::HostFunction(constructThunk), intrinsic); >+ executable->finishCreation(globalData, JITCode::hostFunction(callThunk), JITCode::hostFunction(constructThunk), intrinsic); > } > return executable; > } >@@ -328,13 +320,13 @@ namespace JSC { > > protected: > #if ENABLE(JIT) >- void finishCreation(JSGlobalData& globalData, JITCode callThunk, JITCode constructThunk, Intrinsic intrinsic) >+ void finishCreation(JSGlobalData& globalData, PassRefPtr<JITCode> callThunk, PassRefPtr<JITCode> constructThunk, Intrinsic intrinsic) > { > Base::finishCreation(globalData); >+ m_jitCodeForCallWithArityCheck = callThunk ? callThunk->addressForCall() : MacroAssemblerCodePtr(); >+ m_jitCodeForConstructWithArityCheck = constructThunk ? constructThunk->addressForCall() : MacroAssemblerCodePtr(); > m_jitCodeForCall = callThunk; > m_jitCodeForConstruct = constructThunk; >- m_jitCodeForCallWithArityCheck = callThunk.addressForCall(); >- m_jitCodeForConstructWithArityCheck = constructThunk.addressForCall(); > m_intrinsic = intrinsic; > } > #endif >@@ -459,7 +451,7 @@ namespace JSC { > } > > #if ENABLE(JIT) >- JITCode& generatedJITCode() >+ PassRefPtr<JITCode> generatedJITCode() > { > return generatedJITCodeForCall(); > } >@@ -531,7 +523,7 @@ namespace JSC { > JSObject* checkSyntax(ExecState*); > > #if ENABLE(JIT) >- JITCode& generatedJITCode() >+ PassRefPtr<JITCode> generatedJITCode() > { > return generatedJITCodeForCall(); > } >Index: Source/JavaScriptCore/runtime/ExecutionHarness.h >=================================================================== >--- Source/JavaScriptCore/runtime/ExecutionHarness.h (revision 146422) >+++ Source/JavaScriptCore/runtime/ExecutionHarness.h (working copy) >@@ -36,7 +36,7 @@ > namespace JSC { > > template<typename CodeBlockType> >-inline bool prepareForExecution(ExecState* exec, OwnPtr<CodeBlockType>& codeBlock, JITCode& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex) >+inline bool prepareForExecution(ExecState* exec, OwnPtr<CodeBlockType>& codeBlock, RefPtr<JITCode>& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex) > { > #if ENABLE(LLINT) > if (JITCode::isBaselineCode(jitType)) { >@@ -51,7 +51,7 @@ inline bool prepareForExecution(ExecStat > return jitCompileIfAppropriate(exec, codeBlock, jitCode, jitType, bytecodeIndex, JITCode::isBaselineCode(jitType) ? JITCompilationMustSucceed : JITCompilationCanFail); > } > >-inline bool prepareFunctionForExecution(ExecState* exec, OwnPtr<FunctionCodeBlock>& codeBlock, JITCode& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType, unsigned bytecodeIndex, CodeSpecializationKind kind) >+inline bool prepareFunctionForExecution(ExecState* exec, OwnPtr<FunctionCodeBlock>& codeBlock, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType, unsigned bytecodeIndex, CodeSpecializationKind kind) > { > #if ENABLE(LLINT) > if (JITCode::isBaselineCode(jitType)) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
webkit-ews
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 113437
:
195391
|
195393