Skip to content

Commit

Permalink
Only run slow path for VMEntryScope when globalObject changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed May 27, 2022
1 parent 72193e1 commit e63c5d1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Source/JavaScriptCore/runtime/VM.h
Expand Up @@ -931,6 +931,9 @@ class VM : public ThreadSafeRefCounted<VM>, public DoublyLinkedListNode<VM> {

public:
bool didEnterVM { false };
#if ENABLE(SINGLE_THREADED_VM_ENTRY_SCOPE)
void *entryScopeID { nullptr };
#endif
private:
bool m_failNextNewCodeBlock { false };
bool m_globalConstRedeclarationShouldThrow { true };
Expand Down
8 changes: 8 additions & 0 deletions Source/JavaScriptCore/runtime/VMEntryScope.cpp
Expand Up @@ -36,13 +36,18 @@

namespace JSC {


VMEntryScope::VMEntryScope(VM& vm, JSGlobalObject* globalObject)
: m_vm(vm)
, m_globalObject(globalObject)
{
if (!vm.entryScope) {
vm.entryScope = this;

#if ENABLE(SINGLE_THREADED_VM_ENTRY_SCOPE)
if (vm.entryScopeID != reinterpret_cast<void*>(globalObject)) {
vm.entryScopeID = globalObject;
#endif
#if ENABLE(WEBASSEMBLY)
if (Wasm::isSupported())
Wasm::startTrackingCurrentThread();
Expand Down Expand Up @@ -70,6 +75,9 @@ VMEntryScope::VMEntryScope(VM& vm, JSGlobalObject* globalObject)
#endif
if (UNLIKELY(Options::useTracePoints()))
tracePoint(VMEntryScopeStart);
#if ENABLE(SINGLE_THREADED_VM_ENTRY_SCOPE)
}
#endif
}

vm.clearLastException();
Expand Down
10 changes: 8 additions & 2 deletions Source/cmake/OptionsJSCOnly.cmake
Expand Up @@ -53,10 +53,16 @@ if (ENABLE_REMOTE_INSPECTOR)
else (
set(ENABLE_INSPECTOR_ALTERNATE_DISPATCHERS OFF)
)

endif ()
WEBKIT_OPTION_END()


WEBKIT_OPTION_BEGIN()
WEBKIT_OPTION_DEFINE(ENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE "Only set VMEntryScope once per globalobject" PUBLIC OFF)
if (ENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE)
set(ENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE ON)
SET_AND_EXPOSE_TO_BUILD(ENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE 1)
endif ()
WEBKIT_OPTION_END()

if (WIN32)
set(ENABLE_API_TESTS OFF)
Expand Down

0 comments on commit e63c5d1

Please sign in to comment.