Skip to content

Commit

Permalink
src: add wasm source-map support to --perf
Browse files Browse the repository at this point in the history
  • Loading branch information
debadree25 committed Mar 10, 2023
1 parent f94ef7c commit 60ead86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "node_snapshot_builder.h"
#include "node_v8_platform-inl.h"
#include "node_wasm_web_api.h"
#include "util-inl.h"
#include "uv.h"
#ifdef NODE_ENABLE_VTUNE_PROFILING
#include "../deps/v8/src/third_party/vtune/v8-vtune.h"
Expand Down Expand Up @@ -260,13 +261,26 @@ void SetIsolateErrorHandlers(v8::Isolate* isolate, const IsolateSettings& s) {
}
}

Local<String> WASMLoadSourceMapCb(Isolate* isolate, const char* path) {
std::string contents;
int r = ReadFileSync(&contents, path);
if (r == 0) {
return String::NewFromUtf8(isolate, contents.c_str()).ToLocalChecked();
}
return String::Empty(isolate);
}

void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) {
isolate->SetMicrotasksPolicy(s.policy);

auto* allow_wasm_codegen_cb = s.allow_wasm_code_generation_callback ?
s.allow_wasm_code_generation_callback : AllowWasmCodeGenerationCallback;
isolate->SetAllowWasmCodeGenerationCallback(allow_wasm_codegen_cb);

auto* wasm_load_source_map_callback = s.wasm_load_source_map_callback ?
s.wasm_load_source_map_callback : WASMLoadSourceMapCb;
isolate->SetWasmLoadSourceMapCallback(wasm_load_source_map_callback);

auto* modify_code_generation_from_strings_callback =
ModifyCodeGenerationFromStrings;
if (s.modify_code_generation_from_strings_callback != nullptr) {
Expand Down
1 change: 1 addition & 0 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ struct IsolateSettings {
allow_wasm_code_generation_callback = nullptr;
v8::ModifyCodeGenerationFromStringsCallback2
modify_code_generation_from_strings_callback = nullptr;
v8::WasmLoadSourceMapCallback wasm_load_source_map_callback = nullptr;
};

// Represents a startup snapshot blob, e.g. created by passing
Expand Down

0 comments on commit 60ead86

Please sign in to comment.