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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "src/base/atomic-utils.h" | 7 #include "src/base/atomic-utils.h" |
| 8 #include "src/code-stubs.h" |
| 9 |
8 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
9 #include "src/objects.h" | 11 #include "src/objects.h" |
10 #include "src/property-descriptor.h" | 12 #include "src/property-descriptor.h" |
| 13 #include "src/simulator.h" |
| 14 #include "src/snapshot/snapshot.h" |
11 #include "src/v8.h" | 15 #include "src/v8.h" |
12 | 16 |
13 #include "src/simulator.h" | |
14 | |
15 #include "src/wasm/ast-decoder.h" | 17 #include "src/wasm/ast-decoder.h" |
16 #include "src/wasm/module-decoder.h" | 18 #include "src/wasm/module-decoder.h" |
17 #include "src/wasm/wasm-debug.h" | 19 #include "src/wasm/wasm-debug.h" |
18 #include "src/wasm/wasm-function-name-table.h" | 20 #include "src/wasm/wasm-function-name-table.h" |
19 #include "src/wasm/wasm-module.h" | 21 #include "src/wasm/wasm-module.h" |
20 #include "src/wasm/wasm-result.h" | 22 #include "src/wasm/wasm-result.h" |
21 | 23 |
22 #include "src/compiler/wasm-compiler.h" | 24 #include "src/compiler/wasm-compiler.h" |
23 | 25 |
24 namespace v8 { | 26 namespace v8 { |
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 table->set(static_cast<int>(i), *(*code_table)[index]); | 1566 table->set(static_cast<int>(i), *(*code_table)[index]); |
1565 } | 1567 } |
1566 } | 1568 } |
1567 | 1569 |
1568 int GetNumberOfFunctions(JSObject* wasm) { | 1570 int GetNumberOfFunctions(JSObject* wasm) { |
1569 Object* func_names_obj = wasm->GetInternalField(kWasmFunctionNamesArray); | 1571 Object* func_names_obj = wasm->GetInternalField(kWasmFunctionNamesArray); |
1570 // TODO(clemensh): this looks inside an array constructed elsewhere. Refactor. | 1572 // TODO(clemensh): this looks inside an array constructed elsewhere. Refactor. |
1571 return ByteArray::cast(func_names_obj)->get_int(0); | 1573 return ByteArray::cast(func_names_obj)->get_int(0); |
1572 } | 1574 } |
1573 | 1575 |
| 1576 Handle<JSObject> CreateCompiledModuleObject( |
| 1577 Isolate* isolate, Handle<FixedArray> compiled_module) { |
| 1578 Handle<JSFunction> module_cons( |
| 1579 isolate->native_context()->wasm_module_constructor()); |
| 1580 Handle<JSObject> module_obj = isolate->factory()->NewJSObject(module_cons); |
| 1581 module_obj->SetInternalField(0, *compiled_module); |
| 1582 Handle<Symbol> module_sym(isolate->native_context()->wasm_module_sym()); |
| 1583 Object::SetProperty(module_obj, module_sym, module_obj, STRICT).Check(); |
| 1584 return module_obj; |
| 1585 } |
| 1586 |
1574 namespace testing { | 1587 namespace testing { |
1575 | 1588 |
1576 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, | 1589 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, |
1577 const byte* module_end, bool asm_js) { | 1590 const byte* module_end, bool asm_js) { |
1578 HandleScope scope(isolate); | 1591 HandleScope scope(isolate); |
1579 Zone zone(isolate->allocator()); | 1592 Zone zone(isolate->allocator()); |
1580 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); | 1593 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); |
1581 | 1594 |
1582 // Decode the module, but don't verify function bodies, since we'll | 1595 // Decode the module, but don't verify function bodies, since we'll |
1583 // be compiling them anyway. | 1596 // be compiling them anyway. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); | 1653 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); |
1641 } | 1654 } |
1642 thrower.Error("WASM.compileRun() failed: Return value should be number"); | 1655 thrower.Error("WASM.compileRun() failed: Return value should be number"); |
1643 return -1; | 1656 return -1; |
1644 } | 1657 } |
1645 | 1658 |
1646 } // namespace testing | 1659 } // namespace testing |
1647 } // namespace wasm | 1660 } // namespace wasm |
1648 } // namespace internal | 1661 } // namespace internal |
1649 } // namespace v8 | 1662 } // namespace v8 |
OLD | NEW |