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 "src/macro-assembler.h" | 5 #include "src/macro-assembler.h" |
6 #include "src/objects.h" | 6 #include "src/objects.h" |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/simulator.h" | 9 #include "src/simulator.h" |
10 | 10 |
11 #include "src/wasm/ast-decoder.h" | 11 #include "src/wasm/ast-decoder.h" |
12 #include "src/wasm/module-decoder.h" | 12 #include "src/wasm/module-decoder.h" |
13 #include "src/wasm/wasm-module.h" | 13 #include "src/wasm/wasm-module.h" |
14 #include "src/wasm/wasm-result.h" | 14 #include "src/wasm/wasm-result.h" |
15 | 15 |
16 #include "src/compiler/wasm-compiler.h" | 16 #include "src/compiler/wasm-compiler.h" |
17 | 17 |
18 namespace v8 { | 18 namespace v8 { |
19 namespace internal { | 19 namespace internal { |
20 namespace wasm { | 20 namespace wasm { |
21 | 21 |
| 22 static const char* wasmSections[] = { |
| 23 #define F(enumerator, string) string, |
| 24 FOR_EACH_WASM_SECTION_TYPE(F) |
| 25 #undef F |
| 26 }; |
| 27 |
| 28 static uint8_t wasmSectionsLengths[]{ |
| 29 #define F(enumerator, string) sizeof(string) - 1, |
| 30 FOR_EACH_WASM_SECTION_TYPE(F) |
| 31 #undef F |
| 32 }; |
| 33 |
| 34 static_assert(sizeof(wasmSections) / sizeof(wasmSections[0]) == |
| 35 (size_t)WasmSection::Code::Max, |
| 36 "expected enum WasmSection::Code to be monotonic from 0"); |
| 37 |
| 38 WasmSection::Code WasmSection::begin() { return (WasmSection::Code)0; } |
| 39 WasmSection::Code WasmSection::end() { return WasmSection::Code::Max; } |
| 40 WasmSection::Code WasmSection::next(WasmSection::Code code) { |
| 41 return (WasmSection::Code)(1 + (uint32_t)code); |
| 42 } |
| 43 |
| 44 const char* WasmSection::getName(WasmSection::Code code) { |
| 45 return wasmSections[(size_t)code]; |
| 46 } |
| 47 |
| 48 size_t WasmSection::getNameLength(WasmSection::Code code) { |
| 49 return wasmSectionsLengths[(size_t)code]; |
| 50 } |
| 51 |
22 std::ostream& operator<<(std::ostream& os, const WasmModule& module) { | 52 std::ostream& operator<<(std::ostream& os, const WasmModule& module) { |
23 os << "WASM module with "; | 53 os << "WASM module with "; |
24 os << (module.min_mem_pages * module.kPageSize) << " min mem"; | 54 os << (module.min_mem_pages * module.kPageSize) << " min mem"; |
25 os << (module.max_mem_pages * module.kPageSize) << " max mem"; | 55 os << (module.max_mem_pages * module.kPageSize) << " max mem"; |
26 os << module.functions.size() << " functions"; | 56 os << module.functions.size() << " functions"; |
27 os << module.functions.size() << " globals"; | 57 os << module.functions.size() << " globals"; |
28 os << module.functions.size() << " data segments"; | 58 os << module.functions.size() << " data segments"; |
29 return os; | 59 return os; |
30 } | 60 } |
31 | 61 |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 } | 688 } |
659 if (result->IsHeapNumber()) { | 689 if (result->IsHeapNumber()) { |
660 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); | 690 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); |
661 } | 691 } |
662 thrower.Error("WASM.compileRun() failed: Return value should be number"); | 692 thrower.Error("WASM.compileRun() failed: Return value should be number"); |
663 return -1; | 693 return -1; |
664 } | 694 } |
665 } // namespace wasm | 695 } // namespace wasm |
666 } // namespace internal | 696 } // namespace internal |
667 } // namespace v8 | 697 } // namespace v8 |
OLD | NEW |