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