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 @@ ...@@ -367,6 +367,7 @@
V(_, wasm_exception_values_symbol) \ V(_, wasm_exception_values_symbol) \
V(_, wasm_uncatchable_symbol) \ V(_, wasm_uncatchable_symbol) \
V(_, wasm_wrapped_object_symbol) \ V(_, wasm_wrapped_object_symbol) \
V(_, wasm_debug_proxy_name_tables) \
V(_, uninitialized_symbol) V(_, uninitialized_symbol)
#define PUBLIC_SYMBOL_LIST_GENERATOR(V, _) \ #define PUBLIC_SYMBOL_LIST_GENERATOR(V, _) \
......
This diff is collapsed.
...@@ -257,24 +257,24 @@ class WasmJSBreakHandler : public debug::DebugDelegate { ...@@ -257,24 +257,24 @@ class WasmJSBreakHandler : public debug::DebugDelegate {
Maybe<std::string> error = Nothing<std::string>(); Maybe<std::string> error = Nothing<std::string>();
}; };
WasmJSBreakHandler(Isolate* isolate, Handle<String> snippet) WasmJSBreakHandler(Isolate* isolate, std::vector<Handle<String>> snippets)
: isolate_(isolate), : isolate_(isolate), snippets_(std::move(snippets)) {
snippet_(snippet),
result_(Nothing<EvaluationResult>()) {
v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_), this); v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_), this);
} }
WasmJSBreakHandler(Isolate* isolate, Handle<String> snippet)
: WasmJSBreakHandler(isolate, std::vector<Handle<String>>({snippet})) {}
~WasmJSBreakHandler() override { ~WasmJSBreakHandler() override {
v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_), v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_),
nullptr); nullptr);
} }
const Maybe<EvaluationResult>& result() const { return result_; } const std::vector<EvaluationResult>& results() const { return results_; }
private: private:
Isolate* isolate_; Isolate* isolate_;
Handle<String> snippet_; std::vector<Handle<String>> snippets_;
Maybe<EvaluationResult> result_; std::vector<EvaluationResult> results_;
Maybe<std::string> GetPendingExceptionAsString() const { Maybe<std::string> GetPendingExceptionAsString() const {
if (!isolate_->has_pending_exception()) return Nothing<std::string>(); if (!isolate_->has_pending_exception()) return Nothing<std::string>();
...@@ -304,14 +304,16 @@ class WasmJSBreakHandler : public debug::DebugDelegate { ...@@ -304,14 +304,16 @@ class WasmJSBreakHandler : public debug::DebugDelegate {
WasmFrame* frame = WasmFrame::cast(frame_it.frame()); WasmFrame* frame = WasmFrame::cast(frame_it.frame());
Handle<WasmInstanceObject> instance{frame->wasm_instance(), isolate_}; Handle<WasmInstanceObject> instance{frame->wasm_instance(), isolate_};
for (Handle<String> snippet : snippets_) {
MaybeHandle<Object> result_handle = DebugEvaluate::WebAssembly( MaybeHandle<Object> result_handle = DebugEvaluate::WebAssembly(
instance, frame_it.frame()->id(), snippet_, false); instance, frame_it.frame()->id(), snippet, false);
Maybe<std::string> error_message = GetPendingExceptionAsString(); Maybe<std::string> error_message = GetPendingExceptionAsString();
Maybe<std::string> result_message = GetResultAsString(result_handle); Maybe<std::string> result_message = GetResultAsString(result_handle);
isolate_->clear_pending_exception(); isolate_->clear_pending_exception();
result_ = Just<EvaluationResult>({result_message, error_message}); results_.emplace_back(EvaluationResult{result_message, error_message});
}
} }
}; };
...@@ -541,7 +543,9 @@ WASM_COMPILED_EXEC_TEST(WasmDebugEvaluate_JavaScript) { ...@@ -541,7 +543,9 @@ WASM_COMPILED_EXEC_TEST(WasmDebugEvaluate_JavaScript) {
"$var0, " "$var0, "
"$main, " "$main, "
"$memory0, " "$memory0, "
"globals.$nope, "
"globals[0], " "globals[0], "
"globals[1], "
"tables[0], " "tables[0], "
"locals[0], " "locals[0], "
"functions[0], " "functions[0], "
...@@ -560,13 +564,39 @@ WASM_COMPILED_EXEC_TEST(WasmDebugEvaluate_JavaScript) { ...@@ -560,13 +564,39 @@ WASM_COMPILED_EXEC_TEST(WasmDebugEvaluate_JavaScript) {
WasmJSBreakHandler break_handler(isolate, snippet); WasmJSBreakHandler break_handler(isolate, snippet);
CHECK(!code.Run(&runner).is_null()); CHECK(!code.Run(&runner).is_null());
WasmJSBreakHandler::EvaluationResult result = WasmJSBreakHandler::EvaluationResult result = break_handler.results().front();
break_handler.result().ToChecked();
CHECK_WITH_MSG(result.error.IsNothing(), result.error.ToChecked().c_str()); CHECK_WITH_MSG(result.error.IsNothing(), result.error.ToChecked().c_str());
CHECK_EQ(result.result.ToChecked(), CHECK_EQ(result.result.ToChecked(),
"[\"66\",{},\"65\",\"function 0() { [native code] }\",{}," "[\"66\",{},\"65\",\"function 0() { [native code] "
"\"66\",{},\"65\",\"function 0() { [native code] }\",{}," "}\",{},null,\"66\",null,{},\"65\",\"function 0() { [native code] "
"{},{},{\"0\":\"65\"},{},{},{},{},{}]"); "}\",{},{},{},{\"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 } // namespace
......
...@@ -296,69 +296,69 @@ KNOWN_MAPS = { ...@@ -296,69 +296,69 @@ KNOWN_MAPS = {
("read_only_space", 0x0314d): (67, "BasicBlockCountersMarkerMap"), ("read_only_space", 0x0314d): (67, "BasicBlockCountersMarkerMap"),
("read_only_space", 0x03191): (87, "ArrayBoilerplateDescriptionMap"), ("read_only_space", 0x03191): (87, "ArrayBoilerplateDescriptionMap"),
("read_only_space", 0x03279): (99, "InterceptorInfoMap"), ("read_only_space", 0x03279): (99, "InterceptorInfoMap"),
("read_only_space", 0x05395): (72, "PromiseFulfillReactionJobTaskMap"), ("read_only_space", 0x053a5): (72, "PromiseFulfillReactionJobTaskMap"),
("read_only_space", 0x053bd): (73, "PromiseRejectReactionJobTaskMap"), ("read_only_space", 0x053cd): (73, "PromiseRejectReactionJobTaskMap"),
("read_only_space", 0x053e5): (74, "CallableTaskMap"), ("read_only_space", 0x053f5): (74, "CallableTaskMap"),
("read_only_space", 0x0540d): (75, "CallbackTaskMap"), ("read_only_space", 0x0541d): (75, "CallbackTaskMap"),
("read_only_space", 0x05435): (76, "PromiseResolveThenableJobTaskMap"), ("read_only_space", 0x05445): (76, "PromiseResolveThenableJobTaskMap"),
("read_only_space", 0x0545d): (79, "FunctionTemplateInfoMap"), ("read_only_space", 0x0546d): (79, "FunctionTemplateInfoMap"),
("read_only_space", 0x05485): (80, "ObjectTemplateInfoMap"), ("read_only_space", 0x05495): (80, "ObjectTemplateInfoMap"),
("read_only_space", 0x054ad): (81, "AccessCheckInfoMap"), ("read_only_space", 0x054bd): (81, "AccessCheckInfoMap"),
("read_only_space", 0x054d5): (82, "AccessorInfoMap"), ("read_only_space", 0x054e5): (82, "AccessorInfoMap"),
("read_only_space", 0x054fd): (83, "AccessorPairMap"), ("read_only_space", 0x0550d): (83, "AccessorPairMap"),
("read_only_space", 0x05525): (84, "AliasedArgumentsEntryMap"), ("read_only_space", 0x05535): (84, "AliasedArgumentsEntryMap"),
("read_only_space", 0x0554d): (85, "AllocationMementoMap"), ("read_only_space", 0x0555d): (85, "AllocationMementoMap"),
("read_only_space", 0x05575): (88, "AsmWasmDataMap"), ("read_only_space", 0x05585): (88, "AsmWasmDataMap"),
("read_only_space", 0x0559d): (89, "AsyncGeneratorRequestMap"), ("read_only_space", 0x055ad): (89, "AsyncGeneratorRequestMap"),
("read_only_space", 0x055c5): (90, "BreakPointMap"), ("read_only_space", 0x055d5): (90, "BreakPointMap"),
("read_only_space", 0x055ed): (91, "BreakPointInfoMap"), ("read_only_space", 0x055fd): (91, "BreakPointInfoMap"),
("read_only_space", 0x05615): (92, "CachedTemplateObjectMap"), ("read_only_space", 0x05625): (92, "CachedTemplateObjectMap"),
("read_only_space", 0x0563d): (94, "ClassPositionsMap"), ("read_only_space", 0x0564d): (94, "ClassPositionsMap"),
("read_only_space", 0x05665): (95, "DebugInfoMap"), ("read_only_space", 0x05675): (95, "DebugInfoMap"),
("read_only_space", 0x0568d): (98, "FunctionTemplateRareDataMap"), ("read_only_space", 0x0569d): (98, "FunctionTemplateRareDataMap"),
("read_only_space", 0x056b5): (100, "InterpreterDataMap"), ("read_only_space", 0x056c5): (100, "InterpreterDataMap"),
("read_only_space", 0x056dd): (101, "ModuleRequestMap"), ("read_only_space", 0x056ed): (101, "ModuleRequestMap"),
("read_only_space", 0x05705): (102, "PromiseCapabilityMap"), ("read_only_space", 0x05715): (102, "PromiseCapabilityMap"),
("read_only_space", 0x0572d): (103, "PromiseReactionMap"), ("read_only_space", 0x0573d): (103, "PromiseReactionMap"),
("read_only_space", 0x05755): (104, "PropertyDescriptorObjectMap"), ("read_only_space", 0x05765): (104, "PropertyDescriptorObjectMap"),
("read_only_space", 0x0577d): (105, "PrototypeInfoMap"), ("read_only_space", 0x0578d): (105, "PrototypeInfoMap"),
("read_only_space", 0x057a5): (106, "ScriptMap"), ("read_only_space", 0x057b5): (106, "ScriptMap"),
("read_only_space", 0x057cd): (107, "SourceTextModuleInfoEntryMap"), ("read_only_space", 0x057dd): (107, "SourceTextModuleInfoEntryMap"),
("read_only_space", 0x057f5): (108, "StackFrameInfoMap"), ("read_only_space", 0x05805): (108, "StackFrameInfoMap"),
("read_only_space", 0x0581d): (109, "StackTraceFrameMap"), ("read_only_space", 0x0582d): (109, "StackTraceFrameMap"),
("read_only_space", 0x05845): (110, "TemplateObjectDescriptionMap"), ("read_only_space", 0x05855): (110, "TemplateObjectDescriptionMap"),
("read_only_space", 0x0586d): (111, "Tuple2Map"), ("read_only_space", 0x0587d): (111, "Tuple2Map"),
("read_only_space", 0x05895): (112, "WasmExceptionTagMap"), ("read_only_space", 0x058a5): (112, "WasmExceptionTagMap"),
("read_only_space", 0x058bd): (113, "WasmExportedFunctionDataMap"), ("read_only_space", 0x058cd): (113, "WasmExportedFunctionDataMap"),
("read_only_space", 0x058e5): (114, "WasmIndirectFunctionTableMap"), ("read_only_space", 0x058f5): (114, "WasmIndirectFunctionTableMap"),
("read_only_space", 0x0590d): (115, "WasmJSFunctionDataMap"), ("read_only_space", 0x0591d): (115, "WasmJSFunctionDataMap"),
("read_only_space", 0x05935): (116, "WasmValueMap"), ("read_only_space", 0x05945): (116, "WasmValueMap"),
("read_only_space", 0x0595d): (135, "SloppyArgumentsElementsMap"), ("read_only_space", 0x0596d): (135, "SloppyArgumentsElementsMap"),
("read_only_space", 0x05985): (152, "DescriptorArrayMap"), ("read_only_space", 0x05995): (152, "DescriptorArrayMap"),
("read_only_space", 0x059ad): (157, "UncompiledDataWithoutPreparseDataMap"), ("read_only_space", 0x059bd): (157, "UncompiledDataWithoutPreparseDataMap"),
("read_only_space", 0x059d5): (156, "UncompiledDataWithPreparseDataMap"), ("read_only_space", 0x059e5): (156, "UncompiledDataWithPreparseDataMap"),
("read_only_space", 0x059fd): (172, "OnHeapBasicBlockProfilerDataMap"), ("read_only_space", 0x05a0d): (172, "OnHeapBasicBlockProfilerDataMap"),
("read_only_space", 0x05a25): (181, "WasmCapiFunctionDataMap"), ("read_only_space", 0x05a35): (181, "WasmCapiFunctionDataMap"),
("read_only_space", 0x05a4d): (169, "InternalClassMap"), ("read_only_space", 0x05a5d): (169, "InternalClassMap"),
("read_only_space", 0x05a75): (178, "SmiPairMap"), ("read_only_space", 0x05a85): (178, "SmiPairMap"),
("read_only_space", 0x05a9d): (177, "SmiBoxMap"), ("read_only_space", 0x05aad): (177, "SmiBoxMap"),
("read_only_space", 0x05ac5): (146, "ExportedSubClassBaseMap"), ("read_only_space", 0x05ad5): (146, "ExportedSubClassBaseMap"),
("read_only_space", 0x05aed): (147, "ExportedSubClassMap"), ("read_only_space", 0x05afd): (147, "ExportedSubClassMap"),
("read_only_space", 0x05b15): (68, "AbstractInternalClassSubclass1Map"), ("read_only_space", 0x05b25): (68, "AbstractInternalClassSubclass1Map"),
("read_only_space", 0x05b3d): (69, "AbstractInternalClassSubclass2Map"), ("read_only_space", 0x05b4d): (69, "AbstractInternalClassSubclass2Map"),
("read_only_space", 0x05b65): (134, "InternalClassWithSmiElementsMap"), ("read_only_space", 0x05b75): (134, "InternalClassWithSmiElementsMap"),
("read_only_space", 0x05b8d): (170, "InternalClassWithStructElementsMap"), ("read_only_space", 0x05b9d): (170, "InternalClassWithStructElementsMap"),
("read_only_space", 0x05bb5): (148, "ExportedSubClass2Map"), ("read_only_space", 0x05bc5): (148, "ExportedSubClass2Map"),
("read_only_space", 0x05bdd): (179, "SortStateMap"), ("read_only_space", 0x05bed): (179, "SortStateMap"),
("read_only_space", 0x05c05): (86, "AllocationSiteWithWeakNextMap"), ("read_only_space", 0x05c15): (86, "AllocationSiteWithWeakNextMap"),
("read_only_space", 0x05c2d): (86, "AllocationSiteWithoutWeakNextMap"), ("read_only_space", 0x05c3d): (86, "AllocationSiteWithoutWeakNextMap"),
("read_only_space", 0x05c55): (77, "LoadHandler1Map"), ("read_only_space", 0x05c65): (77, "LoadHandler1Map"),
("read_only_space", 0x05c7d): (77, "LoadHandler2Map"), ("read_only_space", 0x05c8d): (77, "LoadHandler2Map"),
("read_only_space", 0x05ca5): (77, "LoadHandler3Map"), ("read_only_space", 0x05cb5): (77, "LoadHandler3Map"),
("read_only_space", 0x05ccd): (78, "StoreHandler0Map"), ("read_only_space", 0x05cdd): (78, "StoreHandler0Map"),
("read_only_space", 0x05cf5): (78, "StoreHandler1Map"), ("read_only_space", 0x05d05): (78, "StoreHandler1Map"),
("read_only_space", 0x05d1d): (78, "StoreHandler2Map"), ("read_only_space", 0x05d2d): (78, "StoreHandler2Map"),
("read_only_space", 0x05d45): (78, "StoreHandler3Map"), ("read_only_space", 0x05d55): (78, "StoreHandler3Map"),
("map_space", 0x02115): (1057, "ExternalMap"), ("map_space", 0x02115): (1057, "ExternalMap"),
("map_space", 0x0213d): (1072, "JSMessageObjectMap"), ("map_space", 0x0213d): (1072, "JSMessageObjectMap"),
("map_space", 0x02165): (182, "WasmRttEqrefMap"), ("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