Commit 676b4895 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Remove all uses of {NativeModule::module_object}.

The field in question is a phantom link back into the GC'ed heap from
the native WebAssembly heap. It is one of the last pieces that makes the
compiled module specific to an Isolate. This is intended to finally make
code sharable between Isolates.

R=herhut@chromium.org
BUG=v8:7424

Change-Id: I75bcfabaf5149ca98a75d3ea3f19d8d8a8d96dce
Reviewed-on: https://chromium-review.googlesource.com/1113452Reviewed-by: 's avatarStephan Herhut <herhut@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54019}
parent 733b1574
...@@ -377,20 +377,20 @@ wasm::WasmCode* LazyCompileFunction(Isolate* isolate, ...@@ -377,20 +377,20 @@ wasm::WasmCode* LazyCompileFunction(Isolate* isolate,
DCHECK(!native_module->has_code(static_cast<uint32_t>(func_index))); DCHECK(!native_module->has_code(static_cast<uint32_t>(func_index)));
compilation_timer.Start(); compilation_timer.Start();
ModuleEnv* module_env = native_module->compilation_state()->module_env();
// TODO(wasm): Refactor this to only get the name if it is really needed for // TODO(wasm): Refactor this to only get the name if it is really needed for
// tracing / debugging. // tracing / debugging.
std::string func_name; WasmName func_name;
{ {
WasmName name = Vector<const char>::cast( ModuleWireBytes wire_bytes(native_module->wire_bytes());
native_module->module_object()->GetRawFunctionName(func_index)); WireBytesRef name_ref =
// Copy to std::string, because the underlying string object might move on module_env->module->LookupName(wire_bytes, func_index);
// the heap. func_name = wire_bytes.GetName(name_ref);
func_name.assign(name.start(), static_cast<size_t>(name.length()));
} }
TRACE_LAZY("Compiling function '%s' (#%d).\n", func_name.c_str(), func_index); TRACE_LAZY("Compiling function '%.*s' (#%d).\n", func_name.length(),
func_name.start(), func_index);
ModuleEnv* module_env = native_module->compilation_state()->module_env();
const uint8_t* module_start = native_module->wire_bytes().start(); const uint8_t* module_start = native_module->wire_bytes().start();
...@@ -400,8 +400,8 @@ wasm::WasmCode* LazyCompileFunction(Isolate* isolate, ...@@ -400,8 +400,8 @@ wasm::WasmCode* LazyCompileFunction(Isolate* isolate,
module_start + func->code.end_offset()}; module_start + func->code.end_offset()};
ErrorThrower thrower(isolate, "WasmLazyCompile"); ErrorThrower thrower(isolate, "WasmLazyCompile");
WasmCompilationUnit unit(isolate, module_env, native_module, body, WasmCompilationUnit unit(isolate, module_env, native_module, body, func_name,
CStrVector(func_name.c_str()), func_index); func_index);
unit.ExecuteCompilation(); unit.ExecuteCompilation();
wasm::WasmCode* wasm_code = unit.FinishCompilation(&thrower); wasm::WasmCode* wasm_code = unit.FinishCompilation(&thrower);
......
...@@ -149,11 +149,18 @@ void WasmCode::LogCode(Isolate* isolate) const { ...@@ -149,11 +149,18 @@ void WasmCode::LogCode(Isolate* isolate) const {
DCHECK(ShouldBeLogged(isolate)); DCHECK(ShouldBeLogged(isolate));
if (index_.IsJust()) { if (index_.IsJust()) {
uint32_t index = this->index(); uint32_t index = this->index();
Handle<WasmModuleObject> module_object(native_module()->module_object(), ModuleWireBytes wire_bytes(native_module()->wire_bytes());
isolate); // TODO(herhut): Allow to log code without on-heap round-trip of the name.
ModuleEnv* module_env = GetModuleEnv(native_module()->compilation_state());
WireBytesRef name_ref = module_env->module->LookupName(wire_bytes, index);
WasmName name_vec = wire_bytes.GetName(name_ref);
MaybeHandle<String> maybe_name = isolate->factory()->NewStringFromUtf8(
Vector<const char>::cast(name_vec));
Handle<String> name;
if (!maybe_name.ToHandle(&name)) {
name = isolate->factory()->NewStringFromAsciiChecked("<name too long>");
}
int name_length; int name_length;
Handle<String> name(
WasmModuleObject::GetFunctionName(isolate, module_object, index));
auto cname = auto cname =
name->ToCString(AllowNullsFlag::DISALLOW_NULLS, name->ToCString(AllowNullsFlag::DISALLOW_NULLS,
RobustnessFlag::ROBUST_STRING_TRAVERSAL, &name_length); RobustnessFlag::ROBUST_STRING_TRAVERSAL, &name_length);
......
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