WebKit Bugzilla
Attachment 362306 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
bug-194648-20190218161940.patch (text/plain), 16.80 KB, created by
Caio Lima
on 2019-02-18 11:19:42 PST
(
hide
)
Description:
WIP - Patch
Filename:
MIME Type:
Creator:
Caio Lima
Created:
2019-02-18 11:19:42 PST
Size:
16.80 KB
patch
obsolete
>Subversion Revision: 241651 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 165c1820f75845e5e77b2981132b8a8ff9decd53..e130dfbc3807545b72d7c148f74a2e70dd380226 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 5c3e3233f811c89f3ad5b704b49cbafba23c098a..2cf9198f40edaaf53a61dbf3390a6c7db286a5c1 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 a7b76378f75dc774dab44894bf5cf6286df8fd39..c5b4e63a7c297b6aeebddbf8920bb1c9bc177947 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 3e81720b74790831eee20ea2f1b0e83456447d59..e100fb8ff306e7157dcbd3db2219afc1e8269d0b 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 5c194cf54d2ef3020e21330289d9ff5c09861711..152367b66e9313cacda378c61d5e34879a7dc148 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 MacroAssemblerCodeRef<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); >@@ -61,39 +61,74 @@ static MacroAssemblerCodeRef<JITThunkPtrTag> generateThunkWithJumpTo(VM* vm, Opc > return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "LLInt %s prologue thunk", thunkKind); > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallEntryThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallEntryThunk() > { >- return generateThunkWithJumpTo(vm, llint_function_for_call_prologue, "function for call"); >+ static MacroAssemblerCodeRef<JITThunkPtrTag> codeRef; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codeRef = generateThunkWithJumpTo(llint_function_for_call_prologue, "function for call"); >+ }); >+ return codeRef; > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructEntryThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructEntryThunk() > { >- return generateThunkWithJumpTo(vm, llint_function_for_construct_prologue, "function for construct"); >+ static MacroAssemblerCodeRef<JITThunkPtrTag> codeRef; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codeRef = generateThunkWithJumpTo(llint_function_for_construct_prologue, "function for construct"); >+ }); >+ return codeRef; > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallArityCheckThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallArityCheckThunk() > { >- return generateThunkWithJumpTo(vm, llint_function_for_call_arity_check, "function for call with arity check"); >+ static MacroAssemblerCodeRef<JITThunkPtrTag> codeRef; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codeRef = generateThunkWithJumpTo(llint_function_for_call_arity_check, "function for call with arity check"); >+ }); >+ return codeRef; > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructArityCheckThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructArityCheckThunk() > { >- return generateThunkWithJumpTo(vm, llint_function_for_construct_arity_check, "function for construct with arity check"); >+ static MacroAssemblerCodeRef<JITThunkPtrTag> codeRef; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codeRef = generateThunkWithJumpTo(llint_function_for_construct_arity_check, "function for construct with arity check"); >+ }); >+ return codeRef; > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> evalEntryThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> evalEntryThunk() > { >- return generateThunkWithJumpTo(vm, llint_eval_prologue, "eval"); >+ static MacroAssemblerCodeRef<JITThunkPtrTag> codeRef; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codeRef = generateThunkWithJumpTo(llint_eval_prologue, "eval"); >+ }); >+ return codeRef; > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> programEntryThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> programEntryThunk() > { >- return generateThunkWithJumpTo(vm, llint_program_prologue, "program"); >+ static MacroAssemblerCodeRef<JITThunkPtrTag> codeRef; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codeRef = generateThunkWithJumpTo(llint_program_prologue, "program"); >+ }); >+ return codeRef; > } > >-MacroAssemblerCodeRef<JITThunkPtrTag> moduleProgramEntryThunkGenerator(VM* vm) >+MacroAssemblerCodeRef<JITThunkPtrTag> moduleProgramEntryThunk() > { >- return generateThunkWithJumpTo(vm, llint_module_program_prologue, "module_program"); >+ static MacroAssemblerCodeRef<JITThunkPtrTag> codeRef; >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [&] { >+ codeRef = generateThunkWithJumpTo(llint_module_program_prologue, "module_program"); >+ }); >+ return codeRef; > } > > } // namespace LLInt >diff --git a/Source/JavaScriptCore/llint/LLIntThunks.h b/Source/JavaScriptCore/llint/LLIntThunks.h >index 839ff1e0eaccb0e062cb549153c4f0401af87321..e2293dfc03a6a418ecbe19a5e855b9ca7f7b4de4 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 115b178ce2bcf3ff5938207a0faf3c57d517b8b1..5a99ae26b7ca2c4112215cbf40b5991c4fa6ab03 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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194648
:
362008
|
362009
|
362010
|
362036
|
362129
|
362148
|
362306
|
362313
|
362326
|
362897
|
364555
|
364689