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

Unified Diff: src/asmjs/asm-js.cc

Issue 2577453003: [wasm][asm.js] Adding timing info message about asm.js (Closed)
Patch Set: fix Created 4 years 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/asmjs/asm-js.h ('k') | src/compiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/asmjs/asm-js.cc
diff --git a/src/asmjs/asm-js.cc b/src/asmjs/asm-js.cc
index af27beef9a2c354d9311127e1076ad6c0119a803..a30ac674233fa8ec8ed4bb56c3af6c5c75bed4c4 100644
--- a/src/asmjs/asm-js.cc
+++ b/src/asmjs/asm-js.cc
@@ -31,6 +31,15 @@ namespace v8 {
namespace internal {
namespace {
+enum WasmDataEntries {
+ kWasmDataCompiledModule,
+ kWasmDataForeignGlobals,
+ kWasmDataUsesArray,
+ kWasmDataScript,
+ kWasmDataScriptPosition,
+ kWasmDataEntryCount,
+};
+
Handle<i::Object> StdlibMathMember(i::Isolate* isolate,
Handle<JSReceiver> stdlib,
Handle<Name> name) {
@@ -151,8 +160,10 @@ bool IsStdlibMemberValid(i::Isolate* isolate, Handle<JSReceiver> stdlib,
} // namespace
-MaybeHandle<FixedArray> AsmJs::ConvertAsmToWasm(ParseInfo* info) {
+MaybeHandle<FixedArray> AsmJs::CompileAsmViaWasm(ParseInfo* info) {
ErrorThrower thrower(info->isolate(), "Asm.js -> WebAssembly conversion");
+ base::ElapsedTimer asm_wasm_timer;
+ asm_wasm_timer.Start();
wasm::AsmWasmBuilder builder(info->isolate(), info->zone(),
info->ast_value_factory(), info->script(),
info->literal());
@@ -165,14 +176,19 @@ MaybeHandle<FixedArray> AsmJs::ConvertAsmToWasm(ParseInfo* info) {
builder.typer()->error_message());
return MaybeHandle<FixedArray>();
}
+ double asm_wasm_time = asm_wasm_timer.Elapsed().InMillisecondsF();
+
wasm::ZoneBuffer* module = asm_wasm_result.module_bytes;
wasm::ZoneBuffer* asm_offsets = asm_wasm_result.asm_offset_table;
+ base::ElapsedTimer compile_timer;
+ compile_timer.Start();
MaybeHandle<JSObject> compiled = wasm::CreateModuleObjectFromBytes(
info->isolate(), module->begin(), module->end(), &thrower,
internal::wasm::kAsmJsOrigin, info->script(), asm_offsets->begin(),
asm_offsets->end());
DCHECK(!compiled.is_null());
+ double compile_time = compile_timer.Elapsed().InMillisecondsF();
wasm::AsmTyper::StdlibSet uses = builder.typer()->StdlibUses();
Handle<FixedArray> uses_array =
@@ -182,16 +198,37 @@ MaybeHandle<FixedArray> AsmJs::ConvertAsmToWasm(ParseInfo* info) {
uses_array->set(count++, Smi::FromInt(i));
}
- Handle<FixedArray> result = info->isolate()->factory()->NewFixedArray(3);
- result->set(0, *compiled.ToHandleChecked());
- result->set(1, *foreign_globals);
- result->set(2, *uses_array);
+ Handle<FixedArray> result =
+ info->isolate()->factory()->NewFixedArray(kWasmDataEntryCount);
+ result->set(kWasmDataCompiledModule, *compiled.ToHandleChecked());
+ result->set(kWasmDataForeignGlobals, *foreign_globals);
+ result->set(kWasmDataUsesArray, *uses_array);
+ result->set(kWasmDataScript, *info->script());
+ result->set(kWasmDataScriptPosition,
+ Smi::FromInt(info->literal()->position()));
+
+ MessageLocation location(info->script(), info->literal()->position(),
+ info->literal()->position());
+ char text[100];
+ int length = base::OS::SNPrintF(text, arraysize(text),
+ "asm->wasm: %0.3f ms, compile: %0.3f ms",
+ asm_wasm_time, compile_time);
+ DCHECK_NE(-1, length);
+ USE(length);
+ Handle<String> stext(info->isolate()->factory()->InternalizeUtf8String(text));
+ Handle<JSMessageObject> message = MessageHandler::MakeMessageObject(
+ info->isolate(), MessageTemplate::kAsmJsCompiled, &location, stext,
+ Handle<JSArray>::null());
+ message->set_error_level(v8::Isolate::kMessageInfo);
+ MessageHandler::ReportMessage(info->isolate(), &location, message);
+
return result;
}
bool AsmJs::IsStdlibValid(i::Isolate* isolate, Handle<FixedArray> wasm_data,
Handle<JSReceiver> stdlib) {
- i::Handle<i::FixedArray> uses(i::FixedArray::cast(wasm_data->get(2)));
+ i::Handle<i::FixedArray> uses(
+ i::FixedArray::cast(wasm_data->get(kWasmDataUsesArray)));
for (int i = 0; i < uses->length(); ++i) {
if (!IsStdlibMemberValid(isolate, stdlib,
uses->GetValueChecked<i::Object>(isolate, i))) {
@@ -205,9 +242,12 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate,
Handle<FixedArray> wasm_data,
Handle<JSArrayBuffer> memory,
Handle<JSReceiver> foreign) {
- i::Handle<i::JSObject> module(i::JSObject::cast(wasm_data->get(0)));
+ base::ElapsedTimer instantiate_timer;
+ instantiate_timer.Start();
+ i::Handle<i::JSObject> module(
+ i::JSObject::cast(wasm_data->get(kWasmDataCompiledModule)));
i::Handle<i::FixedArray> foreign_globals(
- i::FixedArray::cast(wasm_data->get(1)));
+ i::FixedArray::cast(wasm_data->get(kWasmDataForeignGlobals)));
ErrorThrower thrower(isolate, "Asm.js -> WebAssembly instantiation");
@@ -259,6 +299,26 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate,
!single_function.ToHandleChecked()->IsUndefined(isolate)) {
return single_function;
}
+
+ i::Handle<i::Script> script(i::Script::cast(wasm_data->get(kWasmDataScript)));
+ int32_t position = 0;
+ if (!wasm_data->get(kWasmDataScriptPosition)->ToInt32(&position)) {
+ UNREACHABLE();
+ }
+ MessageLocation location(script, position, position);
+ char text[50];
+ int length =
+ base::OS::SNPrintF(text, arraysize(text), "%0.3f ms",
+ instantiate_timer.Elapsed().InMillisecondsF());
+ DCHECK_NE(-1, length);
+ USE(length);
+ Handle<String> stext(isolate->factory()->InternalizeUtf8String(text));
+ Handle<JSMessageObject> message = MessageHandler::MakeMessageObject(
+ isolate, MessageTemplate::kAsmJsInstantiated, &location, stext,
+ Handle<JSArray>::null());
+ message->set_error_level(v8::Isolate::kMessageInfo);
+ MessageHandler::ReportMessage(isolate, &location, message);
+
return module_object;
}
« no previous file with comments | « src/asmjs/asm-js.h ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698