Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(771)

Unified Diff: src/compiler/wasm-compiler.cc

Issue 2103983003: Revert "[wasm] Complete separation of compilation and instantiation" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index b22e6e81b7d46654967485f61da58791de3091e1..e8346399c4f512ddcff19fc882151d31cd6ac440 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -2955,31 +2955,29 @@ void WasmGraphBuilder::SetSourcePosition(Node* node,
}
static void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
- Isolate* isolate, Handle<Code> code,
+ CompilationInfo* info,
const char* message, uint32_t index,
- const wasm::WasmName& module_name,
- const wasm::WasmName& func_name) {
- DCHECK(isolate->logger()->is_logging_code_events() ||
- isolate->is_profiling());
-
- ScopedVector<char> buffer(128);
- SNPrintF(buffer, "%s#%d:%.*s:%.*s", message, index, module_name.length(),
- module_name.start(), func_name.length(), func_name.start());
- Handle<String> name_str =
- isolate->factory()->NewStringFromAsciiChecked(buffer.start());
- Handle<String> script_str =
- isolate->factory()->NewStringFromAsciiChecked("(WASM)");
- Handle<SharedFunctionInfo> shared =
- isolate->factory()->NewSharedFunctionInfo(name_str, code, false);
- PROFILE(isolate, CodeCreateEvent(tag, AbstractCode::cast(*code), *shared,
- *script_str, 0, 0));
-}
-
-Handle<JSFunction> CompileJSToWasmWrapper(Isolate* isolate,
- wasm::ModuleEnv* module,
- Handle<String> name,
- Handle<Code> wasm_code,
- uint32_t index) {
+ wasm::WasmName func_name) {
+ Isolate* isolate = info->isolate();
+ if (isolate->logger()->is_logging_code_events() || isolate->is_profiling()) {
+ ScopedVector<char> buffer(128);
+ SNPrintF(buffer, "%s#%d:%.*s", message, index, func_name.length(),
+ func_name.start());
+ Handle<String> name_str =
+ isolate->factory()->NewStringFromAsciiChecked(buffer.start());
+ Handle<String> script_str =
+ isolate->factory()->NewStringFromAsciiChecked("(WASM)");
+ Handle<Code> code = info->code();
+ Handle<SharedFunctionInfo> shared =
+ isolate->factory()->NewSharedFunctionInfo(name_str, code, false);
+ PROFILE(isolate, CodeCreateEvent(tag, AbstractCode::cast(*code), *shared,
+ *script_str, 0, 0));
+ }
+}
+
+Handle<JSFunction> CompileJSToWasmWrapper(
+ Isolate* isolate, wasm::ModuleEnv* module, Handle<String> name,
+ Handle<Code> wasm_code, Handle<JSObject> module_object, uint32_t index) {
const wasm::WasmFunction* func = &module->module->functions[index];
//----------------------------------------------------------------------------
@@ -2992,6 +2990,7 @@ Handle<JSFunction> CompileJSToWasmWrapper(Isolate* isolate,
shared->set_internal_formal_parameter_count(params);
Handle<JSFunction> function = isolate->factory()->NewFunction(
isolate->wasm_function_map(), name, MaybeHandle<Code>());
+ function->SetInternalField(0, *module_object);
function->set_shared(*shared);
//----------------------------------------------------------------------------
@@ -3057,13 +3056,9 @@ Handle<JSFunction> CompileJSToWasmWrapper(Isolate* isolate,
buffer.Dispose();
}
- if (isolate->logger()->is_logging_code_events() ||
- isolate->is_profiling()) {
- RecordFunctionCompilation(
- CodeEventListener::FUNCTION_TAG, isolate, code, "js-to-wasm", index,
- wasm::WasmName("export"),
- module->module->GetName(func->name_offset, func->name_length));
- }
+ RecordFunctionCompilation(
+ CodeEventListener::FUNCTION_TAG, &info, "js-to-wasm", index,
+ module->module->GetName(func->name_offset, func->name_length));
// Set the JSFunction's machine code.
function->set_code(*code);
}
@@ -3072,9 +3067,9 @@ Handle<JSFunction> CompileJSToWasmWrapper(Isolate* isolate,
Handle<Code> CompileWasmToJSWrapper(Isolate* isolate,
Handle<JSFunction> function,
- wasm::FunctionSig* sig, uint32_t index,
- Handle<String> import_module,
- MaybeHandle<String> import_function) {
+ wasm::FunctionSig* sig,
+ wasm::WasmName module_name,
+ wasm::WasmName function_name) {
//----------------------------------------------------------------------------
// Create the Graph
//----------------------------------------------------------------------------
@@ -3133,21 +3128,10 @@ Handle<Code> CompileWasmToJSWrapper(Isolate* isolate,
if (debugging) {
buffer.Dispose();
}
- }
- if (isolate->logger()->is_logging_code_events() || isolate->is_profiling()) {
- const char* function_name = nullptr;
- int function_name_size = 0;
- if (!import_function.is_null()) {
- Handle<String> handle = import_function.ToHandleChecked();
- function_name = handle->ToCString().get();
- function_name_size = handle->length();
- }
- RecordFunctionCompilation(
- CodeEventListener::FUNCTION_TAG, isolate, code, "wasm-to-js", index,
- {import_module->ToCString().get(), import_module->length()},
- {function_name, function_name_size});
- }
+ RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, &info,
+ "wasm-to-js", 0, module_name);
+ }
return code;
}
@@ -3310,14 +3294,11 @@ Handle<Code> WasmCompilationUnit::FinishCompilation() {
Handle<Code> code = info_.code();
DCHECK(!code.is_null());
- if (isolate_->logger()->is_logging_code_events() ||
- isolate_->is_profiling()) {
- RecordFunctionCompilation(
- CodeEventListener::FUNCTION_TAG, isolate_, code, "WASM_function",
- function_->func_index, wasm::WasmName("module"),
- module_env_->module->GetName(function_->name_offset,
- function_->name_length));
- }
+ RecordFunctionCompilation(
+ CodeEventListener::FUNCTION_TAG, &info_, "WASM_function",
+ function_->func_index,
+ module_env_->module->GetName(function_->name_offset,
+ function_->name_length));
if (FLAG_trace_wasm_decode_time) {
double compile_ms = compile_timer.Elapsed().InMillisecondsF();
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698