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,
DCHECK(!native_module->has_code(static_cast<uint32_t>(func_index)));
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
// tracing / debugging.
std::string func_name;
WasmName func_name;
{
WasmName name = Vector<const char>::cast(
native_module->module_object()->GetRawFunctionName(func_index));
// Copy to std::string, because the underlying string object might move on
// the heap.
func_name.assign(name.start(), static_cast<size_t>(name.length()));
ModuleWireBytes wire_bytes(native_module->wire_bytes());
WireBytesRef name_ref =
module_env->module->LookupName(wire_bytes, func_index);
func_name = wire_bytes.GetName(name_ref);
}
TRACE_LAZY("Compiling function '%s' (#%d).\n", func_name.c_str(), func_index);
ModuleEnv* module_env = native_module->compilation_state()->module_env();
TRACE_LAZY("Compiling function '%.*s' (#%d).\n", func_name.length(),
func_name.start(), func_index);
const uint8_t* module_start = native_module->wire_bytes().start();
......@@ -400,8 +400,8 @@ wasm::WasmCode* LazyCompileFunction(Isolate* isolate,
module_start + func->code.end_offset()};
ErrorThrower thrower(isolate, "WasmLazyCompile");
WasmCompilationUnit unit(isolate, module_env, native_module, body,
CStrVector(func_name.c_str()), func_index);
WasmCompilationUnit unit(isolate, module_env, native_module, body, func_name,
func_index);
unit.ExecuteCompilation();
wasm::WasmCode* wasm_code = unit.FinishCompilation(&thrower);
......
......@@ -149,11 +149,18 @@ void WasmCode::LogCode(Isolate* isolate) const {
DCHECK(ShouldBeLogged(isolate));
if (index_.IsJust()) {
uint32_t index = this->index();
Handle<WasmModuleObject> module_object(native_module()->module_object(),
isolate);
ModuleWireBytes wire_bytes(native_module()->wire_bytes());
// 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;
Handle<String> name(
WasmModuleObject::GetFunctionName(isolate, module_object, index));
auto cname =
name->ToCString(AllowNullsFlag::DISALLOW_NULLS,
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