WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
work in progress
blah.patch (text/plain), 30.63 KB, created by
Filip Pizlo
on 2013-08-26 14:57:41 PDT
(
hide
)
Description:
work in progress
Filename:
MIME Type:
Creator:
Filip Pizlo
Created:
2013-08-26 14:57:41 PDT
Size:
30.63 KB
patch
obsolete
>Index: Source/JavaScriptCore/bytecode/CodeBlock.cpp >=================================================================== >--- Source/JavaScriptCore/bytecode/CodeBlock.cpp (revision 154632) >+++ Source/JavaScriptCore/bytecode/CodeBlock.cpp (working copy) >@@ -2689,6 +2689,48 @@ void CodeBlock::copyPostParseDataFromAlt > copyPostParseDataFrom(m_alternative.get()); > } > >+CompilationResult CodeBlock::prepareForExecution( >+ ExecState* exec, JITCode::JITType jitType, JITCompilationEffort effort, >+ unsigned bytecodeIndex, PassRefPtr<DeferredCompilationCallback> callback) >+{ >+ VM& vm = exec->vm(); >+ >+ if (jitType == JITCode::InterpreterThunk) { >+ switch (codeType()) { >+ case GlobalCode: >+ LLInt::getEntrypoint(vm, static_cast<GlobalCodeBlock*>(this)); >+ break; >+ case EvalCode: >+ LLInt::getEntrypoint(vm, static_cast<EvalCodeBlock*>(this)); >+ break; >+ case FunctionCode: >+ LLInt::getFunctionEntrypoint(vm, static_cast<FunctionCodeBlock*>(this)); >+ break; >+ } >+ return CompilationSuccessful; >+ } >+ >+#if ENABLE(JIT) >+ if (JITCode::isOptimizingJIT(jitType)) { >+ ASSERT(effort == JITCompilationCanFail); >+ CompilationResult result = DFG::tryCompile(exec, this, bytecodeIndex, callback); >+ ASSERT(result != CompilationDeferred || callback); >+ return result; >+ } >+ >+ MacroAssemblerCodePtr jitCodeWithArityCheck; >+ RefPtr<JITCode> jitCode = JIT::compile(&vm, this, effort, &jitCodeWithArityCheck); >+ if (!jitCode) >+ return CompilationFailed; >+ codeBlock->setJITCode(jitCode, jitCodeWithArityCheck); >+ return CompilationSuccessful; >+#else >+ UNUSED_PARAM(effort); >+ UNUSED_PARAM(bytecodeIndex); >+ return CompilationFailed; >+#endif // ENABLE(JIT) >+} >+ > #if ENABLE(JIT) > void CodeBlock::reoptimize() > { >@@ -2726,11 +2768,6 @@ JSObject* ProgramCodeBlock::compileOptim > return error; > } > >-CompilationResult ProgramCodeBlock::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan) >-{ >- return static_cast<ProgramExecutable*>(ownerExecutable())->replaceWithDeferredOptimizedCode(plan); >-} >- > JSObject* EvalCodeBlock::compileOptimized(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex) > { > if (JITCode::isHigherTier(replacement()->jitType(), jitType())) { >@@ -2741,11 +2778,6 @@ JSObject* EvalCodeBlock::compileOptimize > return error; > } > >-CompilationResult EvalCodeBlock::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan) >-{ >- return static_cast<EvalExecutable*>(ownerExecutable())->replaceWithDeferredOptimizedCode(plan); >-} >- > JSObject* FunctionCodeBlock::compileOptimized(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex) > { > if (JITCode::isHigherTier(replacement()->jitType(), jitType())) { >@@ -2755,11 +2787,6 @@ JSObject* FunctionCodeBlock::compileOpti > JSObject* error = static_cast<FunctionExecutable*>(ownerExecutable())->compileOptimizedFor(exec, scope, result, bytecodeIndex, m_isConstructor ? CodeForConstruct : CodeForCall); > return error; > } >- >-CompilationResult FunctionCodeBlock::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan) >-{ >- return static_cast<FunctionExecutable*>(ownerExecutable())->replaceWithDeferredOptimizedCodeFor(plan, m_isConstructor ? CodeForConstruct : CodeForCall); >-} > #endif // ENABLE(DFG_JIT) > > DFG::CapabilityLevel ProgramCodeBlock::capabilityLevelInternal() >Index: Source/JavaScriptCore/bytecode/CodeBlock.h >=================================================================== >--- Source/JavaScriptCore/bytecode/CodeBlock.h (revision 154632) >+++ Source/JavaScriptCore/bytecode/CodeBlock.h (working copy) >@@ -48,6 +48,7 @@ > #include "DFGOSREntry.h" > #include "DFGOSRExit.h" > #include "DFGVariableEventStream.h" >+#include "DeferredCompilationCallback.h" > #include "EvalCodeCache.h" > #include "ExecutionCounter.h" > #include "ExpressionRangeInfo.h" >@@ -292,17 +293,9 @@ public: > } > #if ENABLE(DFG_JIT) > virtual JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex) = 0; >- virtual CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>) = 0; > #endif // ENABLE(DFG_JIT) > void jettison(); >- CompilationResult jitCompile(ExecState* exec) >- { >- if (jitType() != JITCode::InterpreterThunk) { >- ASSERT(jitType() == JITCode::BaselineJIT); >- return CompilationNotNeeded; >- } >- return jitCompileImpl(exec); >- } >+ CompilationResult prepareForExecution(ExecState*, JITCode::JITType, JITCompilationEffort, unsigned bytecodeIndex, PassRefPtr<DeferredCompilationCallback> = 0); > virtual CodeBlock* replacement() = 0; > > virtual DFG::CapabilityLevel capabilityLevelInternal() = 0; >@@ -1196,7 +1189,6 @@ public: > protected: > #if ENABLE(DFG_JIT) > virtual JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex); >- virtual CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>); > #endif // ENABLE(DFG_JIT) > > virtual void jettisonImpl(); >@@ -1225,7 +1217,6 @@ public: > protected: > #if ENABLE(DFG_JIT) > virtual JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex); >- virtual CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>); > #endif // ENABLE(DFG_JIT) > > virtual void jettisonImpl(); >@@ -1254,7 +1245,6 @@ public: > protected: > #if ENABLE(DFG_JIT) > virtual JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex); >- virtual CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>); > #endif // ENABLE(DFG_JIT) > > virtual void jettisonImpl(); >Index: Source/JavaScriptCore/bytecode/DeferredCompilationCallback.cpp >=================================================================== >--- Source/JavaScriptCore/bytecode/DeferredCompilationCallback.cpp (revision 0) >+++ Source/JavaScriptCore/bytecode/DeferredCompilationCallback.cpp (working copy) >@@ -0,0 +1,35 @@ >+/* >+ * Copyright (C) 2012 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "DeferredCompilationCallback.h" >+ >+namespace JSC { >+ >+DeferredCompilationCallback::DeferredCompilationCallback() { } >+DeferredCompilationCallback::~DeferredCompilationCallback() { } >+ >+} // JSC >+ >Index: Source/JavaScriptCore/bytecode/DeferredCompilationCallback.h >=================================================================== >--- Source/JavaScriptCore/bytecode/DeferredCompilationCallback.h (revision 0) >+++ Source/JavaScriptCore/bytecode/DeferredCompilationCallback.h (working copy) >@@ -0,0 +1,47 @@ >+/* >+ * Copyright (C) 2012 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef DeferredCompilationCallback_h >+#define DeferredCompilationCallback_h >+ >+#include "CompilationResult.h" >+#include <wtf/RefCounted.h> >+ >+namespace JSC { >+ >+class CodeBlock; >+ >+class DeferredCompilationCallback : public RefCounted<DeferredCompilationCallback> { >+public: >+ DeferredCompilationCallback(); >+ virtual ~DeferredCompilationCallback(); >+ >+ virtual void compilationDidComplete(CodeBlock*, CompilationResult) = 0; >+}; >+ >+} // namespace JSC >+ >+#endif // DeferredCompilationCallback_h >+ >Index: Source/JavaScriptCore/dfg/DFGPlan.cpp >=================================================================== >--- Source/JavaScriptCore/dfg/DFGPlan.cpp (revision 154632) >+++ Source/JavaScriptCore/dfg/DFGPlan.cpp (working copy) >@@ -299,6 +299,8 @@ CompilationResult Plan::finalize(RefPtr< > > reallyAdd(jitCode->dfgCommon()); > >+ >+ > return CompilationSuccessful; > } > >Index: Source/JavaScriptCore/heap/Heap.h >=================================================================== >--- Source/JavaScriptCore/heap/Heap.h (revision 154632) >+++ Source/JavaScriptCore/heap/Heap.h (working copy) >@@ -184,6 +184,8 @@ namespace JSC { > const JITStubRoutineSet& jitStubRoutines() { return m_jitStubRoutines; } > > void addReference(JSCell*, ArrayBuffer*); >+ >+ bool isDeferred() const { return !!m_deferralDepth; } > > private: > friend class CodeBlock; >Index: Source/JavaScriptCore/jit/JITStubs.cpp >=================================================================== >--- Source/JavaScriptCore/jit/JITStubs.cpp (revision 154632) >+++ Source/JavaScriptCore/jit/JITStubs.cpp (working copy) >@@ -1019,7 +1019,7 @@ DEFINE_STUB_FUNCTION(void, optimize) > if (Options::verboseOSR()) > dataLog("Considering OSR ", *codeBlock, " -> ", *codeBlock->replacement(), ".\n"); > // If we have an optimized replacement, then it must be the case that we entered >- // cti_optimize from a loop. That's because is there's an optimized replacement, >+ // cti_optimize from a loop. That's because if there's an optimized replacement, > // then all calls to this function will be relinked to the replacement and so > // the prologue OSR will never fire. > >Index: Source/JavaScriptCore/llint/LLIntEntrypoints.cpp >=================================================================== >--- Source/JavaScriptCore/llint/LLIntEntrypoints.cpp (revision 154632) >+++ Source/JavaScriptCore/llint/LLIntEntrypoints.cpp (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 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 >@@ -37,53 +37,67 @@ > > namespace JSC { namespace LLInt { > >-void getFunctionEntrypoint(VM& vm, CodeSpecializationKind kind, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& arityCheck) >+void getFunctionEntrypoint(VM& vm, FunctionCodeBlock* codeBlock) > { >+ CodeSpecializationKind kind = codeBlock->specializationKind(); >+ > if (!vm.canUseJIT()) { > if (kind == CodeForCall) { >- jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_call_prologue), JITCode::InterpreterThunk)); >- arityCheck = MacroAssemblerCodePtr::createLLIntCodePtr(llint_function_for_call_arity_check); >+ codeBlock->setJITCode( >+ adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_call_prologue), JITCode::InterpreterThunk)), >+ MacroAssemblerCodePtr::createLLIntCodePtr(llint_function_for_call_arity_check)); > return; > } > > ASSERT(kind == CodeForConstruct); >- jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_construct_prologue), JITCode::InterpreterThunk)); >- arityCheck = MacroAssemblerCodePtr::createLLIntCodePtr(llint_function_for_construct_arity_check); >+ codeBlock->setJITCode( >+ adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_construct_prologue), JITCode::InterpreterThunk)), >+ MacroAssemblerCodePtr::createLLIntCodePtr(llint_function_for_construct_arity_check)); > return; > } > > #if ENABLE(JIT) > if (kind == CodeForCall) { >- jitCode = adoptRef(new DirectJITCode(vm.getCTIStub(functionForCallEntryThunkGenerator), JITCode::InterpreterThunk)); >- arityCheck = vm.getCTIStub(functionForCallArityCheckThunkGenerator).code(); >+ codeBlock->setJITCode( >+ adoptRef(new DirectJITCode(vm.getCTIStub(functionForCallEntryThunkGenerator), JITCode::InterpreterThunk)), >+ vm.getCTIStub(functionForCallArityCheckThunkGenerator).code()); > return; > } > > ASSERT(kind == CodeForConstruct); >- jitCode = adoptRef(new DirectJITCode(vm.getCTIStub(functionForConstructEntryThunkGenerator), JITCode::InterpreterThunk)); >- arityCheck = vm.getCTIStub(functionForConstructArityCheckThunkGenerator).code(); >+ codeBlock->setJITCode( >+ adoptRef(new DirectJITCode(vm.getCTIStub(functionForConstructEntryThunkGenerator), JITCode::InterpreterThunk)), >+ vm.getCTIStub(functionForConstructArityCheckThunkGenerator).code()); > #endif // ENABLE(JIT) > } > >-void getEvalEntrypoint(VM& vm, RefPtr<JITCode>& jitCode) >+void getEvalEntrypoint(VM& vm, EvalCodeBlock* codeBlock) > { > if (!vm.canUseJIT()) { >- jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_eval_prologue), JITCode::InterpreterThunk)); >+ codeBlock->setJITCode( >+ adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_eval_prologue), JITCode::InterpreterThunk)), >+ MacroAssemblerCodePtr()); > return; > } >-#if ENABLE(JIT) >- jitCode = adoptRef(new DirectJITCode(vm.getCTIStub(evalEntryThunkGenerator), JITCode::InterpreterThunk)); >+#if ENABLE(JIT) >+ codeBlock->setJITCode( >+ adoptRef(new DirectJITCode(vm.getCTIStub(evalEntryThunkGenerator), JITCode::InterpreterThunk)), >+ MacroAssemblerCodePtr()); > #endif > } > > void getProgramEntrypoint(VM& vm, RefPtr<JITCode>& jitCode) > { > if (!vm.canUseJIT()) { >- jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_program_prologue), JITCode::InterpreterThunk)); >+ codeBlock->setJITCode( >+ adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_program_prologue), JITCode::InterpreterThunk)), >+ MacroAssemblerCodePtr()); > return; > } > #if ENABLE(JIT) >- jitCode = adoptRef(new DirectJITCode(vm.getCTIStub(programEntryThunkGenerator), JITCode::InterpreterThunk)); >+ codeBlock->setJITCode( >+ adoptRef(new DirectJITCode(vm.getCTIStub(programEntryThunkGenerator), JITCode::InterpreterThunk)), >+ MacroAssemblerCodePtr()); > #endif > } > >Index: Source/JavaScriptCore/llint/LLIntEntrypoints.h >=================================================================== >--- Source/JavaScriptCore/llint/LLIntEntrypoints.h (revision 154632) >+++ Source/JavaScriptCore/llint/LLIntEntrypoints.h (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 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 >@@ -44,18 +44,18 @@ class ProgramCodeBlock; > > namespace LLInt { > >-void getFunctionEntrypoint(VM&, CodeSpecializationKind, RefPtr<JITCode>&, MacroAssemblerCodePtr& arityCheck); >-void getEvalEntrypoint(VM&, RefPtr<JITCode>&); >-void getProgramEntrypoint(VM&, RefPtr<JITCode>&); >+void getFunctionEntrypoint(VM&, FunctionCodeBlock*); >+void getEvalEntrypoint(VM&, EvalCodeBlock*); >+void getProgramEntrypoint(VM&, ProgramCodeBlock*); > >-inline void getEntrypoint(VM& vm, EvalCodeBlock*, RefPtr<JITCode>& jitCode) >+inline void getEntrypoint(VM& vm, EvalCodeBlock* codeBlock) > { >- getEvalEntrypoint(vm, jitCode); >+ getEvalEntrypoint(vm, codeBlock); > } > >-inline void getEntrypoint(VM& vm, ProgramCodeBlock*, RefPtr<JITCode>& jitCode) >+inline void getEntrypoint(VM& vm, ProgramCodeBlock* codeBlock) > { >- getProgramEntrypoint(vm, jitCode); >+ getProgramEntrypoint(vm, codeBlock); > } > > } } // namespace JSC::LLInt >Index: Source/JavaScriptCore/runtime/CompilationResult.h >=================================================================== >--- Source/JavaScriptCore/runtime/CompilationResult.h (revision 154632) >+++ Source/JavaScriptCore/runtime/CompilationResult.h (working copy) >@@ -30,7 +30,29 @@ > > namespace JSC { > >-enum CompilationResult { CompilationFailed, CompilationInvalidated, CompilationSuccessful, CompilationNotNeeded, CompilationDeferred }; >+enum CompilationResult { >+ // We tried to compile the code, but we couldn't compile it. This could be >+ // because we ran out of memory, or because the compiler encountered an >+ // internal error and decided to bail out gracefully. Either way, this implies >+ // that we shouldn't try to compile this code block again. >+ CompilationFailed, >+ >+ // The profiling assumptions that were fed into the compiler were invalidated >+ // even before we finished compiling. This means we should try again: in such >+ // cases the profiling will now be updated and the next compilation won't >+ // encounter the same problem. But it does mean that we should exercise >+ // exponential back-off, to get even more profiling so that new profiling >+ // pathologies aren't encountered. >+ CompilationInvalidated, >+ >+ // The compilation succeeded and the code block now has JITCode for the newly >+ // compiled code. >+ CompilationSuccessful, >+ >+ // We decided to do the compilation asynchronously. This means that we haven't >+ // yet compiled the code. >+ CompilationDeferred >+}; > > } // namespace JSC > >Index: Source/JavaScriptCore/runtime/Executable.cpp >=================================================================== >--- Source/JavaScriptCore/runtime/Executable.cpp (revision 154632) >+++ Source/JavaScriptCore/runtime/Executable.cpp (working copy) >@@ -75,6 +75,81 @@ Intrinsic ExecutableBase::intrinsic() co > } > #endif > >+void ExecutableBase::installCode(CodeBlock* genericCodeBlock) >+{ >+ VM& vm = *genericCodeBlock->vm(); >+ >+ ASSERT(vm.heap.isDeferred()); >+ >+ if (jitCode) >+ vm.heap.reportExtraMemoryCost(sizeof(CodeBlock) + jitCode->size()); >+ else >+ vm.heap.reportExtraMemoryCost(sizeof(CodeBlock)); >+ >+ CodeSpecializationKind kind = genericCodeBlock->specializationKind(); >+ >+ RefPtr<CodeBlock> oldCodeBlock; >+ >+ switch (kind) { >+ case CodeForCall: >+ m_jitCodeForCall = codeBlock->jitCode(); >+ m_jitCodeForCallWithArityCheck = codeBlock->jitCodeWithArityCheck(); >+ m_numParametersForCall = codeBlock->numParameters(); >+ break; >+ case CodeForConstruct: >+ m_jitCodeForConstruct = codeBlock->jitCode(); >+ m_jitCodeForConstructWithArityCheck = codeBlock->jitCodeWithArityCheck(); >+ m_numParametersForConstruct = codeBlock->numParameters(); >+ break; >+ } >+ >+ switch (genericCodeBlock->codeType()) { >+ case GlobalCode: { >+ ProgramExecutable* executabe = jsCast<ProgramExecutable*>(this); >+ GlobalCodeBlock* codeBlock = static_cast<GlobalCodeBlock*>(genericCodeBlock); >+ >+ ASSERT(!codeBlock->jitCodeWithArityCheck()); >+ ASSERT(!codeBlock->numParameters()); >+ ASSERT(kind == CodeForCall); >+ >+ oldCodeBlock = executable->m_programCodeBlock; >+ executable->m_programCodeBlock = codeBlock; >+ break; >+ } >+ >+ case EvalCode: { >+ EvalExecutable* executable = jsCast<EvalExecutable*>(this); >+ EvalCodeBlock* codeBlock = static_cast<EvalCodeBlock*>(genericCodeBlock); >+ >+ ASSERT(!jitCodeWithArityCheck); >+ ASSERT(!codeBlock->numParameters()); >+ ASSERT(kind == CodeForCall); >+ >+ oldCodeBlock = executable->m_evalCodeBlock; >+ executable->m_evalCodeBlock = codeBlock; >+ break; >+ } >+ >+ case FunctionCode: { >+ FunctionExecutable* executable = jsCast<FunctionExecutable*>(this); >+ FunctionCodeBlock* codeBlock = static_cast<FunctionCodeBlock*>(genericCodeBlock); >+ >+ switch (kind) { >+ case CodeForCall: >+ oldCodeBlock = executable->m_codeBlockForCall; >+ executable->m_codeBlockForCall = codeBlock; >+ break; >+ case CodeForConstruct: >+ oldCodeBlock = executable->m_codeBlockForConstruct; >+ executable->m_codeBlockForConstruct = codeBlock; >+ break; >+ } >+ break; >+ } } >+ >+ oldCodeBlock->unlinkIncomingCalls(); >+} >+ > const ClassInfo NativeExecutable::s_info = { "NativeExecutable", &ExecutableBase::s_info, 0, 0, CREATE_METHOD_TABLE(NativeExecutable) }; > > #if ENABLE(JIT) >@@ -240,14 +315,6 @@ JSObject* EvalExecutable::compileInterna > return 0; > } > >-#if ENABLE(DFG_JIT) >-CompilationResult EvalExecutable::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan) >-{ >- return JSC::replaceWithDeferredOptimizedCode( >- plan, m_evalCodeBlock, m_jitCodeForCall, 0, 0); >-} >-#endif // ENABLE(DFG_JIT) >- > #if ENABLE(JIT) > void EvalExecutable::jettisonOptimizedCode(VM& vm) > { >@@ -344,14 +411,6 @@ JSObject* ProgramExecutable::compileInte > return 0; > } > >-#if ENABLE(DFG_JIT) >-CompilationResult ProgramExecutable::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan) >-{ >- return JSC::replaceWithDeferredOptimizedCode( >- plan, m_programCodeBlock, m_jitCodeForCall, 0, 0); >-} >-#endif // ENABLE(DFG_JIT) >- > #if ENABLE(JIT) > void ProgramExecutable::jettisonOptimizedCode(VM& vm) > { >@@ -538,15 +597,6 @@ JSObject* FunctionExecutable::compileFor > return 0; > } > >-#if ENABLE(DFG_JIT) >-CompilationResult FunctionExecutable::replaceWithDeferredOptimizedCodeForCall(PassRefPtr<DFG::Plan> plan) >-{ >- return JSC::replaceWithDeferredOptimizedCode( >- plan, m_codeBlockForCall, m_jitCodeForCall, &m_jitCodeForCallWithArityCheck, >- &m_numParametersForCall); >-} >-#endif // ENABLE(DFG_JIT) >- > JSObject* FunctionExecutable::compileForConstructInternal(ExecState* exec, JSScope* scope, JITCode::JITType jitType, CompilationResult* result, unsigned bytecodeIndex) > { > SamplingRegion samplingRegion(samplingDescription(jitType)); >@@ -570,15 +620,6 @@ JSObject* FunctionExecutable::compileFor > return 0; > } > >-#if ENABLE(DFG_JIT) >-CompilationResult FunctionExecutable::replaceWithDeferredOptimizedCodeForConstruct(PassRefPtr<DFG::Plan> plan) >-{ >- return JSC::replaceWithDeferredOptimizedCode( >- plan, m_codeBlockForConstruct, m_jitCodeForConstruct, >- &m_jitCodeForConstructWithArityCheck, &m_numParametersForConstruct); >-} >-#endif // ENABLE(DFG_JIT) >- > #if ENABLE(JIT) > void FunctionExecutable::jettisonOptimizedCodeForCall(VM& vm) > { >Index: Source/JavaScriptCore/runtime/Executable.h >=================================================================== >--- Source/JavaScriptCore/runtime/Executable.h (revision 154632) >+++ Source/JavaScriptCore/runtime/Executable.h (working copy) >@@ -244,8 +244,11 @@ public: > return LLInt::CLoop::catchRoutineFor(catchPCForInterpreter); > #endif > } >+ > #endif // ENABLE(JIT || ENABLE(LLINT_C_LOOP) > >+ void installCode(CodeBlock*, PassRefPtr<JITCode>, MacroAssemblerCodePtr jitCodeWithArityCheck, CodeSpecializationKind); >+ > protected: > ExecutableBase* m_prev; > ExecutableBase* m_next; >@@ -442,7 +445,6 @@ public: > > #if ENABLE(DFG_JIT) > JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex); >- CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>); > #endif // ENABLE(DFG_JIT) > > #if ENABLE(JIT) >@@ -481,6 +483,7 @@ public: > unsigned numberOfFunctionDecls() { return m_unlinkedEvalCodeBlock->numberOfFunctionDecls(); } > > private: >+ friend class ExecutableBase; > static const unsigned StructureFlags = OverridesVisitChildren | ScriptExecutable::StructureFlags; > EvalExecutable(ExecState*, const SourceCode&, bool); > >@@ -520,7 +523,6 @@ public: > > #if ENABLE(DFG_JIT) > JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex); >- CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>); > #endif // ENABLE(DFG_JIT) > > #if ENABLE(JIT) >@@ -557,6 +559,8 @@ public: > ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false); } > > private: >+ friend class ExecutableBase; >+ > static const unsigned StructureFlags = OverridesVisitChildren | ScriptExecutable::StructureFlags; > > ProgramExecutable(ExecState*, const SourceCode&); >@@ -614,7 +618,6 @@ public: > > #if ENABLE(DFG_JIT) > JSObject* compileOptimizedForCall(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex); >- CompilationResult replaceWithDeferredOptimizedCodeForCall(PassRefPtr<DFG::Plan>); > #endif // ENABLE(DFG_JIT) > > #if ENABLE(JIT) >@@ -645,7 +648,6 @@ public: > > #if ENABLE(DFG_JIT) > JSObject* compileOptimizedForConstruct(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex); >- CompilationResult replaceWithDeferredOptimizedCodeForConstruct(PassRefPtr<DFG::Plan>); > #endif // ENABLE(DFG_JIT) > > #if ENABLE(JIT) >@@ -689,12 +691,6 @@ public: > return compileOptimizedForConstruct(exec, scope, result, bytecodeIndex); > } > >- CompilationResult replaceWithDeferredOptimizedCodeFor(PassRefPtr<DFG::Plan> plan, CodeSpecializationKind kind) >- { >- if (kind == CodeForCall) >- return replaceWithDeferredOptimizedCodeForCall(plan); >- return replaceWithDeferredOptimizedCodeForConstruct(plan); >- } > #endif // ENABLE(DFG_JIT) > > #if ENABLE(JIT) >@@ -786,6 +782,8 @@ private: > return false; > } > >+ friend class ExecutableBase; >+ > static const unsigned StructureFlags = OverridesVisitChildren | ScriptExecutable::StructureFlags; > WriteBarrier<UnlinkedFunctionExecutable> m_unlinkedExecutable; > RefPtr<FunctionCodeBlock> m_codeBlockForCall; >Index: Source/JavaScriptCore/runtime/ExecutionHarness.h >=================================================================== >--- Source/JavaScriptCore/runtime/ExecutionHarness.h (revision 154632) >+++ Source/JavaScriptCore/runtime/ExecutionHarness.h (working copy) >@@ -45,7 +45,7 @@ inline CompilationResult prepareForExecu > #if ENABLE(LLINT) > if (JITCode::isBaselineCode(jitType)) { > // Start off in the low level interpreter. >- LLInt::getEntrypoint(exec->vm(), codeBlock, jitCode); >+ LLInt::getEntrypoint(exec->vm(), codeBlock); > if (exec->vm().m_perBytecodeProfiler) > exec->vm().m_perBytecodeProfiler->ensureBytecodesFor(codeBlock); > return CompilationSuccessful; >@@ -70,7 +70,7 @@ inline CompilationResult prepareFunction > #if ENABLE(LLINT) > if (JITCode::isBaselineCode(jitType)) { > // Start off in the low level interpreter. >- LLInt::getFunctionEntrypoint(exec->vm(), kind, jitCode, jitCodeWithArityCheck); >+ LLInt::getFunctionEntrypoint(exec->vm(), codeBlock); > if (exec->vm().m_perBytecodeProfiler) > exec->vm().m_perBytecodeProfiler->ensureBytecodesFor(codeBlock); > return CompilationSuccessful; >@@ -88,44 +88,15 @@ inline CompilationResult prepareFunction > } > > template<typename CodeBlockType> >-inline CompilationResult installOptimizedCode( >- CompilationResult result, RefPtr<CodeBlockType>& sink, CodeBlockType* codeBlock, >- PassRefPtr<JITCode> jitCode, MacroAssemblerCodePtr jitCodeWithArityCheck, >- int* numParameters) >-{ >- UNUSED_PARAM(jitCodeWithArityCheck); >- if (result != CompilationSuccessful) >- return result; >- >-#if ENABLE(JIT) >- codeBlock->setJITCode(jitCode, jitCodeWithArityCheck); >-#endif >- >- sink = codeBlock; >- >- if (numParameters) >- *numParameters = codeBlock->numParameters(); >- >- if (jitCode) >- codeBlock->vm()->heap.reportExtraMemoryCost(sizeof(*codeBlock) + jitCode->size()); >- else >- codeBlock->vm()->heap.reportExtraMemoryCost(sizeof(*codeBlock)); >- >- if (sink != codeBlock) { >- // This can happen if we GC and decide that the code is invalid. >- return CompilationInvalidated; >- } >- >- return result; >-} >- >-template<typename CodeBlockType> > inline CompilationResult prepareForExecution( >- ExecState* exec, RefPtr<CodeBlockType>& sink, CodeBlockType* codeBlock, >- RefPtr<JITCode>& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex) >+ ExecState* exec, ExecutableBase* executable, CodeBlockType* codeBlock, >+ JITCode::JITType jitType, unsigned bytecodeIndex) > { > CompilationResult result = prepareForExecutionImpl(exec, codeBlock, jitCode, jitType, bytecodeIndex); >- return installOptimizedCode(result, sink, codeBlock, jitCode, MacroAssemblerCodePtr(), 0); >+ if (result != CompilationSuccessful) >+ return result; >+ executable->installCode(codeBlock); >+ return CompilationSuccessful; > } > > inline CompilationResult prepareFunctionForExecution( >@@ -136,7 +107,10 @@ inline CompilationResult prepareFunction > { > CompilationResult result = prepareFunctionForExecutionImpl(exec, codeBlock, > jitCode, jitCodeWithArityCheck, jitType, bytecodeIndex, kind); >- return installOptimizedCode(result, sink, codeBlock, jitCode, jitCodeWithArityCheck, &numParameters); >+ if (result != CompilationSuccessful) >+ return result; >+ executable->installCode(codeBlock); >+ return CompilationSuccessful; > } > > #if ENABLE(DFG_JIT)
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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 120326
:
209681
|
209794
|
209797
|
209834
|
209837
|
209845
|
209846