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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include "src/wasm/encoder.h" | 8 #include "src/wasm/encoder.h" |
9 #include "src/wasm/module-decoder.h" | 9 #include "src/wasm/module-decoder.h" |
10 #include "src/wasm/wasm-js.h" | 10 #include "src/wasm/wasm-js.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 HandleScope scope(isolate); | 208 HandleScope scope(isolate); |
209 | 209 |
210 ModuleResult decoding_result = DecodeWasmModule( | 210 ModuleResult decoding_result = DecodeWasmModule( |
211 isolate, &zone, buffer.begin(), buffer.end(), false, kWasmOrigin); | 211 isolate, &zone, buffer.begin(), buffer.end(), false, kWasmOrigin); |
212 std::unique_ptr<const WasmModule> module(decoding_result.val); | 212 std::unique_ptr<const WasmModule> module(decoding_result.val); |
213 CHECK(!decoding_result.failed()); | 213 CHECK(!decoding_result.failed()); |
214 | 214 |
215 MaybeHandle<FixedArray> compiled_module = | 215 MaybeHandle<FixedArray> compiled_module = |
216 module->CompileFunctions(isolate, &thrower); | 216 module->CompileFunctions(isolate, &thrower); |
217 CHECK(!compiled_module.is_null()); | 217 CHECK(!compiled_module.is_null()); |
218 Handle<JSObject> module_obj = | 218 Handle<JSObject> module_obj = CreateCompiledModuleObject( |
219 CreateCompiledModuleObject(isolate, compiled_module.ToHandleChecked()); | 219 isolate, compiled_module.ToHandleChecked(), ModuleOrigin::kWasmOrigin); |
220 v8::Local<v8::Object> v8_module_obj = v8::Utils::ToLocal(module_obj); | 220 v8::Local<v8::Object> v8_module_obj = v8::Utils::ToLocal(module_obj); |
221 CHECK(v8_module_obj->IsWebAssemblyCompiledModule()); | 221 CHECK(v8_module_obj->IsWebAssemblyCompiledModule()); |
222 | 222 |
223 v8::Local<v8::WasmCompiledModule> v8_compiled_module = | 223 v8::Local<v8::WasmCompiledModule> v8_compiled_module = |
224 v8_module_obj.As<v8::WasmCompiledModule>(); | 224 v8_module_obj.As<v8::WasmCompiledModule>(); |
225 data = v8_compiled_module->Serialize(); | 225 data = v8_compiled_module->Serialize(); |
226 } | 226 } |
227 | 227 |
228 v8::Isolate::CreateParams create_params; | 228 v8::Isolate::CreateParams create_params; |
229 create_params.array_buffer_allocator = isolate->array_buffer_allocator(); | 229 create_params.array_buffer_allocator = isolate->array_buffer_allocator(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); | 264 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); |
265 uint16_t f_index = builder->AddFunction(); | 265 uint16_t f_index = builder->AddFunction(); |
266 WasmFunctionBuilder* f = builder->FunctionAt(f_index); | 266 WasmFunctionBuilder* f = builder->FunctionAt(f_index); |
267 f->SetSignature(sigs.i_v()); | 267 f->SetSignature(sigs.i_v()); |
268 ExportAsMain(f); | 268 ExportAsMain(f); |
269 byte code[] = {WASM_IF_ELSE(WASM_I32V(0), WASM_GROW_MEMORY(WASM_I32V(1)), | 269 byte code[] = {WASM_IF_ELSE(WASM_I32V(0), WASM_GROW_MEMORY(WASM_I32V(1)), |
270 WASM_I32V(12))}; | 270 WASM_I32V(12))}; |
271 f->EmitCode(code, sizeof(code)); | 271 f->EmitCode(code, sizeof(code)); |
272 TestModule(&zone, builder, 12); | 272 TestModule(&zone, builder, 12); |
273 } | 273 } |
OLD | NEW |