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