Index: src/compiler/wasm-compiler.cc |
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc |
index d838e019581e85400700a8329cad5e7e41274ccf..2f867c3037c0e201b1beaf32bfa0cfb4b98514d8 100644 |
--- a/src/compiler/wasm-compiler.cc |
+++ b/src/compiler/wasm-compiler.cc |
@@ -29,6 +29,9 @@ |
#include "src/code-factory.h" |
#include "src/code-stubs.h" |
+#include "src/factory.h" |
+#include "src/log-inl.h" |
+#include "src/profiler/cpu-profiler.h" |
#include "src/wasm/ast-decoder.h" |
#include "src/wasm/wasm-module.h" |
@@ -1924,21 +1927,18 @@ Handle<JSFunction> CompileJSToWasmWrapper( |
CompilationInfo info("js-to-wasm", isolate, &zone, flags); |
Handle<Code> code = |
Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr); |
- |
-#ifdef ENABLE_DISASSEMBLER |
- // Disassemble the wrapper code for debugging. |
- if (!code.is_null() && FLAG_print_opt_code) { |
- Vector<char> buffer; |
- const char* name = ""; |
- if (func->name_offset > 0) { |
- const byte* ptr = module->module->module_start + func->name_offset; |
- name = reinterpret_cast<const char*>(ptr); |
- } |
- SNPrintF(buffer, "JS->WASM function wrapper #%d:%s", index, name); |
- OFStream os(stdout); |
- code->Disassemble(buffer.start(), os); |
+ if (info.isolate()->logger()->is_logging_code_events() || |
+ info.isolate()->cpu_profiler()->is_profiling()) { |
+ ScopedVector<char> buffer(128); |
+ SNPrintF(buffer, "JS->WASM_function_wrapper_#%d:%s", index, |
+ module->module->GetName(func->name_offset)); |
+ Handle<String> name_str = |
+ isolate->factory()->NewStringFromAsciiChecked(buffer.start()); |
+ Handle<SharedFunctionInfo> shared = |
titzer
2016/01/26 15:42:31
You should probably use the shared function info f
Weiliang
2016/01/28 14:03:35
the shared function info here is the js-to-wasm tr
|
+ isolate->factory()->NewSharedFunctionInfo(name_str, code, false); |
+ PROFILE(info.isolate(), CodeCreateEvent(Logger::FUNCTION_TAG, *code, |
+ *shared, &info, *name_str, 0, 0)); |
} |
-#endif |
// Set the JSFunction's machine code. |
function->set_code(*code); |
} |
@@ -1999,20 +1999,18 @@ Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module, |
CompilationInfo info("wasm-to-js", isolate, &zone, flags); |
code = Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr); |
-#ifdef ENABLE_DISASSEMBLER |
- // Disassemble the wrapper code for debugging. |
- if (!code.is_null() && FLAG_print_opt_code) { |
- Vector<char> buffer; |
- const char* name = ""; |
- if (func->name_offset > 0) { |
- const byte* ptr = module->module->module_start + func->name_offset; |
- name = reinterpret_cast<const char*>(ptr); |
- } |
- SNPrintF(buffer, "WASM->JS function wrapper #%d:%s", index, name); |
- OFStream os(stdout); |
- code->Disassemble(buffer.start(), os); |
+ if (info.isolate()->logger()->is_logging_code_events() || |
+ info.isolate()->cpu_profiler()->is_profiling()) { |
+ ScopedVector<char> buffer(128); |
+ SNPrintF(buffer, "WASM->JS_function_wrapper_#%d:%s", index, |
+ module->module->GetName(func->name_offset)); |
+ Handle<String> name_str = |
+ isolate->factory()->NewStringFromAsciiChecked(buffer.start()); |
+ Handle<SharedFunctionInfo> shared = |
+ isolate->factory()->NewSharedFunctionInfo(name_str, code, false); |
+ PROFILE(info.isolate(), CodeCreateEvent(Logger::FUNCTION_TAG, *code, |
+ *shared, &info, *name_str, 0, 0)); |
} |
-#endif |
} |
return code; |
} |
@@ -2023,14 +2021,13 @@ Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate, |
wasm::ModuleEnv* module_env, |
const wasm::WasmFunction& function, |
int index) { |
+ ScopedVector<char> buffer(128); |
titzer
2016/01/26 15:42:31
This will always build this string, even when it i
Weiliang
2016/01/28 14:03:35
Done.
|
+ SNPrintF(buffer, "WASM_function_#%d:%s", index, |
+ module_env->module->GetName(function.name_offset)); |
if (FLAG_trace_wasm_compiler || FLAG_trace_wasm_decode_time) { |
// TODO(titzer): clean me up a bit. |
OFStream os(stdout); |
- os << "Compiling WASM function #" << index << ":"; |
- if (function.name_offset > 0) { |
- os << module_env->module->GetName(function.name_offset); |
- } |
- os << std::endl; |
+ os << "Compiling " << buffer.start() << std::endl; |
} |
// Initialize the function environment for decoding. |
wasm::FunctionEnv env; |
@@ -2063,9 +2060,7 @@ Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate, |
os << "Compilation failed: " << result << std::endl; |
} |
// Add the function as another context for the exception |
- Vector<char> buffer; |
- SNPrintF(buffer, "Compiling WASM function #%d:%s failed:", index, |
- module_env->module->GetName(function.name_offset)); |
+ SNPrintF(buffer, "Compiling %s failed:", buffer.start()); |
titzer
2016/01/26 15:42:31
This probably corrupts the buffer, since it uses t
Weiliang
2016/01/28 14:03:35
Done.
|
thrower.Failed(buffer.start(), result); |
return Handle<Code>::null(); |
} |
@@ -2074,24 +2069,23 @@ Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate, |
CallDescriptor* descriptor = const_cast<CallDescriptor*>( |
module_env->GetWasmCallDescriptor(&zone, function.sig)); |
Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION); |
- CompilationInfo info("wasm", isolate, &zone, flags); |
+ CompilationInfo info(buffer.start(), isolate, &zone, flags); |
Handle<Code> code = |
Pipeline::GenerateCodeForTesting(&info, descriptor, &graph); |
-#ifdef ENABLE_DISASSEMBLER |
- // Disassemble the code for debugging. |
- if (!code.is_null() && FLAG_print_opt_code) { |
- Vector<char> buffer; |
- const char* name = ""; |
- if (function.name_offset > 0) { |
- const byte* ptr = module_env->module->module_start + function.name_offset; |
- name = reinterpret_cast<const char*>(ptr); |
- } |
- SNPrintF(buffer, "WASM function #%d:%s", index, name); |
- OFStream os(stdout); |
- code->Disassemble(buffer.start(), os); |
+ if (info.isolate()->logger()->is_logging_code_events() || |
danno
2016/01/26 08:40:06
Could you please turn this combined test into a se
Weiliang
2016/01/28 14:03:35
Done.
|
+ info.isolate()->cpu_profiler()->is_profiling()) { |
+ 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(info.isolate(), CodeCreateEvent(Logger::FUNCTION_TAG, *code, |
+ *shared, &info, *script_str, 0, 0)); |
} |
-#endif |
+ |
+ |
return code; |
} |