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/api-natives.h" | 5 #include "src/api-natives.h" |
6 #include "src/api.h" | 6 #include "src/api.h" |
7 #include "src/assert-scope.h" | 7 #include "src/assert-scope.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 ffi = i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj)); | 185 ffi = i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj)); |
186 } | 186 } |
187 | 187 |
188 i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null(); | 188 i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null(); |
189 if (args.Length() > 2 && args[2]->IsArrayBuffer()) { | 189 if (args.Length() > 2 && args[2]->IsArrayBuffer()) { |
190 Local<Object> obj = Local<Object>::Cast(args[2]); | 190 Local<Object> obj = Local<Object>::Cast(args[2]); |
191 i::Handle<i::Object> mem_obj = v8::Utils::OpenHandle(*obj); | 191 i::Handle<i::Object> mem_obj = v8::Utils::OpenHandle(*obj); |
192 memory = i::Handle<i::JSArrayBuffer>(i::JSArrayBuffer::cast(*mem_obj)); | 192 memory = i::Handle<i::JSArrayBuffer>(i::JSArrayBuffer::cast(*mem_obj)); |
193 } | 193 } |
194 | 194 |
195 object = result.val->Instantiate(isolate, ffi, memory); | 195 i::MaybeHandle<i::FixedArray> compiled_module = |
196 if (!object.is_null()) { | 196 result.val->CompileFunctions(isolate); |
197 args.GetReturnValue().Set(v8::Utils::ToLocal(object.ToHandleChecked())); | 197 if (!compiled_module.is_null()) { |
| 198 object = i::wasm::WasmModule::Instantiate( |
| 199 isolate, compiled_module.ToHandleChecked(), ffi, memory); |
| 200 if (!object.is_null()) { |
| 201 args.GetReturnValue().Set(v8::Utils::ToLocal(object.ToHandleChecked())); |
| 202 } |
198 } | 203 } |
199 } | 204 } |
200 | 205 |
201 if (result.val) delete result.val; | 206 if (result.val) delete result.val; |
202 return object; | 207 return object; |
203 } | 208 } |
204 | 209 |
205 void InstantiateModuleFromAsm(const v8::FunctionCallbackInfo<v8::Value>& args) { | 210 void InstantiateModuleFromAsm(const v8::FunctionCallbackInfo<v8::Value>& args) { |
206 HandleScope scope(args.GetIsolate()); | 211 HandleScope scope(args.GetIsolate()); |
207 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); | 212 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 int unused_property_fields = in_object_properties - pre_allocated; | 492 int unused_property_fields = in_object_properties - pre_allocated; |
488 Handle<Map> map = Map::CopyInitialMap( | 493 Handle<Map> map = Map::CopyInitialMap( |
489 prev_map, instance_size, in_object_properties, unused_property_fields); | 494 prev_map, instance_size, in_object_properties, unused_property_fields); |
490 | 495 |
491 context->set_wasm_function_map(*map); | 496 context->set_wasm_function_map(*map); |
492 } | 497 } |
493 } | 498 } |
494 | 499 |
495 } // namespace internal | 500 } // namespace internal |
496 } // namespace v8 | 501 } // namespace v8 |
OLD | NEW |