| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 return true; | 165 return true; |
| 166 } | 166 } |
| 167 | 167 |
| 168 MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate, | 168 MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate, |
| 169 Handle<FixedArray> wasm_data, | 169 Handle<FixedArray> wasm_data, |
| 170 Handle<JSArrayBuffer> memory, | 170 Handle<JSArrayBuffer> memory, |
| 171 Handle<JSReceiver> foreign) { | 171 Handle<JSReceiver> foreign) { |
| 172 i::Handle<i::FixedArray> compiled(i::FixedArray::cast(wasm_data->get(0))); | 172 i::Handle<i::FixedArray> compiled(i::FixedArray::cast(wasm_data->get(0))); |
| 173 i::Handle<i::FixedArray> foreign_globals( | 173 i::Handle<i::FixedArray> foreign_globals( |
| 174 i::FixedArray::cast(wasm_data->get(1))); | 174 i::FixedArray::cast(wasm_data->get(1))); |
| 175 i::Handle<i::Context> context(isolate->context()); |
| 175 | 176 |
| 176 ErrorThrower thrower(isolate, "Asm.js -> WebAssembly instantiation"); | 177 ErrorThrower thrower(isolate, "Asm.js -> WebAssembly instantiation"); |
| 177 | 178 |
| 178 i::MaybeHandle<i::JSObject> maybe_module_object = | 179 i::MaybeHandle<i::JSObject> maybe_module_object = |
| 179 i::wasm::WasmModule::Instantiate(isolate, compiled, foreign, memory); | 180 i::wasm::WasmModule::Instantiate(isolate, context, compiled, foreign, |
| 181 memory); |
| 180 if (maybe_module_object.is_null()) { | 182 if (maybe_module_object.is_null()) { |
| 181 return MaybeHandle<Object>(); | 183 return MaybeHandle<Object>(); |
| 182 } | 184 } |
| 183 | 185 |
| 184 i::Handle<i::Name> name(isolate->factory()->InternalizeOneByteString( | 186 i::Handle<i::Name> name(isolate->factory()->InternalizeOneByteString( |
| 185 STATIC_CHAR_VECTOR("__foreign_init__"))); | 187 STATIC_CHAR_VECTOR("__foreign_init__"))); |
| 186 | 188 |
| 187 i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked(); | 189 i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked(); |
| 188 i::MaybeHandle<i::Object> maybe_init = | 190 i::MaybeHandle<i::Object> maybe_init = |
| 189 i::Object::GetProperty(module_object, name); | 191 i::Object::GetProperty(module_object, name); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 215 if (retval.is_null()) { | 217 if (retval.is_null()) { |
| 216 thrower.Error( | 218 thrower.Error( |
| 217 "WASM.instantiateModuleFromAsm(): foreign init function failed"); | 219 "WASM.instantiateModuleFromAsm(): foreign init function failed"); |
| 218 return MaybeHandle<Object>(); | 220 return MaybeHandle<Object>(); |
| 219 } | 221 } |
| 220 return maybe_module_object; | 222 return maybe_module_object; |
| 221 } | 223 } |
| 222 | 224 |
| 223 } // namespace internal | 225 } // namespace internal |
| 224 } // namespace v8 | 226 } // namespace v8 |
| OLD | NEW |