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::WasmModule module(reinterpret_cast<byte*>(mem_buffer->backing_store())); |
155 wasm::ErrorThrower thrower(isolate, "JITSingleFunction"); | 156 wasm::ErrorThrower thrower(isolate, "JITSingleFunction"); |
156 wasm::WasmModule module(reinterpret_cast<byte*>(mem_buffer->backing_store())); | |
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 | |
164 wasm::ModuleEnv module_env; | 157 wasm::ModuleEnv module_env; |
165 module_env.module = &module; | 158 module_env.module = &module; |
166 module_env.instance = &instance; | 159 module_env.instance = nullptr; |
167 module_env.origin = wasm::kWasmOrigin; | 160 module_env.origin = wasm::kWasmOrigin; |
168 | 161 |
169 uint32_t signature_size = args.length() - fixed_args; | 162 uint32_t signature_size = args.length() - fixed_args; |
170 wasm::LocalType* sig_types = new wasm::LocalType[signature_size]; | 163 wasm::LocalType* sig_types = new wasm::LocalType[signature_size]; |
171 | 164 |
172 for (uint32_t i = 0; i < signature_size; ++i) { | 165 for (uint32_t i = 0; i < signature_size; ++i) { |
173 CONVERT_SMI_ARG_CHECKED(sig_type, i + fixed_args); | 166 CONVERT_SMI_ARG_CHECKED(sig_type, i + fixed_args); |
174 sig_types[i] = static_cast<wasm::LocalType>(sig_type); | 167 sig_types[i] = static_cast<wasm::LocalType>(sig_type); |
175 } | 168 } |
176 wasm::FunctionSig sig(return_count, signature_size - return_count, sig_types); | 169 wasm::FunctionSig sig(return_count, signature_size - return_count, sig_types); |
(...skipping 15 matching lines...) Expand all Loading... |
192 return isolate->heap()->undefined_value(); | 185 return isolate->heap()->undefined_value(); |
193 } | 186 } |
194 | 187 |
195 function_table->set(index, Smi::FromInt(sig_index)); | 188 function_table->set(index, Smi::FromInt(sig_index)); |
196 function_table->set(index + function_table->length() / 2, *code); | 189 function_table->set(index + function_table->length() / 2, *code); |
197 | 190 |
198 return isolate->heap()->undefined_value(); | 191 return isolate->heap()->undefined_value(); |
199 } | 192 } |
200 } // namespace internal | 193 } // namespace internal |
201 } // namespace v8 | 194 } // namespace v8 |
OLD | NEW |