WebKit Bugzilla
Attachment 362313 Details for
Bug 194648
: [JSC] LLIntEntryPoint creates same DirectJITCode for all functions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP - Patch
llint-entry-code.diff (text/plain), 17.06 KB, created by
Caio Lima
on 2019-02-18 12:30:01 PST
(
hide
)
Description:
WIP - Patch
Filename:
MIME Type:
Creator:
Caio Lima
Created:
2019-02-18 12:30:01 PST
Size:
17.06 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 165c1820f75..e130dfbc380 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,47 @@ >+2019-02-18 Caio Lima <ticaiolima@gmail.com> >+ >+ [JSC] LLIntEntryPoint creates same DirectJITCode for all functions >+ https://bugs.webkit.org/show_bug.cgi?id=194648 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ All LLIntEntryPoint functions is allocating a new `DirectJITCode` >+ object with the same values. On this patch we are changing this >+ behavior to use a singleton JITCode for each type of entry point. >+ This also required a change on LLIntThunks, where we were generating >+ the same ctiStub per VM, but now we have only one global thunk per >+ entrypoint type. >+ >+ * jit/JSInterfaceJIT.h: >+ (JSC::JSInterfaceJIT::JSInterfaceJIT): >+ * llint/LLIntEntrypoint.cpp: >+ (JSC::LLInt::setFunctionEntrypoint): >+ (JSC::LLInt::setEvalEntrypoint): >+ (JSC::LLInt::setProgramEntrypoint): >+ (JSC::LLInt::setModuleProgramEntrypoint): >+ (JSC::LLInt::setEntrypoint): >+ * llint/LLIntEntrypoint.h: >+ * llint/LLIntThunks.cpp: >+ (JSC::LLInt::generateThunkWithJumpTo): >+ (JSC::LLInt::functionForCallEntryThunk): >+ (JSC::LLInt::functionForConstructEntryThunk): >+ (JSC::LLInt::functionForCallArityCheckThunk): >+ (JSC::LLInt::functionForConstructArityCheckThunk): >+ (JSC::LLInt::evalEntryThunk): >+ (JSC::LLInt::programEntryThunk): >+ (JSC::LLInt::moduleProgramEntryThunk): >+ (JSC::LLInt::functionForCallEntryThunkGenerator): Deleted. >+ (JSC::LLInt::functionForConstructEntryThunkGenerator): Deleted. >+ (JSC::LLInt::functionForCallArityCheckThunkGenerator): Deleted. >+ (JSC::LLInt::functionForConstructArityCheckThunkGenerator): Deleted. >+ (JSC::LLInt::evalEntryThunkGenerator): Deleted. >+ (JSC::LLInt::programEntryThunkGenerator): Deleted. >+ (JSC::LLInt::moduleProgramEntryThunkGenerator): Deleted. >+ * llint/LLIntThunks.h: >+ * runtime/ScriptExecutable.cpp: >+ (JSC::setupLLInt): >+ (JSC::ScriptExecutable::prepareForExecutionImpl): >+ > 2019-02-17 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r241612. >diff --git a/Source/JavaScriptCore/jit/JSInterfaceJIT.h b/Source/JavaScriptCore/jit/JSInterfaceJIT.h >index 5c3e3233f81..2cf9198f40e 100644 >--- a/Source/JavaScriptCore/jit/JSInterfaceJIT.h >+++ b/Source/JavaScriptCore/jit/JSInterfaceJIT.h >@@ -38,7 +38,8 @@ > namespace JSC { > class JSInterfaceJIT : public CCallHelpers, public GPRInfo, public FPRInfo { > public: >- JSInterfaceJIT(VM* vm, CodeBlock* codeBlock = 0) >+ >+ JSInterfaceJIT(VM* vm = nullptr, CodeBlock* codeBlock = nullptr) > : CCallHelpers(codeBlock) > , m_vm(vm) > { >diff --git a/Source/JavaScriptCore/llint/LLIntEntrypoint.cpp b/Source/JavaScriptCore/llint/LLIntEntrypoint.cpp >index a7b76378f75..c5b4e63a7c2 100644 >--- a/Source/JavaScriptCore/llint/LLIntEntrypoint.cpp >+++ b/Source/JavaScriptCore/llint/LLIntEntrypoint.cpp >@@ -38,25 +38,39 @@ > > namespace JSC { namespace LLInt { > >-static void setFunctionEntrypoint(VM& vm, CodeBlock* codeBlock) >+static void setFunctionEntrypoint(CodeBlock* codeBlock) > { > CodeSpecializationKind kind = codeBlock->specializationKind(); > > #if ENABLE(JIT) > if (VM::canUseJIT()) { > if (kind == CodeForCall) { >- codeBlock->setJITCode( >- adoptRef(*new DirectJITCode(vm.getCTIStub(functionForCallEntryThunkGenerator).retagged<JSEntryPtrTag>(), vm.getCTIStub(functionForCallArityCheckThunkGenerator).retaggedCode<JSEntryPtrTag>(), JITCode::InterpreterThunk))); >+ static DirectJITCode* jitCode; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ auto callRef = functionForCallEntryThunk().retagged<JSEntryPtrTag>(); >+ auto callArityCheckRef = functionForCallArityCheckThunk().retaggedCode<JSEntryPtrTag>(); >+ jitCode = new DirectJITCode(callRef, callArityCheckRef, JITCode::InterpreterThunk); >+ }); >+ >+ codeBlock->setJITCode(makeRef(*jitCode)); > return; > } > ASSERT(kind == CodeForConstruct); >- codeBlock->setJITCode( >- adoptRef(*new DirectJITCode(vm.getCTIStub(functionForConstructEntryThunkGenerator).retagged<JSEntryPtrTag>(), vm.getCTIStub(functionForConstructArityCheckThunkGenerator).retaggedCode<JSEntryPtrTag>(), JITCode::InterpreterThunk))); >+ >+ static DirectJITCode* jitCode; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ auto constructRef = functionForConstructEntryThunk().retagged<JSEntryPtrTag>(); >+ auto constructArityCheckRef = functionForConstructArityCheckThunk().retaggedCode<JSEntryPtrTag>(); >+ jitCode = new DirectJITCode(constructRef, constructArityCheckRef, JITCode::InterpreterThunk); >+ }); >+ >+ codeBlock->setJITCode(makeRef(*jitCode)); > return; > } > #endif // ENABLE(JIT) > >- UNUSED_PARAM(vm); > if (kind == CodeForCall) { > static DirectJITCode* jitCode; > static std::once_flag onceKey; >@@ -74,18 +88,21 @@ static void setFunctionEntrypoint(VM& vm, CodeBlock* codeBlock) > } > } > >-static void setEvalEntrypoint(VM& vm, CodeBlock* codeBlock) >+static void setEvalEntrypoint(CodeBlock* codeBlock) > { > #if ENABLE(JIT) > if (VM::canUseJIT()) { >- MacroAssemblerCodeRef<JSEntryPtrTag> codeRef = vm.getCTIStub(evalEntryThunkGenerator).retagged<JSEntryPtrTag>(); >- codeBlock->setJITCode( >- adoptRef(*new DirectJITCode(codeRef, codeRef.code(), JITCode::InterpreterThunk))); >+ static DirectJITCode* jitCode; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ MacroAssemblerCodeRef<JSEntryPtrTag> codeRef = evalEntryThunk().retagged<JSEntryPtrTag>(); >+ jitCode = new DirectJITCode(codeRef, codeRef.code(), JITCode::InterpreterThunk); >+ }); >+ codeBlock->setJITCode(makeRef(*jitCode)); > return; > } > #endif // ENABLE(JIT) > >- UNUSED_PARAM(vm); > static NativeJITCode* jitCode; > static std::once_flag onceKey; > std::call_once(onceKey, [&] { >@@ -94,18 +111,21 @@ static void setEvalEntrypoint(VM& vm, CodeBlock* codeBlock) > codeBlock->setJITCode(makeRef(*jitCode)); > } > >-static void setProgramEntrypoint(VM& vm, CodeBlock* codeBlock) >+static void setProgramEntrypoint(CodeBlock* codeBlock) > { > #if ENABLE(JIT) > if (VM::canUseJIT()) { >- MacroAssemblerCodeRef<JSEntryPtrTag> codeRef = vm.getCTIStub(programEntryThunkGenerator).retagged<JSEntryPtrTag>(); >- codeBlock->setJITCode( >- adoptRef(*new DirectJITCode(codeRef, codeRef.code(), JITCode::InterpreterThunk))); >+ static DirectJITCode* jitCode; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ MacroAssemblerCodeRef<JSEntryPtrTag> codeRef = programEntryThunk().retagged<JSEntryPtrTag>(); >+ jitCode = new DirectJITCode(codeRef, codeRef.code(), JITCode::InterpreterThunk); >+ }); >+ codeBlock->setJITCode(makeRef(*jitCode)); > return; > } > #endif // ENABLE(JIT) > >- UNUSED_PARAM(vm); > static NativeJITCode* jitCode; > static std::once_flag onceKey; > std::call_once(onceKey, [&] { >@@ -114,18 +134,21 @@ static void setProgramEntrypoint(VM& vm, CodeBlock* codeBlock) > codeBlock->setJITCode(makeRef(*jitCode)); > } > >-static void setModuleProgramEntrypoint(VM& vm, CodeBlock* codeBlock) >+static void setModuleProgramEntrypoint(CodeBlock* codeBlock) > { > #if ENABLE(JIT) > if (VM::canUseJIT()) { >- MacroAssemblerCodeRef<JSEntryPtrTag> codeRef = vm.getCTIStub(moduleProgramEntryThunkGenerator).retagged<JSEntryPtrTag>(); >- codeBlock->setJITCode( >- adoptRef(*new DirectJITCode(codeRef, codeRef.code(), JITCode::InterpreterThunk))); >+ static DirectJITCode* jitCode; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ MacroAssemblerCodeRef<JSEntryPtrTag> codeRef = moduleProgramEntryThunk().retagged<JSEntryPtrTag>(); >+ jitCode = new DirectJITCode(codeRef, codeRef.code(), JITCode::InterpreterThunk); >+ }); >+ codeBlock->setJITCode(makeRef(*jitCode)); > return; > } > #endif // ENABLE(JIT) > >- UNUSED_PARAM(vm); > static NativeJITCode* jitCode; > static std::once_flag onceKey; > std::call_once(onceKey, [&] { >@@ -134,20 +157,20 @@ static void setModuleProgramEntrypoint(VM& vm, CodeBlock* codeBlock) > codeBlock->setJITCode(makeRef(*jitCode)); > } > >-void setEntrypoint(VM& vm, CodeBlock* codeBlock) >+void setEntrypoint(CodeBlock* codeBlock) > { > switch (codeBlock->codeType()) { > case GlobalCode: >- setProgramEntrypoint(vm, codeBlock); >+ setProgramEntrypoint(codeBlock); > return; > case ModuleCode: >- setModuleProgramEntrypoint(vm, codeBlock); >+ setModuleProgramEntrypoint(codeBlock); > return; > case EvalCode: >- setEvalEntrypoint(vm, codeBlock); >+ setEvalEntrypoint(codeBlock); > return; > case FunctionCode: >- setFunctionEntrypoint(vm, codeBlock); >+ setFunctionEntrypoint(codeBlock); > return; > } > >diff --git a/Source/JavaScriptCore/llint/LLIntEntrypoint.h b/Source/JavaScriptCore/llint/LLIntEntrypoint.h >index 3e81720b747..e100fb8ff30 100644 >--- a/Source/JavaScriptCore/llint/LLIntEntrypoint.h >+++ b/Source/JavaScriptCore/llint/LLIntEntrypoint.h >@@ -33,7 +33,7 @@ class VM; > > namespace LLInt { > >-void setEntrypoint(VM&, CodeBlock*); >+void setEntrypoint(CodeBlock*); > > unsigned frameRegisterCountFor(CodeBlock*); > >diff --git a/Source/JavaScriptCore/llint/LLIntThunks.cpp b/Source/JavaScriptCore/llint/LLIntThunks.cpp >index 5c194cf54d2..e8530517111 100644 >--- a/Source/JavaScriptCore/llint/LLIntThunks.cpp >+++ b/Source/JavaScriptCore/llint/LLIntThunks.cpp >@@ -46,9 +46,9 @@ namespace JSC { > > namespace LLInt { > >-static MacroAssemblerCodeRef<JITThunkPtrTag> generateThunkWithJumpTo(VM* vm, OpcodeID opcodeID, const char *thunkKind) >+static MacroAssemblerCodePtr<JITThunkPtrTag> generateThunkWithJumpTo(OpcodeID opcodeID, const char *thunkKind) > { >- JSInterfaceJIT jit(vm); >+ JSInterfaceJIT jit; > > // FIXME: there's probably a better way to do it on X86, but I'm not sure I care. > LLIntCode target = LLInt::getCodeFunctionPtr<JSEntryPtrTag>(opcodeID); >@@ -58,42 +58,78 @@ static MacroAssemblerCodeRef<JITThunkPtrTag> generateThunkWithJumpTo(VM* vm, Opc > jit.jump(JSInterfaceJIT::regT0, JSEntryPtrTag); > > LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID); >- return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "LLInt %s prologue thunk", thunkKind); >+ auto codeRef = FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "LLInt %s prologue thunk", thunkKind); >+ return codeRef.code(); > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallEntryThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallEntryThunk() > { >- return generateThunkWithJumpTo(vm, llint_function_for_call_prologue, "function for call"); >+ static MacroAssemblerCodePtr<JITThunkPtrTag> codePtr; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codePtr = generateThunkWithJumpTo(llint_function_for_call_prologue, "function for call"); >+ }); >+ return MacroAssemblerCodeRef<JITThunkPtrTag>::createSelfManagedCodeRef(codePtr); > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructEntryThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructEntryThunk() > { >- return generateThunkWithJumpTo(vm, llint_function_for_construct_prologue, "function for construct"); >+ static MacroAssemblerCodePtr<JITThunkPtrTag> codePtr; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codePtr = generateThunkWithJumpTo(llint_function_for_construct_prologue, "function for construct"); >+ }); >+ return MacroAssemblerCodeRef<JITThunkPtrTag>::createSelfManagedCodeRef(codePtr); > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallArityCheckThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallArityCheckThunk() > { >- return generateThunkWithJumpTo(vm, llint_function_for_call_arity_check, "function for call with arity check"); >+ static MacroAssemblerCodePtr<JITThunkPtrTag> codePtr; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codePtr = generateThunkWithJumpTo(llint_function_for_call_arity_check, "function for call with arity check"); >+ }); >+ return MacroAssemblerCodeRef<JITThunkPtrTag>::createSelfManagedCodeRef(codePtr);; > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructArityCheckThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructArityCheckThunk() > { >- return generateThunkWithJumpTo(vm, llint_function_for_construct_arity_check, "function for construct with arity check"); >+ static MacroAssemblerCodePtr<JITThunkPtrTag> codePtr; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codePtr = generateThunkWithJumpTo(llint_function_for_construct_arity_check, "function for construct with arity check"); >+ }); >+ return MacroAssemblerCodeRef<JITThunkPtrTag>::createSelfManagedCodeRef(codePtr); > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> evalEntryThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> evalEntryThunk() > { >- return generateThunkWithJumpTo(vm, llint_eval_prologue, "eval"); >+ static MacroAssemblerCodePtr<JITThunkPtrTag> codePtr; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codePtr = generateThunkWithJumpTo(llint_eval_prologue, "eval"); >+ }); >+ return MacroAssemblerCodeRef<JITThunkPtrTag>::createSelfManagedCodeRef(codePtr); > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> programEntryThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> programEntryThunk() > { >- return generateThunkWithJumpTo(vm, llint_program_prologue, "program"); >+ static MacroAssemblerCodePtr<JITThunkPtrTag> codePtr; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codePtr = generateThunkWithJumpTo(llint_program_prologue, "program"); >+ }); >+ return MacroAssemblerCodeRef<JITThunkPtrTag>::createSelfManagedCodeRef(codePtr); > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> moduleProgramEntryThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> moduleProgramEntryThunk() > { >- return generateThunkWithJumpTo(vm, llint_module_program_prologue, "module_program"); >+ static MacroAssemblerCodePtr<JITThunkPtrTag> codePtr; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codePtr = generateThunkWithJumpTo(llint_module_program_prologue, "module_program"); >+ }); >+ return MacroAssemblerCodeRef<JITThunkPtrTag>::createSelfManagedCodeRef(codePtr); > } > > } // namespace LLInt >diff --git a/Source/JavaScriptCore/llint/LLIntThunks.h b/Source/JavaScriptCore/llint/LLIntThunks.h >index 839ff1e0eac..e2293dfc03a 100644 >--- a/Source/JavaScriptCore/llint/LLIntThunks.h >+++ b/Source/JavaScriptCore/llint/LLIntThunks.h >@@ -46,12 +46,12 @@ inline EncodedJSValue vmEntryToWasm(void* code, VM* vm, ProtoCallFrame* frame) > > namespace LLInt { > >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallEntryThunkGenerator(VM*); >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructEntryThunkGenerator(VM*); >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallArityCheckThunkGenerator(VM*); >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructArityCheckThunkGenerator(VM*); >-MacroAssemblerCodeRef<JITThunkPtrTag> evalEntryThunkGenerator(VM*); >-MacroAssemblerCodeRef<JITThunkPtrTag> programEntryThunkGenerator(VM*); >-MacroAssemblerCodeRef<JITThunkPtrTag> moduleProgramEntryThunkGenerator(VM*); >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallEntryThunk(); >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructEntryThunk(); >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallArityCheckThunk(); >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructArityCheckThunk(); >+MacroAssemblerCodeRef<JITThunkPtrTag> evalEntryThunk(); >+MacroAssemblerCodeRef<JITThunkPtrTag> programEntryThunk(); >+MacroAssemblerCodeRef<JITThunkPtrTag> moduleProgramEntryThunk(); > > } } // namespace JSC::LLInt >diff --git a/Source/JavaScriptCore/runtime/ScriptExecutable.cpp b/Source/JavaScriptCore/runtime/ScriptExecutable.cpp >index 115b178ce2b..5a99ae26b7c 100644 >--- a/Source/JavaScriptCore/runtime/ScriptExecutable.cpp >+++ b/Source/JavaScriptCore/runtime/ScriptExecutable.cpp >@@ -385,9 +385,9 @@ CodeBlock* ScriptExecutable::newReplacementCodeBlockFor( > return result; > } > >-static void setupLLInt(VM& vm, CodeBlock* codeBlock) >+static void setupLLInt(CodeBlock* codeBlock) > { >- LLInt::setEntrypoint(vm, codeBlock); >+ LLInt::setEntrypoint(codeBlock); > } > > static void setupJIT(VM& vm, CodeBlock* codeBlock) >@@ -424,7 +424,7 @@ JSObject* ScriptExecutable::prepareForExecutionImpl( > codeBlock->validate(); > > if (Options::useLLInt()) >- setupLLInt(vm, codeBlock); >+ setupLLInt(codeBlock); > else > setupJIT(vm, codeBlock); >
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:
ticaiolima
:
review-
ticaiolima
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194648
:
362008
|
362009
|
362010
|
362036
|
362129
|
362148
|
362306
|
362313
|
362326
|
362897
|
364555
|
364689