fix: new WebAssembly API support in Node.js (#36420)
This commit is contained in:
parent
909ee0ed6b
commit
b90a5baa6d
4 changed files with 26 additions and 9 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "shell/common/gin_helper/cleaned_up_at_exit.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "third_party/blink/public/common/switches.h"
|
||||
#include "third_party/electron_node/src/node_wasm_web_api.h"
|
||||
|
||||
namespace {
|
||||
v8::Isolate* g_isolate;
|
||||
|
@ -73,8 +74,9 @@ struct base::trace_event::TraceValue::Helper<
|
|||
|
||||
namespace electron {
|
||||
|
||||
JavascriptEnvironment::JavascriptEnvironment(uv_loop_t* event_loop)
|
||||
: isolate_(Initialize(event_loop)),
|
||||
JavascriptEnvironment::JavascriptEnvironment(uv_loop_t* event_loop,
|
||||
bool setup_wasm_streaming)
|
||||
: isolate_(Initialize(event_loop, setup_wasm_streaming)),
|
||||
isolate_holder_(base::ThreadTaskRunnerHandle::Get(),
|
||||
gin::IsolateHolder::kSingleThread,
|
||||
gin::IsolateHolder::kAllowAtomicsWait,
|
||||
|
@ -247,7 +249,8 @@ class TracingControllerImpl : public node::tracing::TracingController {
|
|||
}
|
||||
};
|
||||
|
||||
v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop) {
|
||||
v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop,
|
||||
bool setup_wasm_streaming) {
|
||||
auto* cmd = base::CommandLine::ForCurrentProcess();
|
||||
|
||||
// --js-flags.
|
||||
|
@ -276,6 +279,17 @@ v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop) {
|
|||
|
||||
v8::Isolate* isolate = v8::Isolate::Allocate();
|
||||
platform_->RegisterIsolate(isolate, event_loop);
|
||||
|
||||
// This is done here because V8 checks for the callback in NewContext.
|
||||
// Our setup order doesn't allow for calling SetupIsolateForNode
|
||||
// before NewContext without polluting JavaScriptEnvironment with
|
||||
// Node.js logic and so we conditionally do it here to keep
|
||||
// concerns separate.
|
||||
if (setup_wasm_streaming) {
|
||||
isolate->SetWasmStreamingCallback(
|
||||
node::wasm_web_api::StartStreamingCompilation);
|
||||
}
|
||||
|
||||
g_isolate = isolate;
|
||||
|
||||
return isolate;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue