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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 ffi = i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj)); | 190 ffi = i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj)); |
191 } | 191 } |
192 | 192 |
193 i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null(); | 193 i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null(); |
194 if (args.Length() > 2 && args[2]->IsArrayBuffer()) { | 194 if (args.Length() > 2 && args[2]->IsArrayBuffer()) { |
195 Local<Object> obj = Local<Object>::Cast(args[2]); | 195 Local<Object> obj = Local<Object>::Cast(args[2]); |
196 i::Handle<i::Object> mem_obj = v8::Utils::OpenHandle(*obj); | 196 i::Handle<i::Object> mem_obj = v8::Utils::OpenHandle(*obj); |
197 memory = i::Handle<i::JSArrayBuffer>(i::JSArrayBuffer::cast(*mem_obj)); | 197 memory = i::Handle<i::JSArrayBuffer>(i::JSArrayBuffer::cast(*mem_obj)); |
198 } | 198 } |
199 | 199 |
200 object = result.val->Instantiate(isolate, ffi, memory); | 200 i::MaybeHandle<i::FixedArray> compiled_module = |
201 if (!object.is_null()) { | 201 result.val->CompileFunctions(isolate); |
202 args.GetReturnValue().Set(v8::Utils::ToLocal(object.ToHandleChecked())); | 202 if (!compiled_module.is_null()) { |
| 203 object = i::wasm::WasmModule::Instantiate( |
| 204 isolate, compiled_module.ToHandleChecked(), ffi, memory); |
| 205 if (!object.is_null()) { |
| 206 args.GetReturnValue().Set(v8::Utils::ToLocal(object.ToHandleChecked())); |
| 207 } |
203 } | 208 } |
204 } | 209 } |
205 | 210 |
206 if (result.val) delete result.val; | 211 if (result.val) delete result.val; |
207 return object; | 212 return object; |
208 } | 213 } |
209 | 214 |
210 void InstantiateModuleFromAsm(const v8::FunctionCallbackInfo<v8::Value>& args) { | 215 void InstantiateModuleFromAsm(const v8::FunctionCallbackInfo<v8::Value>& args) { |
211 HandleScope scope(args.GetIsolate()); | 216 HandleScope scope(args.GetIsolate()); |
212 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); | 217 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 int unused_property_fields = in_object_properties - pre_allocated; | 497 int unused_property_fields = in_object_properties - pre_allocated; |
493 Handle<Map> map = Map::CopyInitialMap( | 498 Handle<Map> map = Map::CopyInitialMap( |
494 prev_map, instance_size, in_object_properties, unused_property_fields); | 499 prev_map, instance_size, in_object_properties, unused_property_fields); |
495 | 500 |
496 context->set_wasm_function_map(*map); | 501 context->set_wasm_function_map(*map); |
497 } | 502 } |
498 } | 503 } |
499 | 504 |
500 } // namespace internal | 505 } // namespace internal |
501 } // namespace v8 | 506 } // namespace v8 |
OLD | NEW |