| 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/signature.h" | 5 #include "src/signature.h" |
| 6 | 6 |
| 7 #include "src/bit-vector.h" | 7 #include "src/bit-vector.h" |
| 8 #include "src/flags.h" | 8 #include "src/flags.h" |
| 9 #include "src/handles.h" | 9 #include "src/handles.h" |
| 10 #include "src/zone-containers.h" | 10 #include "src/zone/zone-containers.h" |
| 11 | 11 |
| 12 #include "src/wasm/ast-decoder.h" | 12 #include "src/wasm/ast-decoder.h" |
| 13 #include "src/wasm/decoder.h" | 13 #include "src/wasm/decoder.h" |
| 14 #include "src/wasm/wasm-module.h" | 14 #include "src/wasm/wasm-module.h" |
| 15 #include "src/wasm/wasm-opcodes.h" | 15 #include "src/wasm/wasm-opcodes.h" |
| 16 | 16 |
| 17 #include "src/ostreams.h" | 17 #include "src/ostreams.h" |
| 18 | 18 |
| 19 #include "src/compiler/wasm-compiler.h" | 19 #include "src/compiler/wasm-compiler.h" |
| 20 | 20 |
| (...skipping 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 UNREACHABLE(); | 1642 UNREACHABLE(); |
| 1643 node = nullptr; | 1643 node = nullptr; |
| 1644 break; | 1644 break; |
| 1645 } | 1645 } |
| 1646 Push(GetReturnType(sig), node); | 1646 Push(GetReturnType(sig), node); |
| 1647 } | 1647 } |
| 1648 }; | 1648 }; |
| 1649 | 1649 |
| 1650 bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start, | 1650 bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start, |
| 1651 const byte* end) { | 1651 const byte* end) { |
| 1652 base::AccountingAllocator allocator; | 1652 AccountingAllocator allocator; |
| 1653 Zone tmp(&allocator); | 1653 Zone tmp(&allocator); |
| 1654 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 1654 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
| 1655 WasmFullDecoder decoder(&tmp, nullptr, body); | 1655 WasmFullDecoder decoder(&tmp, nullptr, body); |
| 1656 return decoder.DecodeLocalDecls(decls); | 1656 return decoder.DecodeLocalDecls(decls); |
| 1657 } | 1657 } |
| 1658 | 1658 |
| 1659 BytecodeIterator::BytecodeIterator(const byte* start, const byte* end, | 1659 BytecodeIterator::BytecodeIterator(const byte* start, const byte* end, |
| 1660 AstLocalDecls* decls) | 1660 AstLocalDecls* decls) |
| 1661 : Decoder(start, end) { | 1661 : Decoder(start, end) { |
| 1662 if (decls != nullptr) { | 1662 if (decls != nullptr) { |
| 1663 if (DecodeLocalDecls(*decls, start, end)) { | 1663 if (DecodeLocalDecls(*decls, start, end)) { |
| 1664 pc_ += decls->decls_encoded_size; | 1664 pc_ += decls->decls_encoded_size; |
| 1665 if (pc_ > end_) pc_ = end_; | 1665 if (pc_ > end_) pc_ = end_; |
| 1666 } | 1666 } |
| 1667 } | 1667 } |
| 1668 } | 1668 } |
| 1669 | 1669 |
| 1670 DecodeResult VerifyWasmCode(base::AccountingAllocator* allocator, | 1670 DecodeResult VerifyWasmCode(AccountingAllocator* allocator, |
| 1671 FunctionBody& body) { | 1671 FunctionBody& body) { |
| 1672 Zone zone(allocator); | 1672 Zone zone(allocator); |
| 1673 WasmFullDecoder decoder(&zone, nullptr, body); | 1673 WasmFullDecoder decoder(&zone, nullptr, body); |
| 1674 decoder.Decode(); | 1674 decoder.Decode(); |
| 1675 return decoder.toResult<DecodeStruct*>(nullptr); | 1675 return decoder.toResult<DecodeStruct*>(nullptr); |
| 1676 } | 1676 } |
| 1677 | 1677 |
| 1678 DecodeResult BuildTFGraph(base::AccountingAllocator* allocator, | 1678 DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder, |
| 1679 TFBuilder* builder, FunctionBody& body) { | 1679 FunctionBody& body) { |
| 1680 Zone zone(allocator); | 1680 Zone zone(allocator); |
| 1681 WasmFullDecoder decoder(&zone, builder, body); | 1681 WasmFullDecoder decoder(&zone, builder, body); |
| 1682 decoder.Decode(); | 1682 decoder.Decode(); |
| 1683 return decoder.toResult<DecodeStruct*>(nullptr); | 1683 return decoder.toResult<DecodeStruct*>(nullptr); |
| 1684 } | 1684 } |
| 1685 | 1685 |
| 1686 unsigned OpcodeLength(const byte* pc, const byte* end) { | 1686 unsigned OpcodeLength(const byte* pc, const byte* end) { |
| 1687 WasmDecoder decoder(nullptr, nullptr, pc, end); | 1687 WasmDecoder decoder(nullptr, nullptr, pc, end); |
| 1688 return decoder.OpcodeLength(pc); | 1688 return decoder.OpcodeLength(pc); |
| 1689 } | 1689 } |
| 1690 | 1690 |
| 1691 unsigned OpcodeArity(const byte* pc, const byte* end) { | 1691 unsigned OpcodeArity(const byte* pc, const byte* end) { |
| 1692 WasmDecoder decoder(nullptr, nullptr, pc, end); | 1692 WasmDecoder decoder(nullptr, nullptr, pc, end); |
| 1693 return decoder.OpcodeArity(pc); | 1693 return decoder.OpcodeArity(pc); |
| 1694 } | 1694 } |
| 1695 | 1695 |
| 1696 void PrintAstForDebugging(const byte* start, const byte* end) { | 1696 void PrintAstForDebugging(const byte* start, const byte* end) { |
| 1697 base::AccountingAllocator allocator; | 1697 AccountingAllocator allocator; |
| 1698 OFStream os(stdout); | 1698 OFStream os(stdout); |
| 1699 PrintAst(&allocator, FunctionBodyForTesting(start, end), os, nullptr); | 1699 PrintAst(&allocator, FunctionBodyForTesting(start, end), os, nullptr); |
| 1700 } | 1700 } |
| 1701 | 1701 |
| 1702 bool PrintAst(base::AccountingAllocator* allocator, const FunctionBody& body, | 1702 bool PrintAst(AccountingAllocator* allocator, const FunctionBody& body, |
| 1703 std::ostream& os, | 1703 std::ostream& os, |
| 1704 std::vector<std::tuple<uint32_t, int, int>>* offset_table) { | 1704 std::vector<std::tuple<uint32_t, int, int>>* offset_table) { |
| 1705 Zone zone(allocator); | 1705 Zone zone(allocator); |
| 1706 WasmFullDecoder decoder(&zone, nullptr, body); | 1706 WasmFullDecoder decoder(&zone, nullptr, body); |
| 1707 int line_nr = 0; | 1707 int line_nr = 0; |
| 1708 | 1708 |
| 1709 // Print the function signature. | 1709 // Print the function signature. |
| 1710 if (body.sig) { | 1710 if (body.sig) { |
| 1711 os << "// signature: " << *body.sig << std::endl; | 1711 os << "// signature: " << *body.sig << std::endl; |
| 1712 ++line_nr; | 1712 ++line_nr; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 1831 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
| 1832 const byte* start, const byte* end) { | 1832 const byte* start, const byte* end) { |
| 1833 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 1833 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
| 1834 WasmFullDecoder decoder(zone, nullptr, body); | 1834 WasmFullDecoder decoder(zone, nullptr, body); |
| 1835 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 1835 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
| 1836 } | 1836 } |
| 1837 | 1837 |
| 1838 } // namespace wasm | 1838 } // namespace wasm |
| 1839 } // namespace internal | 1839 } // namespace internal |
| 1840 } // namespace v8 | 1840 } // namespace v8 |
| OLD | NEW |