OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/compiler/wasm-compiler.h" | 9 #include "src/compiler/wasm-compiler.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // Get mem buffer associated with module object | 145 // Get mem buffer associated with module object |
146 Handle<Object> obj(module_object->GetInternalField(kWasmMemArrayBuffer), | 146 Handle<Object> obj(module_object->GetInternalField(kWasmMemArrayBuffer), |
147 isolate); | 147 isolate); |
148 | 148 |
149 if (obj->IsUndefined(isolate)) { | 149 if (obj->IsUndefined(isolate)) { |
150 return isolate->heap()->undefined_value(); | 150 return isolate->heap()->undefined_value(); |
151 } | 151 } |
152 | 152 |
153 Handle<JSArrayBuffer> mem_buffer = Handle<JSArrayBuffer>::cast(obj); | 153 Handle<JSArrayBuffer> mem_buffer = Handle<JSArrayBuffer>::cast(obj); |
154 | 154 |
| 155 wasm::ErrorThrower thrower(isolate, "JITSingleFunction"); |
155 wasm::WasmModule module(reinterpret_cast<byte*>(mem_buffer->backing_store())); | 156 wasm::WasmModule module(reinterpret_cast<byte*>(mem_buffer->backing_store())); |
156 wasm::ErrorThrower thrower(isolate, "JITSingleFunction"); | 157 wasm::WasmModuleInstance instance(&module); |
| 158 instance.context = isolate->native_context(); |
| 159 instance.mem_size = |
| 160 static_cast<uint32_t>(mem_buffer->byte_length()->Number()); |
| 161 instance.mem_start = reinterpret_cast<byte*>(mem_buffer->backing_store()); |
| 162 instance.globals_start = nullptr; |
| 163 |
157 wasm::ModuleEnv module_env; | 164 wasm::ModuleEnv module_env; |
158 module_env.module = &module; | 165 module_env.module = &module; |
159 module_env.instance = nullptr; | 166 module_env.instance = &instance; |
160 module_env.origin = wasm::kWasmOrigin; | 167 module_env.origin = wasm::kWasmOrigin; |
161 | 168 |
162 uint32_t signature_size = args.length() - fixed_args; | 169 uint32_t signature_size = args.length() - fixed_args; |
163 wasm::LocalType* sig_types = new wasm::LocalType[signature_size]; | 170 wasm::LocalType* sig_types = new wasm::LocalType[signature_size]; |
164 | 171 |
165 for (uint32_t i = 0; i < signature_size; ++i) { | 172 for (uint32_t i = 0; i < signature_size; ++i) { |
166 CONVERT_SMI_ARG_CHECKED(sig_type, i + fixed_args); | 173 CONVERT_SMI_ARG_CHECKED(sig_type, i + fixed_args); |
167 sig_types[i] = static_cast<wasm::LocalType>(sig_type); | 174 sig_types[i] = static_cast<wasm::LocalType>(sig_type); |
168 } | 175 } |
169 wasm::FunctionSig sig(return_count, signature_size - return_count, sig_types); | 176 wasm::FunctionSig sig(return_count, signature_size - return_count, sig_types); |
(...skipping 15 matching lines...) Expand all Loading... |
185 return isolate->heap()->undefined_value(); | 192 return isolate->heap()->undefined_value(); |
186 } | 193 } |
187 | 194 |
188 function_table->set(index, Smi::FromInt(sig_index)); | 195 function_table->set(index, Smi::FromInt(sig_index)); |
189 function_table->set(index + function_table->length() / 2, *code); | 196 function_table->set(index + function_table->length() / 2, *code); |
190 | 197 |
191 return isolate->heap()->undefined_value(); | 198 return isolate->heap()->undefined_value(); |
192 } | 199 } |
193 } // namespace internal | 200 } // namespace internal |
194 } // namespace v8 | 201 } // namespace v8 |
OLD | NEW |