Skip to content

Commit 17eea18

Browse files
codebyteredanielleadams
authored andcommittedApr 3, 2023
src: allow embedder control of code generation policy
PR-URL: #46368 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent 68b5cf8 commit 17eea18

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed
 

‎src/api/environment.cc

+9-1
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,16 @@ void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) {
263263
auto* allow_wasm_codegen_cb = s.allow_wasm_code_generation_callback ?
264264
s.allow_wasm_code_generation_callback : AllowWasmCodeGenerationCallback;
265265
isolate->SetAllowWasmCodeGenerationCallback(allow_wasm_codegen_cb);
266+
267+
auto* modify_code_generation_from_strings_callback =
268+
ModifyCodeGenerationFromStrings;
269+
if (s.flags & ALLOW_MODIFY_CODE_GENERATION_FROM_STRINGS_CALLBACK &&
270+
s.modify_code_generation_from_strings_callback) {
271+
modify_code_generation_from_strings_callback =
272+
s.modify_code_generation_from_strings_callback;
273+
}
266274
isolate->SetModifyCodeGenerationFromStringsCallback(
267-
ModifyCodeGenerationFromStrings);
275+
modify_code_generation_from_strings_callback);
268276

269277
Mutex::ScopedLock lock(node::per_process::cli_options_mutex);
270278
if (per_process::cli_options->get_per_isolate_options()

‎src/node.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,8 @@ enum IsolateSettingsFlags {
438438
MESSAGE_LISTENER_WITH_ERROR_LEVEL = 1 << 0,
439439
DETAILED_SOURCE_POSITIONS_FOR_PROFILING = 1 << 1,
440440
SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK = 1 << 2,
441-
SHOULD_NOT_SET_PREPARE_STACK_TRACE_CALLBACK = 1 << 3
441+
SHOULD_NOT_SET_PREPARE_STACK_TRACE_CALLBACK = 1 << 3,
442+
ALLOW_MODIFY_CODE_GENERATION_FROM_STRINGS_CALLBACK = 1 << 4,
442443
};
443444

444445
struct IsolateSettings {
@@ -456,6 +457,8 @@ struct IsolateSettings {
456457
v8::PromiseRejectCallback promise_reject_callback = nullptr;
457458
v8::AllowWasmCodeGenerationCallback
458459
allow_wasm_code_generation_callback = nullptr;
460+
v8::ModifyCodeGenerationFromStringsCallback2
461+
modify_code_generation_from_strings_callback = nullptr;
459462
};
460463

461464
// Overriding IsolateSettings may produce unexpected behavior

0 commit comments

Comments
 (0)