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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 194 } |
195 } | 195 } |
196 return true; | 196 return true; |
197 } | 197 } |
198 | 198 |
199 MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate, | 199 MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate, |
200 Handle<FixedArray> wasm_data, | 200 Handle<FixedArray> wasm_data, |
201 Handle<JSArrayBuffer> memory, | 201 Handle<JSArrayBuffer> memory, |
202 Handle<JSReceiver> foreign) { | 202 Handle<JSReceiver> foreign) { |
203 i::Handle<i::JSObject> module(i::JSObject::cast(wasm_data->get(0))); | 203 i::Handle<i::JSObject> module(i::JSObject::cast(wasm_data->get(0))); |
204 i::Handle<i::FixedArray> compiled( | |
205 i::FixedArray::cast(module->GetInternalField(0))); | |
206 i::Handle<i::FixedArray> foreign_globals( | 204 i::Handle<i::FixedArray> foreign_globals( |
207 i::FixedArray::cast(wasm_data->get(1))); | 205 i::FixedArray::cast(wasm_data->get(1))); |
208 | 206 |
209 ErrorThrower thrower(isolate, "Asm.js -> WebAssembly instantiation"); | 207 ErrorThrower thrower(isolate, "Asm.js -> WebAssembly instantiation"); |
210 | 208 |
211 i::MaybeHandle<i::JSObject> maybe_module_object = | 209 i::MaybeHandle<i::JSObject> maybe_module_object = |
212 i::wasm::WasmModule::Instantiate(isolate, compiled, foreign, memory); | 210 i::wasm::WasmModule::Instantiate(isolate, module, foreign, memory); |
213 if (maybe_module_object.is_null()) { | 211 if (maybe_module_object.is_null()) { |
214 return MaybeHandle<Object>(); | 212 return MaybeHandle<Object>(); |
215 } | 213 } |
216 | 214 |
217 i::Handle<i::Name> name(isolate->factory()->InternalizeOneByteString( | 215 i::Handle<i::Name> name(isolate->factory()->InternalizeOneByteString( |
218 STATIC_CHAR_VECTOR("__foreign_init__"))); | 216 STATIC_CHAR_VECTOR("__foreign_init__"))); |
219 | 217 |
220 i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked(); | 218 i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked(); |
221 i::MaybeHandle<i::Object> maybe_init = | 219 i::MaybeHandle<i::Object> maybe_init = |
222 i::Object::GetProperty(module_object, name); | 220 i::Object::GetProperty(module_object, name); |
(...skipping 22 matching lines...) Expand all Loading... |
245 isolate, init, undefined, foreign_globals->length(), foreign_args_array); | 243 isolate, init, undefined, foreign_globals->length(), foreign_args_array); |
246 delete[] foreign_args_array; | 244 delete[] foreign_args_array; |
247 | 245 |
248 DCHECK(!retval.is_null()); | 246 DCHECK(!retval.is_null()); |
249 | 247 |
250 return maybe_module_object; | 248 return maybe_module_object; |
251 } | 249 } |
252 | 250 |
253 } // namespace internal | 251 } // namespace internal |
254 } // namespace v8 | 252 } // namespace v8 |
OLD | NEW |