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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 181 } |
182 double asm_wasm_time = asm_wasm_timer.Elapsed().InMillisecondsF(); | 182 double asm_wasm_time = asm_wasm_timer.Elapsed().InMillisecondsF(); |
183 | 183 |
184 wasm::ZoneBuffer* module = asm_wasm_result.module_bytes; | 184 wasm::ZoneBuffer* module = asm_wasm_result.module_bytes; |
185 wasm::ZoneBuffer* asm_offsets = asm_wasm_result.asm_offset_table; | 185 wasm::ZoneBuffer* asm_offsets = asm_wasm_result.asm_offset_table; |
186 Vector<const byte> asm_offsets_vec(asm_offsets->begin(), | 186 Vector<const byte> asm_offsets_vec(asm_offsets->begin(), |
187 static_cast<int>(asm_offsets->size())); | 187 static_cast<int>(asm_offsets->size())); |
188 | 188 |
189 base::ElapsedTimer compile_timer; | 189 base::ElapsedTimer compile_timer; |
190 compile_timer.Start(); | 190 compile_timer.Start(); |
191 MaybeHandle<JSObject> compiled = wasm::CreateModuleObjectFromBytes( | 191 MaybeHandle<JSObject> compiled = SyncCompileTranslatedAsmJs( |
192 info->isolate(), module->begin(), module->end(), &thrower, | 192 info->isolate(), &thrower, |
193 internal::wasm::kAsmJsOrigin, info->script(), asm_offsets_vec); | 193 wasm::ModuleWireBytes(module->begin(), module->end()), info->script(), |
| 194 asm_offsets_vec); |
194 DCHECK(!compiled.is_null()); | 195 DCHECK(!compiled.is_null()); |
195 double compile_time = compile_timer.Elapsed().InMillisecondsF(); | 196 double compile_time = compile_timer.Elapsed().InMillisecondsF(); |
196 DCHECK_GE(module->end(), module->begin()); | 197 DCHECK_GE(module->end(), module->begin()); |
197 uintptr_t wasm_size = module->end() - module->begin(); | 198 uintptr_t wasm_size = module->end() - module->begin(); |
198 | 199 |
199 wasm::AsmTyper::StdlibSet uses = builder.typer()->StdlibUses(); | 200 wasm::AsmTyper::StdlibSet uses = builder.typer()->StdlibUses(); |
200 Handle<FixedArray> uses_array = | 201 Handle<FixedArray> uses_array = |
201 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size())); | 202 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size())); |
202 int count = 0; | 203 int count = 0; |
203 for (auto i : uses) { | 204 for (auto i : uses) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 Handle<JSObject> ffi_object; | 270 Handle<JSObject> ffi_object; |
270 if (!foreign.is_null()) { | 271 if (!foreign.is_null()) { |
271 Handle<JSFunction> object_function = Handle<JSFunction>( | 272 Handle<JSFunction> object_function = Handle<JSFunction>( |
272 isolate->native_context()->object_function(), isolate); | 273 isolate->native_context()->object_function(), isolate); |
273 ffi_object = isolate->factory()->NewJSObject(object_function); | 274 ffi_object = isolate->factory()->NewJSObject(object_function); |
274 JSObject::AddProperty(ffi_object, isolate->factory()->empty_string(), | 275 JSObject::AddProperty(ffi_object, isolate->factory()->empty_string(), |
275 foreign, NONE); | 276 foreign, NONE); |
276 } | 277 } |
277 | 278 |
278 i::MaybeHandle<i::Object> maybe_module_object = | 279 i::MaybeHandle<i::Object> maybe_module_object = |
279 i::wasm::WasmModule::Instantiate(isolate, &thrower, module, ffi_object, | 280 i::wasm::SyncInstantiate(isolate, &thrower, module, ffi_object, memory); |
280 memory); | |
281 if (maybe_module_object.is_null()) { | 281 if (maybe_module_object.is_null()) { |
282 return MaybeHandle<Object>(); | 282 return MaybeHandle<Object>(); |
283 } | 283 } |
284 i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked(); | 284 i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked(); |
285 | 285 |
286 i::Handle<i::Name> init_name(isolate->factory()->InternalizeUtf8String( | 286 i::Handle<i::Name> init_name(isolate->factory()->InternalizeUtf8String( |
287 wasm::AsmWasmBuilder::foreign_init_name)); | 287 wasm::AsmWasmBuilder::foreign_init_name)); |
288 i::Handle<i::Object> init = | 288 i::Handle<i::Object> init = |
289 i::Object::GetProperty(module_object, init_name).ToHandleChecked(); | 289 i::Object::GetProperty(module_object, init_name).ToHandleChecked(); |
290 | 290 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 MessageHandler::ReportMessage(isolate, &location, message); | 346 MessageHandler::ReportMessage(isolate, &location, message); |
347 } | 347 } |
348 | 348 |
349 Handle<String> exports_name = | 349 Handle<String> exports_name = |
350 isolate->factory()->InternalizeUtf8String("exports"); | 350 isolate->factory()->InternalizeUtf8String("exports"); |
351 return i::Object::GetProperty(module_object, exports_name); | 351 return i::Object::GetProperty(module_object, exports_name); |
352 } | 352 } |
353 | 353 |
354 } // namespace internal | 354 } // namespace internal |
355 } // namespace v8 | 355 } // namespace v8 |
OLD | NEW |