Commit 8ca19603 authored by Philip Pfaffe's avatar Philip Pfaffe Committed by Commit Bot

[wasm debug] Cache name tables for the wasm debug proxy.

Also construct the `JSMap`s used to store these names lazily and
only on-demand, and construct them directly instead of first doing
a `std::vector<Handle<String>>` and using that to construct the
`JSMap`. The latter resulted in a gigantic root set of 150k+ handles,
which wasn't well received by the GC.

Bug: chromium:1154154
Fixed: chromium:1154564
Also-By: bmeurer@chromium.org
Change-Id: I92e8931f15eda133e2a62b5cc53fbe1f2dafcead
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2568275
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Auto-Submit: Philip Pfaffe <pfaffe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71589}
parent 220b4a3b
......@@ -367,6 +367,7 @@
V(_, wasm_exception_values_symbol) \
V(_, wasm_uncatchable_symbol) \
V(_, wasm_wrapped_object_symbol) \
V(_, wasm_debug_proxy_name_tables) \
V(_, uninitialized_symbol)
#define PUBLIC_SYMBOL_LIST_GENERATOR(V, _) \
......
......@@ -2321,20 +2321,75 @@ Handle<Object> GetMapValue(Isolate* isolate, Handle<JSMap> map,
.ToHandleChecked();
}
Handle<WasmInstanceObject> GetInstance(Isolate* isolate,
Handle<JSObject> handler) {
Handle<Object> instance =
JSObject::GetProperty(isolate, handler, "instance").ToHandleChecked();
DCHECK(instance->IsWasmInstanceObject());
return Handle<WasmInstanceObject>::cast(instance);
}
// Populate a JSMap with name->index mappings from an ordered list of names.
Handle<JSMap> GetNameTable(Isolate* isolate,
const std::vector<Handle<String>>& names) {
Factory* factory = isolate->factory();
Handle<JSMap> name_table = factory->NewJSMap();
for (size_t i = 0; i < names.size(); ++i) {
SetMapValue(isolate, name_table, names[i], factory->NewNumberFromInt64(i));
}
return name_table;
}
// Look up a JSMap with name->index mappings from an ordered list of names.
Handle<JSMap> GetOrCreateNameTable(
Handle<WasmInstanceObject> instance, const char* table_name,
Handle<JSMap> (*generate_names_callback)(Handle<WasmInstanceObject>)) {
Isolate* isolate = instance->GetIsolate();
Handle<Object> tables;
Handle<Object> name_table;
Handle<String> table_name_string =
isolate->factory()->InternalizeUtf8String(table_name);
Handle<Name> symbol = isolate->factory()->wasm_debug_proxy_name_tables();
bool has_tables =
Object::GetProperty(isolate, instance, symbol).ToHandle(&tables) &&
!tables->IsUndefined();
if (has_tables) {
if (Object::GetProperty(isolate, tables, table_name_string)
.ToHandle(&name_table)) {
DCHECK(name_table->IsUndefined() || name_table->IsJSMap());
if (!name_table->IsUndefined()) return Handle<JSMap>::cast(name_table);
}
} else {
tables = isolate->factory()->NewJSObjectWithNullProto();
Object::SetProperty(isolate, instance, symbol, tables).Check();
}
name_table = generate_names_callback(instance);
Object::SetProperty(isolate, tables, table_name_string, name_table).Check();
return Handle<JSMap>::cast(name_table);
}
// Look up a name in a name table. Name tables are stored under the "names"
// property of the handler and map names to index.
base::Optional<int> ResolveValueSelector(Isolate* isolate,
Handle<Name> property,
Handle<JSObject> handler,
bool enable_index_lookup) {
base::Optional<int> ResolveValueSelector(
Isolate* isolate, Handle<Name> property, Handle<JSObject> handler,
bool enable_index_lookup, const char* table_name = nullptr,
Handle<JSMap> (*generate_names_callback)(Handle<WasmInstanceObject>) =
nullptr) {
size_t index = 0;
if (enable_index_lookup && property->AsIntegerIndex(&index) &&
index < kMaxInt) {
return static_cast<int>(index);
if (enable_index_lookup && property->AsIntegerIndex(&index)) {
if (index < kMaxInt) return static_cast<int>(index);
return {};
}
Handle<Object> name_table =
JSObject::GetProperty(isolate, handler, "names").ToHandleChecked();
if (name_table->IsUndefined(isolate)) {
name_table = GetOrCreateNameTable(GetInstance(isolate, handler), table_name,
generate_names_callback);
JSObject::AddProperty(isolate, handler, "names", name_table, DONT_ENUM);
}
DCHECK(name_table->IsJSMap());
Handle<Object> object =
......@@ -2397,128 +2452,128 @@ std::vector<Handle<String>> GetLocalNames(Handle<WasmInstanceObject> instance,
// Generate names for the globals. Names either come from the name table,
// otherwise the default $globalX is used.
std::vector<Handle<String>> GetGlobalNames(
Handle<WasmInstanceObject> instance) {
Handle<JSMap> GetGlobalNames(Handle<WasmInstanceObject> instance) {
Isolate* isolate = instance->GetIsolate();
auto& globals = instance->module()->globals;
std::vector<Handle<String>> names;
Handle<JSMap> names = isolate->factory()->NewJSMap();
for (uint32_t i = 0; i < globals.size(); ++i) {
names.emplace_back(GetNameOrDefault(
isolate, WasmInstanceObject::GetGlobalNameOrNull(isolate, instance, i),
"$global", i));
HandleScope scope(isolate);
SetMapValue(isolate, names,
GetNameOrDefault(isolate,
WasmInstanceObject::GetGlobalNameOrNull(
isolate, instance, i),
"$global", i),
isolate->factory()->NewNumberFromUint(i));
}
return names;
}
// Generate names for the functions.
std::vector<Handle<String>> GetFunctionNames(
Handle<WasmInstanceObject> instance) {
Handle<JSMap> GetFunctionNames(Handle<WasmInstanceObject> instance) {
Isolate* isolate = instance->GetIsolate();
auto* module = instance->module();
wasm::ModuleWireBytes wire_bytes(
instance->module_object().native_module()->wire_bytes());
std::vector<Handle<String>> names;
Handle<JSMap> names = isolate->factory()->NewJSMap();
for (auto& function : module->functions) {
DCHECK_EQ(function.func_index, names.size());
HandleScope scope(isolate);
wasm::WireBytesRef name_ref =
module->lazily_generated_names.LookupFunctionName(
wire_bytes, function.func_index, VectorOf(module->export_table));
DCHECK(wire_bytes.BoundsCheck(name_ref));
Vector<const char> name_vec = wire_bytes.GetNameOrNull(name_ref);
names.emplace_back(GetNameOrDefault(
Handle<String> name = GetNameOrDefault(
isolate,
name_vec.empty() ? MaybeHandle<String>()
: isolate->factory()->NewStringFromUtf8(name_vec),
"$func", function.func_index));
"$func", function.func_index);
SetMapValue(isolate, names, name,
isolate->factory()->NewNumberFromUint(function.func_index));
}
return names;
}
// Generate names for the imports.
std::vector<Handle<String>> GetImportNames(
Handle<WasmInstanceObject> instance) {
Handle<JSMap> GetImportNames(Handle<WasmInstanceObject> instance) {
Isolate* isolate = instance->GetIsolate();
const wasm::WasmModule* module = instance->module();
Handle<WasmModuleObject> module_object(instance->module_object(), isolate);
int num_imports = static_cast<int>(module->import_table.size());
size_t num_imports = module->import_table.size();
std::vector<Handle<String>> names;
for (int index = 0; index < num_imports; ++index) {
const wasm::WasmImport& import = module->import_table[index];
Handle<JSMap> names = isolate->factory()->NewJSMap();
for (size_t index = 0; index < num_imports; ++index) {
HandleScope scope(isolate);
names.emplace_back(WasmModuleObject::ExtractUtf8StringFromModuleBytes(
isolate, module_object, import.field_name, kInternalize));
const wasm::WasmImport& import = module->import_table[index];
SetMapValue(isolate, names,
WasmModuleObject::ExtractUtf8StringFromModuleBytes(
isolate, module_object, import.field_name, kInternalize),
isolate->factory()->NewNumberFromSize(index));
}
return names;
}
// Generate names for the memories.
std::vector<Handle<String>> GetMemoryNames(
Handle<WasmInstanceObject> instance) {
Handle<JSMap> GetMemoryNames(Handle<WasmInstanceObject> instance) {
Isolate* isolate = instance->GetIsolate();
std::vector<Handle<String>> names;
Handle<JSMap> names = isolate->factory()->NewJSMap();
uint32_t memory_count = instance->has_memory_object() ? 1 : 0;
for (uint32_t memory_index = 0; memory_index < memory_count; ++memory_index) {
names.emplace_back(GetNameOrDefault(isolate,
WasmInstanceObject::GetMemoryNameOrNull(
isolate, instance, memory_index),
"$memory", memory_index));
SetMapValue(isolate, names,
GetNameOrDefault(isolate,
WasmInstanceObject::GetMemoryNameOrNull(
isolate, instance, memory_index),
"$memory", memory_index),
isolate->factory()->NewNumberFromUint(memory_index));
}
return names;
}
// Generate names for the tables.
std::vector<Handle<String>> GetTableNames(Handle<WasmInstanceObject> instance) {
Handle<JSMap> GetTableNames(Handle<WasmInstanceObject> instance) {
Isolate* isolate = instance->GetIsolate();
auto tables = handle(instance->tables(), isolate);
std::vector<Handle<String>> names;
Handle<JSMap> names = isolate->factory()->NewJSMap();
for (int table_index = 0; table_index < tables->length(); ++table_index) {
auto func_table =
handle(WasmTableObject::cast(tables->get(table_index)), isolate);
if (!func_table->type().is_reference_to(wasm::HeapType::kFunc)) continue;
names.emplace_back(GetNameOrDefault(
isolate,
WasmInstanceObject::GetTableNameOrNull(isolate, instance, table_index),
"$table", table_index));
SetMapValue(isolate, names,
GetNameOrDefault(isolate,
WasmInstanceObject::GetTableNameOrNull(
isolate, instance, table_index),
"$table", table_index),
isolate->factory()->NewNumberFromInt(table_index));
}
return names;
}
// Generate names for the exports
std::vector<Handle<String>> GetExportNames(
Handle<WasmInstanceObject> instance) {
Handle<JSMap> GetExportNames(Handle<WasmInstanceObject> instance) {
Isolate* isolate = instance->GetIsolate();
const wasm::WasmModule* module = instance->module();
Handle<WasmModuleObject> module_object(instance->module_object(), isolate);
int num_exports = static_cast<int>(module->export_table.size());
size_t num_exports = module->export_table.size();
std::vector<Handle<String>> names;
for (int index = 0; index < num_exports; ++index) {
Handle<JSMap> names = isolate->factory()->NewJSMap();
for (size_t index = 0; index < num_exports; ++index) {
const wasm::WasmExport& exp = module->export_table[index];
names.emplace_back(WasmModuleObject::ExtractUtf8StringFromModuleBytes(
isolate, module_object, exp.name, kInternalize));
SetMapValue(isolate, names,
WasmModuleObject::ExtractUtf8StringFromModuleBytes(
isolate, module_object, exp.name, kInternalize),
isolate->factory()->NewNumberFromSize(index));
}
return names;
}
Handle<WasmInstanceObject> GetInstance(Isolate* isolate,
Handle<JSObject> handler) {
Handle<Object> instance =
JSObject::GetProperty(isolate, handler, "instance").ToHandleChecked();
DCHECK(instance->IsWasmInstanceObject());
return Handle<WasmInstanceObject>::cast(instance);
}
Address GetPC(Isolate* isolate, Handle<JSObject> handler) {
Handle<Object> pc =
JSObject::GetProperty(isolate, handler, "pc").ToHandleChecked();
......@@ -2618,7 +2673,8 @@ base::Optional<int> HasGlobalImpl(Isolate* isolate, Handle<Name> property,
bool enable_index_lookup) {
Handle<WasmInstanceObject> instance = GetInstance(isolate, handler);
base::Optional<int> index =
ResolveValueSelector(isolate, property, handler, enable_index_lookup);
ResolveValueSelector(isolate, property, handler, enable_index_lookup,
"globals", GetGlobalNames);
if (!index) return index;
const std::vector<wasm::WasmGlobal>& globals = instance->module()->globals;
......@@ -2647,7 +2703,8 @@ base::Optional<int> HasMemoryImpl(Isolate* isolate, Handle<Name> property,
bool enable_index_lookup) {
Handle<WasmInstanceObject> instance = GetInstance(isolate, handler);
base::Optional<int> index =
ResolveValueSelector(isolate, property, handler, enable_index_lookup);
ResolveValueSelector(isolate, property, handler, enable_index_lookup,
"memories", GetMemoryNames);
if (index && *index == 0 && instance->has_memory_object()) return index;
return {};
}
......@@ -2667,7 +2724,8 @@ base::Optional<int> HasFunctionImpl(Isolate* isolate, Handle<Name> property,
bool enable_index_lookup) {
Handle<WasmInstanceObject> instance = GetInstance(isolate, handler);
base::Optional<int> index =
ResolveValueSelector(isolate, property, handler, enable_index_lookup);
ResolveValueSelector(isolate, property, handler, enable_index_lookup,
"functions", GetFunctionNames);
if (!index) return index;
const std::vector<wasm::WasmFunction>& functions =
instance->module()->functions;
......@@ -2694,8 +2752,8 @@ base::Optional<int> HasTableImpl(Isolate* isolate, Handle<Name> property,
Handle<JSObject> handler,
bool enable_index_lookup) {
Handle<WasmInstanceObject> instance = GetInstance(isolate, handler);
base::Optional<int> index =
ResolveValueSelector(isolate, property, handler, enable_index_lookup);
base::Optional<int> index = ResolveValueSelector(
isolate, property, handler, enable_index_lookup, "tables", GetTableNames);
if (!index) return index;
Handle<FixedArray> tables(instance->tables(), isolate);
int num_tables = tables->length();
......@@ -2725,7 +2783,8 @@ base::Optional<int> HasImportImpl(Isolate* isolate, Handle<Name> property,
bool enable_index_lookup) {
Handle<WasmInstanceObject> instance = GetInstance(isolate, handler);
base::Optional<int> index =
ResolveValueSelector(isolate, property, handler, enable_index_lookup);
ResolveValueSelector(isolate, property, handler, enable_index_lookup,
"imports", GetImportNames);
if (!index) return index;
const wasm::WasmModule* module = instance->module();
Handle<WasmModuleObject> module_object(instance->module_object(), isolate);
......@@ -2776,7 +2835,8 @@ base::Optional<int> HasExportImpl(Isolate* isolate, Handle<Name> property,
bool enable_index_lookup) {
Handle<WasmInstanceObject> instance = GetInstance(isolate, handler);
base::Optional<int> index =
ResolveValueSelector(isolate, property, handler, enable_index_lookup);
ResolveValueSelector(isolate, property, handler, enable_index_lookup,
"exports", GetExportNames);
if (!index) return index;
const wasm::WasmModule* module = instance->module();
......@@ -2862,6 +2922,17 @@ void ToplevelHasTrapCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
return;
}
// All the properties in the delegates below are starting with $.
if (!property->IsString()) {
args.GetReturnValue().Set(false);
return;
}
Handle<String> property_string = Handle<String>::cast(property);
if (property_string->length() < 2 || property_string->Get(0) != '$') {
args.GetReturnValue().Set(false);
return;
}
// Now check the index space proxies in order if they know the property.
constexpr std::pair<const char*, DelegateCallback<base::Optional<int>>>
kDelegates[] = {{"memories", HasMemoryImpl},
......@@ -2898,6 +2969,15 @@ void ToplevelGetTrapCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
return;
}
// All the properties in the delegates below are starting with $.
if (!property->IsString()) {
return;
}
Handle<String> property_string = Handle<String>::cast(property);
if (property_string->length() < 0 || property_string->Get(0) != '$') {
return;
}
// Try the index space proxies in the correct disambiguation order.
constexpr std::pair<const char*, DelegateCallback<Handle<Object>>>
kDelegates[] = {{"memories", GetMemoryImpl},
......@@ -2915,21 +2995,9 @@ void ToplevelGetTrapCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
}
// Populate a JSMap with name->index mappings from an ordered list of names.
Handle<JSMap> GetNameTable(Isolate* isolate,
const std::vector<Handle<String>>& names) {
Factory* factory = isolate->factory();
Handle<JSMap> name_table = factory->NewJSMap();
for (size_t i = 0; i < names.size(); ++i) {
SetMapValue(isolate, name_table, names[i], factory->NewNumberFromInt64(i));
}
return name_table;
}
// Produce a JSProxy with a given name table and get and has trap handlers.
Handle<JSProxy> GetJSProxy(
WasmFrame* frame, Handle<JSMap> name_table,
WasmFrame* frame, MaybeHandle<JSMap> maybe_name_table,
void (*get_callback)(const v8::FunctionCallbackInfo<v8::Value>&),
void (*has_callback)(const v8::FunctionCallbackInfo<v8::Value>&)) {
Isolate* isolate = frame->isolate();
......@@ -2939,7 +3007,10 @@ Handle<JSProxy> GetJSProxy(
// Besides the name table, the get and has traps need access to the instance
// and frame information.
JSObject::AddProperty(isolate, handler, "names", name_table, DONT_ENUM);
Handle<JSMap> name_table;
if (maybe_name_table.ToHandle(&name_table)) {
JSObject::AddProperty(isolate, handler, "names", name_table, DONT_ENUM);
}
Handle<WasmInstanceObject> instance(frame->wasm_instance(), isolate);
JSObject::AddProperty(isolate, handler, "instance", instance, DONT_ENUM);
Handle<BigInt> pc = BigInt::FromInt64(isolate, frame->pc());
......@@ -3032,40 +3103,28 @@ Handle<JSProxy> WasmJs::GetJSDebugProxy(WasmFrame* frame) {
HasTrapCallback<HasLocalImpl>);
JSObject::AddProperty(isolate, target, "locals", locals, READ_ONLY);
auto global_name_table = GetNameTable(isolate, GetGlobalNames(instance));
auto globals =
GetJSProxy(frame, global_name_table, GetTrapCallback<GetGlobalImpl>,
HasTrapCallback<HasGlobalImpl>);
auto globals = GetJSProxy(frame, {}, GetTrapCallback<GetGlobalImpl>,
HasTrapCallback<HasGlobalImpl>);
JSObject::AddProperty(isolate, target, "globals", globals, READ_ONLY);
auto function_name_table = GetNameTable(isolate, GetFunctionNames(instance));
auto functions =
GetJSProxy(frame, function_name_table, GetTrapCallback<GetFunctionImpl>,
HasTrapCallback<HasFunctionImpl>);
auto functions = GetJSProxy(frame, {}, GetTrapCallback<GetFunctionImpl>,
HasTrapCallback<HasFunctionImpl>);
JSObject::AddProperty(isolate, target, "functions", functions, READ_ONLY);
auto memory_name_table = GetNameTable(isolate, GetMemoryNames(instance));
auto memories =
GetJSProxy(frame, memory_name_table, GetTrapCallback<GetMemoryImpl>,
HasTrapCallback<HasMemoryImpl>);
auto memories = GetJSProxy(frame, {}, GetTrapCallback<GetMemoryImpl>,
HasTrapCallback<HasMemoryImpl>);
JSObject::AddProperty(isolate, target, "memories", memories, READ_ONLY);
auto table_name_table = GetNameTable(isolate, GetTableNames(instance));
auto tables =
GetJSProxy(frame, table_name_table, GetTrapCallback<GetTableImpl>,
HasTrapCallback<HasTableImpl>);
auto tables = GetJSProxy(frame, {}, GetTrapCallback<GetTableImpl>,
HasTrapCallback<HasTableImpl>);
JSObject::AddProperty(isolate, target, "tables", tables, READ_ONLY);
auto import_name_table = GetNameTable(isolate, GetImportNames(instance));
auto imports =
GetJSProxy(frame, import_name_table, GetTrapCallback<GetImportImpl>,
HasTrapCallback<HasImportImpl>);
auto imports = GetJSProxy(frame, {}, GetTrapCallback<GetImportImpl>,
HasTrapCallback<HasImportImpl>);
JSObject::AddProperty(isolate, target, "imports", imports, READ_ONLY);
auto export_name_table = GetNameTable(isolate, GetExportNames(instance));
auto exports =
GetJSProxy(frame, export_name_table, GetTrapCallback<GetExportImpl>,
HasTrapCallback<HasExportImpl>);
auto exports = GetJSProxy(frame, {}, GetTrapCallback<GetExportImpl>,
HasTrapCallback<HasExportImpl>);
JSObject::AddProperty(isolate, target, "exports", exports, READ_ONLY);
auto stack = GetStackObject(frame);
......
......@@ -257,24 +257,24 @@ class WasmJSBreakHandler : public debug::DebugDelegate {
Maybe<std::string> error = Nothing<std::string>();
};
WasmJSBreakHandler(Isolate* isolate, Handle<String> snippet)
: isolate_(isolate),
snippet_(snippet),
result_(Nothing<EvaluationResult>()) {
WasmJSBreakHandler(Isolate* isolate, std::vector<Handle<String>> snippets)
: isolate_(isolate), snippets_(std::move(snippets)) {
v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_), this);
}
WasmJSBreakHandler(Isolate* isolate, Handle<String> snippet)
: WasmJSBreakHandler(isolate, std::vector<Handle<String>>({snippet})) {}
~WasmJSBreakHandler() override {
v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_),
nullptr);
}
const Maybe<EvaluationResult>& result() const { return result_; }
const std::vector<EvaluationResult>& results() const { return results_; }
private:
Isolate* isolate_;
Handle<String> snippet_;
Maybe<EvaluationResult> result_;
std::vector<Handle<String>> snippets_;
std::vector<EvaluationResult> results_;
Maybe<std::string> GetPendingExceptionAsString() const {
if (!isolate_->has_pending_exception()) return Nothing<std::string>();
......@@ -304,14 +304,16 @@ class WasmJSBreakHandler : public debug::DebugDelegate {
WasmFrame* frame = WasmFrame::cast(frame_it.frame());
Handle<WasmInstanceObject> instance{frame->wasm_instance(), isolate_};
MaybeHandle<Object> result_handle = DebugEvaluate::WebAssembly(
instance, frame_it.frame()->id(), snippet_, false);
for (Handle<String> snippet : snippets_) {
MaybeHandle<Object> result_handle = DebugEvaluate::WebAssembly(
instance, frame_it.frame()->id(), snippet, false);
Maybe<std::string> error_message = GetPendingExceptionAsString();
Maybe<std::string> result_message = GetResultAsString(result_handle);
Maybe<std::string> error_message = GetPendingExceptionAsString();
Maybe<std::string> result_message = GetResultAsString(result_handle);
isolate_->clear_pending_exception();
result_ = Just<EvaluationResult>({result_message, error_message});
isolate_->clear_pending_exception();
results_.emplace_back(EvaluationResult{result_message, error_message});
}
}
};
......@@ -541,7 +543,9 @@ WASM_COMPILED_EXEC_TEST(WasmDebugEvaluate_JavaScript) {
"$var0, "
"$main, "
"$memory0, "
"globals.$nope, "
"globals[0], "
"globals[1], "
"tables[0], "
"locals[0], "
"functions[0], "
......@@ -560,13 +564,39 @@ WASM_COMPILED_EXEC_TEST(WasmDebugEvaluate_JavaScript) {
WasmJSBreakHandler break_handler(isolate, snippet);
CHECK(!code.Run(&runner).is_null());
WasmJSBreakHandler::EvaluationResult result =
break_handler.result().ToChecked();
WasmJSBreakHandler::EvaluationResult result = break_handler.results().front();
CHECK_WITH_MSG(result.error.IsNothing(), result.error.ToChecked().c_str());
CHECK_EQ(result.result.ToChecked(),
"[\"66\",{},\"65\",\"function 0() { [native code] }\",{},"
"\"66\",{},\"65\",\"function 0() { [native code] }\",{},"
"{},{},{\"0\":\"65\"},{},{},{},{},{}]");
"[\"66\",{},\"65\",\"function 0() { [native code] "
"}\",{},null,\"66\",null,{},\"65\",\"function 0() { [native code] "
"}\",{},{},{},{\"0\":\"65\"},{},{},{},{},{}]");
}
WASM_COMPILED_EXEC_TEST(WasmDebugEvaluate_JavaScript_Caching) {
WasmRunner<int> runner(execution_tier);
runner.builder().AddGlobal<int32_t>();
TestCode<int32_t> code(
&runner,
{WASM_SET_GLOBAL(0, WASM_I32V_2('B')), WASM_RETURN1(WASM_GET_GLOBAL(0))},
{});
code.BreakOnReturn(&runner);
Isolate* isolate = runner.main_isolate();
Handle<String> snippet = V8String(isolate, "JSON.stringify($global0)");
WasmJSBreakHandler break_handler(isolate, {snippet, snippet});
CHECK(!code.Run(&runner).is_null());
auto results = break_handler.results();
CHECK_EQ(results.size(), 2);
CHECK_WITH_MSG(results[0].error.IsNothing(),
results[0].error.ToChecked().c_str());
CHECK_EQ(results[0].result.ToChecked(), "66");
CHECK_WITH_MSG(results[1].error.IsNothing(),
results[1].error.ToChecked().c_str());
CHECK_EQ(results[1].result.ToChecked(), "66");
}
} // namespace
......
......@@ -296,69 +296,69 @@ KNOWN_MAPS = {
("read_only_space", 0x0314d): (67, "BasicBlockCountersMarkerMap"),
("read_only_space", 0x03191): (87, "ArrayBoilerplateDescriptionMap"),
("read_only_space", 0x03279): (99, "InterceptorInfoMap"),
("read_only_space", 0x05395): (72, "PromiseFulfillReactionJobTaskMap"),
("read_only_space", 0x053bd): (73, "PromiseRejectReactionJobTaskMap"),
("read_only_space", 0x053e5): (74, "CallableTaskMap"),
("read_only_space", 0x0540d): (75, "CallbackTaskMap"),
("read_only_space", 0x05435): (76, "PromiseResolveThenableJobTaskMap"),
("read_only_space", 0x0545d): (79, "FunctionTemplateInfoMap"),
("read_only_space", 0x05485): (80, "ObjectTemplateInfoMap"),
("read_only_space", 0x054ad): (81, "AccessCheckInfoMap"),
("read_only_space", 0x054d5): (82, "AccessorInfoMap"),
("read_only_space", 0x054fd): (83, "AccessorPairMap"),
("read_only_space", 0x05525): (84, "AliasedArgumentsEntryMap"),
("read_only_space", 0x0554d): (85, "AllocationMementoMap"),
("read_only_space", 0x05575): (88, "AsmWasmDataMap"),
("read_only_space", 0x0559d): (89, "AsyncGeneratorRequestMap"),
("read_only_space", 0x055c5): (90, "BreakPointMap"),
("read_only_space", 0x055ed): (91, "BreakPointInfoMap"),
("read_only_space", 0x05615): (92, "CachedTemplateObjectMap"),
("read_only_space", 0x0563d): (94, "ClassPositionsMap"),
("read_only_space", 0x05665): (95, "DebugInfoMap"),
("read_only_space", 0x0568d): (98, "FunctionTemplateRareDataMap"),
("read_only_space", 0x056b5): (100, "InterpreterDataMap"),
("read_only_space", 0x056dd): (101, "ModuleRequestMap"),
("read_only_space", 0x05705): (102, "PromiseCapabilityMap"),
("read_only_space", 0x0572d): (103, "PromiseReactionMap"),
("read_only_space", 0x05755): (104, "PropertyDescriptorObjectMap"),
("read_only_space", 0x0577d): (105, "PrototypeInfoMap"),
("read_only_space", 0x057a5): (106, "ScriptMap"),
("read_only_space", 0x057cd): (107, "SourceTextModuleInfoEntryMap"),
("read_only_space", 0x057f5): (108, "StackFrameInfoMap"),
("read_only_space", 0x0581d): (109, "StackTraceFrameMap"),
("read_only_space", 0x05845): (110, "TemplateObjectDescriptionMap"),
("read_only_space", 0x0586d): (111, "Tuple2Map"),
("read_only_space", 0x05895): (112, "WasmExceptionTagMap"),
("read_only_space", 0x058bd): (113, "WasmExportedFunctionDataMap"),
("read_only_space", 0x058e5): (114, "WasmIndirectFunctionTableMap"),
("read_only_space", 0x0590d): (115, "WasmJSFunctionDataMap"),
("read_only_space", 0x05935): (116, "WasmValueMap"),
("read_only_space", 0x0595d): (135, "SloppyArgumentsElementsMap"),
("read_only_space", 0x05985): (152, "DescriptorArrayMap"),
("read_only_space", 0x059ad): (157, "UncompiledDataWithoutPreparseDataMap"),
("read_only_space", 0x059d5): (156, "UncompiledDataWithPreparseDataMap"),
("read_only_space", 0x059fd): (172, "OnHeapBasicBlockProfilerDataMap"),
("read_only_space", 0x05a25): (181, "WasmCapiFunctionDataMap"),
("read_only_space", 0x05a4d): (169, "InternalClassMap"),
("read_only_space", 0x05a75): (178, "SmiPairMap"),
("read_only_space", 0x05a9d): (177, "SmiBoxMap"),
("read_only_space", 0x05ac5): (146, "ExportedSubClassBaseMap"),
("read_only_space", 0x05aed): (147, "ExportedSubClassMap"),
("read_only_space", 0x05b15): (68, "AbstractInternalClassSubclass1Map"),
("read_only_space", 0x05b3d): (69, "AbstractInternalClassSubclass2Map"),
("read_only_space", 0x05b65): (134, "InternalClassWithSmiElementsMap"),
("read_only_space", 0x05b8d): (170, "InternalClassWithStructElementsMap"),
("read_only_space", 0x05bb5): (148, "ExportedSubClass2Map"),
("read_only_space", 0x05bdd): (179, "SortStateMap"),
("read_only_space", 0x05c05): (86, "AllocationSiteWithWeakNextMap"),
("read_only_space", 0x05c2d): (86, "AllocationSiteWithoutWeakNextMap"),
("read_only_space", 0x05c55): (77, "LoadHandler1Map"),
("read_only_space", 0x05c7d): (77, "LoadHandler2Map"),
("read_only_space", 0x05ca5): (77, "LoadHandler3Map"),
("read_only_space", 0x05ccd): (78, "StoreHandler0Map"),
("read_only_space", 0x05cf5): (78, "StoreHandler1Map"),
("read_only_space", 0x05d1d): (78, "StoreHandler2Map"),
("read_only_space", 0x05d45): (78, "StoreHandler3Map"),
("read_only_space", 0x053a5): (72, "PromiseFulfillReactionJobTaskMap"),
("read_only_space", 0x053cd): (73, "PromiseRejectReactionJobTaskMap"),
("read_only_space", 0x053f5): (74, "CallableTaskMap"),
("read_only_space", 0x0541d): (75, "CallbackTaskMap"),
("read_only_space", 0x05445): (76, "PromiseResolveThenableJobTaskMap"),
("read_only_space", 0x0546d): (79, "FunctionTemplateInfoMap"),
("read_only_space", 0x05495): (80, "ObjectTemplateInfoMap"),
("read_only_space", 0x054bd): (81, "AccessCheckInfoMap"),
("read_only_space", 0x054e5): (82, "AccessorInfoMap"),
("read_only_space", 0x0550d): (83, "AccessorPairMap"),
("read_only_space", 0x05535): (84, "AliasedArgumentsEntryMap"),
("read_only_space", 0x0555d): (85, "AllocationMementoMap"),
("read_only_space", 0x05585): (88, "AsmWasmDataMap"),
("read_only_space", 0x055ad): (89, "AsyncGeneratorRequestMap"),
("read_only_space", 0x055d5): (90, "BreakPointMap"),
("read_only_space", 0x055fd): (91, "BreakPointInfoMap"),
("read_only_space", 0x05625): (92, "CachedTemplateObjectMap"),
("read_only_space", 0x0564d): (94, "ClassPositionsMap"),
("read_only_space", 0x05675): (95, "DebugInfoMap"),
("read_only_space", 0x0569d): (98, "FunctionTemplateRareDataMap"),
("read_only_space", 0x056c5): (100, "InterpreterDataMap"),
("read_only_space", 0x056ed): (101, "ModuleRequestMap"),
("read_only_space", 0x05715): (102, "PromiseCapabilityMap"),
("read_only_space", 0x0573d): (103, "PromiseReactionMap"),
("read_only_space", 0x05765): (104, "PropertyDescriptorObjectMap"),
("read_only_space", 0x0578d): (105, "PrototypeInfoMap"),
("read_only_space", 0x057b5): (106, "ScriptMap"),
("read_only_space", 0x057dd): (107, "SourceTextModuleInfoEntryMap"),
("read_only_space", 0x05805): (108, "StackFrameInfoMap"),
("read_only_space", 0x0582d): (109, "StackTraceFrameMap"),
("read_only_space", 0x05855): (110, "TemplateObjectDescriptionMap"),
("read_only_space", 0x0587d): (111, "Tuple2Map"),
("read_only_space", 0x058a5): (112, "WasmExceptionTagMap"),
("read_only_space", 0x058cd): (113, "WasmExportedFunctionDataMap"),
("read_only_space", 0x058f5): (114, "WasmIndirectFunctionTableMap"),
("read_only_space", 0x0591d): (115, "WasmJSFunctionDataMap"),
("read_only_space", 0x05945): (116, "WasmValueMap"),
("read_only_space", 0x0596d): (135, "SloppyArgumentsElementsMap"),
("read_only_space", 0x05995): (152, "DescriptorArrayMap"),
("read_only_space", 0x059bd): (157, "UncompiledDataWithoutPreparseDataMap"),
("read_only_space", 0x059e5): (156, "UncompiledDataWithPreparseDataMap"),
("read_only_space", 0x05a0d): (172, "OnHeapBasicBlockProfilerDataMap"),
("read_only_space", 0x05a35): (181, "WasmCapiFunctionDataMap"),
("read_only_space", 0x05a5d): (169, "InternalClassMap"),
("read_only_space", 0x05a85): (178, "SmiPairMap"),
("read_only_space", 0x05aad): (177, "SmiBoxMap"),
("read_only_space", 0x05ad5): (146, "ExportedSubClassBaseMap"),
("read_only_space", 0x05afd): (147, "ExportedSubClassMap"),
("read_only_space", 0x05b25): (68, "AbstractInternalClassSubclass1Map"),
("read_only_space", 0x05b4d): (69, "AbstractInternalClassSubclass2Map"),
("read_only_space", 0x05b75): (134, "InternalClassWithSmiElementsMap"),
("read_only_space", 0x05b9d): (170, "InternalClassWithStructElementsMap"),
("read_only_space", 0x05bc5): (148, "ExportedSubClass2Map"),
("read_only_space", 0x05bed): (179, "SortStateMap"),
("read_only_space", 0x05c15): (86, "AllocationSiteWithWeakNextMap"),
("read_only_space", 0x05c3d): (86, "AllocationSiteWithoutWeakNextMap"),
("read_only_space", 0x05c65): (77, "LoadHandler1Map"),
("read_only_space", 0x05c8d): (77, "LoadHandler2Map"),
("read_only_space", 0x05cb5): (77, "LoadHandler3Map"),
("read_only_space", 0x05cdd): (78, "StoreHandler0Map"),
("read_only_space", 0x05d05): (78, "StoreHandler1Map"),
("read_only_space", 0x05d2d): (78, "StoreHandler2Map"),
("read_only_space", 0x05d55): (78, "StoreHandler3Map"),
("map_space", 0x02115): (1057, "ExternalMap"),
("map_space", 0x0213d): (1072, "JSMessageObjectMap"),
("map_space", 0x02165): (182, "WasmRttEqrefMap"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment