| 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 #ifndef WASM_RUN_UTILS_H | 5 #ifndef WASM_RUN_UTILS_H |
| 6 #define WASM_RUN_UTILS_H | 6 #define WASM_RUN_UTILS_H |
| 7 | 7 |
| 8 #include <setjmp.h> | 8 #include <setjmp.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // The lifetime of the wasm module is tied to this object's, and we cannot | 352 // The lifetime of the wasm module is tied to this object's, and we cannot |
| 353 // rely on the mechanics of Managed<T>. | 353 // rely on the mechanics of Managed<T>. |
| 354 Handle<Foreign> module_wrapper = | 354 Handle<Foreign> module_wrapper = |
| 355 isolate_->factory()->NewForeign(reinterpret_cast<Address>(&module)); | 355 isolate_->factory()->NewForeign(reinterpret_cast<Address>(&module)); |
| 356 Handle<Script> script = | 356 Handle<Script> script = |
| 357 isolate_->factory()->NewScript(isolate_->factory()->empty_string()); | 357 isolate_->factory()->NewScript(isolate_->factory()->empty_string()); |
| 358 script->set_type(Script::TYPE_WASM); | 358 script->set_type(Script::TYPE_WASM); |
| 359 Handle<WasmSharedModuleData> shared_module_data = | 359 Handle<WasmSharedModuleData> shared_module_data = |
| 360 WasmSharedModuleData::New(isolate_, module_wrapper, empty_string, | 360 WasmSharedModuleData::New(isolate_, module_wrapper, empty_string, |
| 361 script, Handle<ByteArray>::null()); | 361 script, Handle<ByteArray>::null()); |
| 362 Handle<WasmCompiledModule> compiled_module = | |
| 363 WasmCompiledModule::New(isolate_, shared_module_data); | |
| 364 // Minimally initialize the compiled module such that IsWasmCompiledModule | |
| 365 // passes. | |
| 366 // If tests need more (correct) information, add it later. | |
| 367 compiled_module->set_min_mem_pages(0); | |
| 368 compiled_module->set_max_mem_pages(Smi::kMaxValue); | |
| 369 Handle<FixedArray> code_table = isolate_->factory()->NewFixedArray(0); | 362 Handle<FixedArray> code_table = isolate_->factory()->NewFixedArray(0); |
| 370 compiled_module->set_code_table(code_table); | 363 |
| 364 Handle<WasmCompiledModule> compiled_module = WasmCompiledModule::New( |
| 365 isolate_, shared_module_data, code_table, MaybeHandle<FixedArray>(), |
| 366 MaybeHandle<FixedArray>()); |
| 371 Handle<FixedArray> weak_exported = isolate_->factory()->NewFixedArray(0); | 367 Handle<FixedArray> weak_exported = isolate_->factory()->NewFixedArray(0); |
| 372 compiled_module->set_weak_exported_functions(weak_exported); | 368 compiled_module->set_weak_exported_functions(weak_exported); |
| 373 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); | 369 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); |
| 374 return WasmInstanceObject::New(isolate_, compiled_module); | 370 return WasmInstanceObject::New(isolate_, compiled_module); |
| 375 } | 371 } |
| 376 }; | 372 }; |
| 377 | 373 |
| 378 inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, ModuleEnv* module, | 374 inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, ModuleEnv* module, |
| 379 FunctionSig* sig, | 375 FunctionSig* sig, |
| 380 SourcePositionTable* source_position_table, | 376 SourcePositionTable* source_position_table, |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 | 576 |
| 581 // Add to code table. | 577 // Add to code table. |
| 582 Handle<WasmCompiledModule> compiled_module( | 578 Handle<WasmCompiledModule> compiled_module( |
| 583 testing_module_->instance_object()->compiled_module(), isolate()); | 579 testing_module_->instance_object()->compiled_module(), isolate()); |
| 584 Handle<FixedArray> code_table = compiled_module->code_table(); | 580 Handle<FixedArray> code_table = compiled_module->code_table(); |
| 585 if (static_cast<int>(function_index()) >= code_table->length()) { | 581 if (static_cast<int>(function_index()) >= code_table->length()) { |
| 586 Handle<FixedArray> new_arr = isolate()->factory()->NewFixedArray( | 582 Handle<FixedArray> new_arr = isolate()->factory()->NewFixedArray( |
| 587 static_cast<int>(function_index()) + 1); | 583 static_cast<int>(function_index()) + 1); |
| 588 code_table->CopyTo(0, *new_arr, 0, code_table->length()); | 584 code_table->CopyTo(0, *new_arr, 0, code_table->length()); |
| 589 code_table = new_arr; | 585 code_table = new_arr; |
| 590 compiled_module->set_code_table(code_table); | 586 compiled_module->ReplaceCodeTableForTesting(code_table); |
| 591 } | 587 } |
| 592 DCHECK(code_table->get(static_cast<int>(function_index())) | 588 DCHECK(code_table->get(static_cast<int>(function_index())) |
| 593 ->IsUndefined(isolate())); | 589 ->IsUndefined(isolate())); |
| 594 code_table->set(static_cast<int>(function_index()), *code); | 590 code_table->set(static_cast<int>(function_index()), *code); |
| 595 if (trap_handler::UseTrapHandler()) { | 591 if (trap_handler::UseTrapHandler()) { |
| 596 UnpackAndRegisterProtectedInstructions(isolate(), code_table); | 592 UnpackAndRegisterProtectedInstructions(isolate(), code_table); |
| 597 } | 593 } |
| 598 } | 594 } |
| 599 | 595 |
| 600 byte AllocateLocal(ValueType type) { | 596 byte AllocateLocal(ValueType type) { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 void RunWasm_##name(WasmExecutionMode execution_mode) | 858 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 863 | 859 |
| 864 #define WASM_EXEC_COMPILED_TEST(name) \ | 860 #define WASM_EXEC_COMPILED_TEST(name) \ |
| 865 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 861 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
| 866 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 862 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
| 867 void RunWasm_##name(WasmExecutionMode execution_mode) | 863 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 868 | 864 |
| 869 } // namespace | 865 } // namespace |
| 870 | 866 |
| 871 #endif | 867 #endif |
| OLD | NEW |