| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/asmjs/asm-js.h" | 5 #include "src/asmjs/asm-js.h" |
| 6 | 6 |
| 7 #include "src/api-natives.h" | 7 #include "src/api-natives.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/asmjs/asm-typer.h" | 9 #include "src/asmjs/asm-typer.h" |
| 10 #include "src/asmjs/asm-wasm-builder.h" | 10 #include "src/asmjs/asm-wasm-builder.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 Vector<const byte> asm_offsets_vec(asm_offsets->begin(), | 184 Vector<const byte> asm_offsets_vec(asm_offsets->begin(), |
| 185 static_cast<int>(asm_offsets->size())); | 185 static_cast<int>(asm_offsets->size())); |
| 186 | 186 |
| 187 base::ElapsedTimer compile_timer; | 187 base::ElapsedTimer compile_timer; |
| 188 compile_timer.Start(); | 188 compile_timer.Start(); |
| 189 MaybeHandle<JSObject> compiled = wasm::CreateModuleObjectFromBytes( | 189 MaybeHandle<JSObject> compiled = wasm::CreateModuleObjectFromBytes( |
| 190 info->isolate(), module->begin(), module->end(), &thrower, | 190 info->isolate(), module->begin(), module->end(), &thrower, |
| 191 internal::wasm::kAsmJsOrigin, info->script(), asm_offsets_vec); | 191 internal::wasm::kAsmJsOrigin, info->script(), asm_offsets_vec); |
| 192 DCHECK(!compiled.is_null()); | 192 DCHECK(!compiled.is_null()); |
| 193 double compile_time = compile_timer.Elapsed().InMillisecondsF(); | 193 double compile_time = compile_timer.Elapsed().InMillisecondsF(); |
| 194 DCHECK_GE(module->end(), module->begin()); |
| 195 uintptr_t wasm_size = module->end() - module->begin(); |
| 194 | 196 |
| 195 wasm::AsmTyper::StdlibSet uses = builder.typer()->StdlibUses(); | 197 wasm::AsmTyper::StdlibSet uses = builder.typer()->StdlibUses(); |
| 196 Handle<FixedArray> uses_array = | 198 Handle<FixedArray> uses_array = |
| 197 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size())); | 199 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size())); |
| 198 int count = 0; | 200 int count = 0; |
| 199 for (auto i : uses) { | 201 for (auto i : uses) { |
| 200 uses_array->set(count++, Smi::FromInt(i)); | 202 uses_array->set(count++, Smi::FromInt(i)); |
| 201 } | 203 } |
| 202 | 204 |
| 203 Handle<FixedArray> result = | 205 Handle<FixedArray> result = |
| 204 info->isolate()->factory()->NewFixedArray(kWasmDataEntryCount); | 206 info->isolate()->factory()->NewFixedArray(kWasmDataEntryCount); |
| 205 result->set(kWasmDataCompiledModule, *compiled.ToHandleChecked()); | 207 result->set(kWasmDataCompiledModule, *compiled.ToHandleChecked()); |
| 206 result->set(kWasmDataForeignGlobals, *foreign_globals); | 208 result->set(kWasmDataForeignGlobals, *foreign_globals); |
| 207 result->set(kWasmDataUsesArray, *uses_array); | 209 result->set(kWasmDataUsesArray, *uses_array); |
| 208 result->set(kWasmDataScript, *info->script()); | 210 result->set(kWasmDataScript, *info->script()); |
| 209 result->set(kWasmDataScriptPosition, | 211 result->set(kWasmDataScriptPosition, |
| 210 Smi::FromInt(info->literal()->position())); | 212 Smi::FromInt(info->literal()->position())); |
| 211 | 213 |
| 212 MessageLocation location(info->script(), info->literal()->position(), | 214 MessageLocation location(info->script(), info->literal()->position(), |
| 213 info->literal()->position()); | 215 info->literal()->position()); |
| 214 char text[100]; | 216 char text[100]; |
| 215 int length; | 217 int length; |
| 216 if (FLAG_predictable) { | 218 if (FLAG_predictable) { |
| 217 length = base::OS::SNPrintF(text, arraysize(text), "success"); | 219 length = base::OS::SNPrintF(text, arraysize(text), "success"); |
| 218 } else { | 220 } else { |
| 219 length = | 221 length = base::OS::SNPrintF( |
| 220 base::OS::SNPrintF(text, arraysize(text), | 222 text, arraysize(text), |
| 221 "success, asm->wasm: %0.3f ms, compile: %0.3f ms", | 223 "success, asm->wasm: %0.3f ms, compile: %0.3f ms, %" PRIuPTR " bytes", |
| 222 asm_wasm_time, compile_time); | 224 asm_wasm_time, compile_time, wasm_size); |
| 223 } | 225 } |
| 224 DCHECK_NE(-1, length); | 226 DCHECK_NE(-1, length); |
| 225 USE(length); | 227 USE(length); |
| 226 Handle<String> stext(info->isolate()->factory()->InternalizeUtf8String(text)); | 228 Handle<String> stext(info->isolate()->factory()->InternalizeUtf8String(text)); |
| 227 Handle<JSMessageObject> message = MessageHandler::MakeMessageObject( | 229 Handle<JSMessageObject> message = MessageHandler::MakeMessageObject( |
| 228 info->isolate(), MessageTemplate::kAsmJsCompiled, &location, stext, | 230 info->isolate(), MessageTemplate::kAsmJsCompiled, &location, stext, |
| 229 Handle<JSArray>::null()); | 231 Handle<JSArray>::null()); |
| 230 message->set_error_level(v8::Isolate::kMessageInfo); | 232 message->set_error_level(v8::Isolate::kMessageInfo); |
| 231 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) { | 233 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) { |
| 232 MessageHandler::ReportMessage(info->isolate(), &location, message); | 234 MessageHandler::ReportMessage(info->isolate(), &location, message); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 message->set_error_level(v8::Isolate::kMessageInfo); | 345 message->set_error_level(v8::Isolate::kMessageInfo); |
| 344 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) { | 346 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) { |
| 345 MessageHandler::ReportMessage(isolate, &location, message); | 347 MessageHandler::ReportMessage(isolate, &location, message); |
| 346 } | 348 } |
| 347 | 349 |
| 348 return module_object; | 350 return module_object; |
| 349 } | 351 } |
| 350 | 352 |
| 351 } // namespace internal | 353 } // namespace internal |
| 352 } // namespace v8 | 354 } // namespace v8 |
| OLD | NEW |