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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 result->set(kWasmDataCompiledModule, *compiled.ToHandleChecked()); | 205 result->set(kWasmDataCompiledModule, *compiled.ToHandleChecked()); |
206 result->set(kWasmDataForeignGlobals, *foreign_globals); | 206 result->set(kWasmDataForeignGlobals, *foreign_globals); |
207 result->set(kWasmDataUsesArray, *uses_array); | 207 result->set(kWasmDataUsesArray, *uses_array); |
208 result->set(kWasmDataScript, *info->script()); | 208 result->set(kWasmDataScript, *info->script()); |
209 result->set(kWasmDataScriptPosition, | 209 result->set(kWasmDataScriptPosition, |
210 Smi::FromInt(info->literal()->position())); | 210 Smi::FromInt(info->literal()->position())); |
211 | 211 |
212 MessageLocation location(info->script(), info->literal()->position(), | 212 MessageLocation location(info->script(), info->literal()->position(), |
213 info->literal()->position()); | 213 info->literal()->position()); |
214 char text[100]; | 214 char text[100]; |
215 int length; | 215 int length = base::OS::SNPrintF( |
216 if (FLAG_trace_asm_time) { | 216 text, arraysize(text), "success, asm->wasm: %0.3f ms, compile: %0.3f ms", |
217 length = | 217 asm_wasm_time, compile_time); |
218 base::OS::SNPrintF(text, arraysize(text), | |
219 "success, asm->wasm: %0.3f ms, compile: %0.3f ms", | |
220 asm_wasm_time, compile_time); | |
221 } else { | |
222 length = base::OS::SNPrintF(text, arraysize(text), "success"); | |
223 } | |
224 DCHECK_NE(-1, length); | 218 DCHECK_NE(-1, length); |
225 USE(length); | 219 USE(length); |
226 Handle<String> stext(info->isolate()->factory()->InternalizeUtf8String(text)); | 220 Handle<String> stext(info->isolate()->factory()->InternalizeUtf8String(text)); |
227 Handle<JSMessageObject> message = MessageHandler::MakeMessageObject( | 221 Handle<JSMessageObject> message = MessageHandler::MakeMessageObject( |
228 info->isolate(), MessageTemplate::kAsmJsCompiled, &location, stext, | 222 info->isolate(), MessageTemplate::kAsmJsCompiled, &location, stext, |
229 Handle<JSArray>::null()); | 223 Handle<JSArray>::null()); |
230 message->set_error_level(v8::Isolate::kMessageInfo); | 224 message->set_error_level(v8::Isolate::kMessageInfo); |
231 if (!FLAG_suppress_asm_messages) { | 225 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) { |
232 MessageHandler::ReportMessage(info->isolate(), &location, message); | 226 MessageHandler::ReportMessage(info->isolate(), &location, message); |
233 } | 227 } |
234 | 228 |
235 return result; | 229 return result; |
236 } | 230 } |
237 | 231 |
238 bool AsmJs::IsStdlibValid(i::Isolate* isolate, Handle<FixedArray> wasm_data, | 232 bool AsmJs::IsStdlibValid(i::Isolate* isolate, Handle<FixedArray> wasm_data, |
239 Handle<JSReceiver> stdlib) { | 233 Handle<JSReceiver> stdlib) { |
240 i::Handle<i::FixedArray> uses( | 234 i::Handle<i::FixedArray> uses( |
241 i::FixedArray::cast(wasm_data->get(kWasmDataUsesArray))); | 235 i::FixedArray::cast(wasm_data->get(kWasmDataUsesArray))); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 return single_function; | 314 return single_function; |
321 } | 315 } |
322 | 316 |
323 i::Handle<i::Script> script(i::Script::cast(wasm_data->get(kWasmDataScript))); | 317 i::Handle<i::Script> script(i::Script::cast(wasm_data->get(kWasmDataScript))); |
324 int32_t position = 0; | 318 int32_t position = 0; |
325 if (!wasm_data->get(kWasmDataScriptPosition)->ToInt32(&position)) { | 319 if (!wasm_data->get(kWasmDataScriptPosition)->ToInt32(&position)) { |
326 UNREACHABLE(); | 320 UNREACHABLE(); |
327 } | 321 } |
328 MessageLocation location(script, position, position); | 322 MessageLocation location(script, position, position); |
329 char text[50]; | 323 char text[50]; |
330 int length; | 324 int length = |
331 if (FLAG_trace_asm_time) { | 325 base::OS::SNPrintF(text, arraysize(text), "success, %0.3f ms", |
332 length = base::OS::SNPrintF(text, arraysize(text), "success, %0.3f ms", | 326 instantiate_timer.Elapsed().InMillisecondsF()); |
333 instantiate_timer.Elapsed().InMillisecondsF()); | |
334 } else { | |
335 length = base::OS::SNPrintF(text, arraysize(text), "success"); | |
336 } | |
337 DCHECK_NE(-1, length); | 327 DCHECK_NE(-1, length); |
338 USE(length); | 328 USE(length); |
339 Handle<String> stext(isolate->factory()->InternalizeUtf8String(text)); | 329 Handle<String> stext(isolate->factory()->InternalizeUtf8String(text)); |
340 Handle<JSMessageObject> message = MessageHandler::MakeMessageObject( | 330 Handle<JSMessageObject> message = MessageHandler::MakeMessageObject( |
341 isolate, MessageTemplate::kAsmJsInstantiated, &location, stext, | 331 isolate, MessageTemplate::kAsmJsInstantiated, &location, stext, |
342 Handle<JSArray>::null()); | 332 Handle<JSArray>::null()); |
343 message->set_error_level(v8::Isolate::kMessageInfo); | 333 message->set_error_level(v8::Isolate::kMessageInfo); |
344 MessageHandler::ReportMessage(isolate, &location, message); | 334 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) { |
| 335 MessageHandler::ReportMessage(isolate, &location, message); |
| 336 } |
345 | 337 |
346 return module_object; | 338 return module_object; |
347 } | 339 } |
348 | 340 |
349 } // namespace internal | 341 } // namespace internal |
350 } // namespace v8 | 342 } // namespace v8 |
OLD | NEW |