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