-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try bringing release/acquire heap access back (#16865)
Co-authored-by: Ben Grant <[email protected]>
- Loading branch information
1 parent
4471212
commit c1708ea
Showing
9 changed files
with
68 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,33 @@ | ||
#include "root.h" | ||
#include "BunClientData.h" | ||
|
||
#include <JavaScriptCore/VM.h> | ||
#include <JavaScriptCore/Heap.h> | ||
|
||
extern "C" int Bun__JSC_onBeforeWait(JSC::VM* vm) | ||
// It would be nicer to construct a DropAllLocks in us_loop_run_bun_tick (the only function that | ||
// uses onBeforeWait and onAfterWait), but that code is in C. We use an optional as that lets us | ||
// check whether it's initialized. | ||
static thread_local std::optional<JSC::JSLock::DropAllLocks> drop_all_locks { std::nullopt }; | ||
|
||
extern "C" void WTFTimer__runIfImminent(void* bun_vm); | ||
|
||
// Safe if VM is nullptr | ||
extern "C" void Bun__JSC_onBeforeWait(JSC::VM* vm) | ||
{ | ||
(void)vm; | ||
// if (vm->heap.hasAccess()) { | ||
// vm->heap.releaseAccess(); | ||
// return 1; | ||
// } | ||
return 0; | ||
ASSERT(!drop_all_locks.has_value()); | ||
if (vm) { | ||
bool previouslyHadAccess = vm->heap.hasHeapAccess(); | ||
drop_all_locks.emplace(*vm); | ||
if (previouslyHadAccess) { | ||
vm->heap.releaseAccess(); | ||
} | ||
} | ||
} | ||
|
||
extern "C" void Bun__JSC_onAfterWait(JSC::VM* vm) | ||
{ | ||
(void)vm; | ||
// vm->heap.acquireAccess(); | ||
if (vm) { | ||
vm->heap.acquireAccess(); | ||
drop_all_locks.reset(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters