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/zone-containers.h" | 10 #include "src/zone/zone-containers.h" |
(...skipping 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 node = nullptr; | 1777 node = nullptr; |
1778 break; | 1778 break; |
1779 } | 1779 } |
1780 Push(GetReturnType(sig), node); | 1780 Push(GetReturnType(sig), node); |
1781 } | 1781 } |
1782 }; | 1782 }; |
1783 | 1783 |
1784 bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start, | 1784 bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start, |
1785 const byte* end) { | 1785 const byte* end) { |
1786 AccountingAllocator allocator; | 1786 AccountingAllocator allocator; |
1787 Zone tmp(&allocator); | 1787 Zone tmp(&allocator, ZONE_NAME); |
1788 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 1788 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
1789 WasmFullDecoder decoder(&tmp, nullptr, body); | 1789 WasmFullDecoder decoder(&tmp, nullptr, body); |
1790 return decoder.DecodeLocalDecls(decls); | 1790 return decoder.DecodeLocalDecls(decls); |
1791 } | 1791 } |
1792 | 1792 |
1793 BytecodeIterator::BytecodeIterator(const byte* start, const byte* end, | 1793 BytecodeIterator::BytecodeIterator(const byte* start, const byte* end, |
1794 AstLocalDecls* decls) | 1794 AstLocalDecls* decls) |
1795 : Decoder(start, end) { | 1795 : Decoder(start, end) { |
1796 if (decls != nullptr) { | 1796 if (decls != nullptr) { |
1797 if (DecodeLocalDecls(*decls, start, end)) { | 1797 if (DecodeLocalDecls(*decls, start, end)) { |
1798 pc_ += decls->decls_encoded_size; | 1798 pc_ += decls->decls_encoded_size; |
1799 if (pc_ > end_) pc_ = end_; | 1799 if (pc_ > end_) pc_ = end_; |
1800 } | 1800 } |
1801 } | 1801 } |
1802 } | 1802 } |
1803 | 1803 |
1804 DecodeResult VerifyWasmCode(AccountingAllocator* allocator, | 1804 DecodeResult VerifyWasmCode(AccountingAllocator* allocator, |
1805 FunctionBody& body) { | 1805 FunctionBody& body) { |
1806 Zone zone(allocator); | 1806 Zone zone(allocator, ZONE_NAME); |
1807 WasmFullDecoder decoder(&zone, nullptr, body); | 1807 WasmFullDecoder decoder(&zone, nullptr, body); |
1808 decoder.Decode(); | 1808 decoder.Decode(); |
1809 return decoder.toResult<DecodeStruct*>(nullptr); | 1809 return decoder.toResult<DecodeStruct*>(nullptr); |
1810 } | 1810 } |
1811 | 1811 |
1812 DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder, | 1812 DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder, |
1813 FunctionBody& body) { | 1813 FunctionBody& body) { |
1814 Zone zone(allocator); | 1814 Zone zone(allocator, ZONE_NAME); |
1815 WasmFullDecoder decoder(&zone, builder, body); | 1815 WasmFullDecoder decoder(&zone, builder, body); |
1816 decoder.Decode(); | 1816 decoder.Decode(); |
1817 return decoder.toResult<DecodeStruct*>(nullptr); | 1817 return decoder.toResult<DecodeStruct*>(nullptr); |
1818 } | 1818 } |
1819 | 1819 |
1820 unsigned OpcodeLength(const byte* pc, const byte* end) { | 1820 unsigned OpcodeLength(const byte* pc, const byte* end) { |
1821 WasmDecoder decoder(nullptr, nullptr, pc, end); | 1821 WasmDecoder decoder(nullptr, nullptr, pc, end); |
1822 return decoder.OpcodeLength(pc); | 1822 return decoder.OpcodeLength(pc); |
1823 } | 1823 } |
1824 | 1824 |
1825 void PrintAstForDebugging(const byte* start, const byte* end) { | 1825 void PrintAstForDebugging(const byte* start, const byte* end) { |
1826 AccountingAllocator allocator; | 1826 AccountingAllocator allocator; |
1827 OFStream os(stdout); | 1827 OFStream os(stdout); |
1828 PrintAst(&allocator, FunctionBodyForTesting(start, end), os, nullptr); | 1828 PrintAst(&allocator, FunctionBodyForTesting(start, end), os, nullptr); |
1829 } | 1829 } |
1830 | 1830 |
1831 bool PrintAst(AccountingAllocator* allocator, const FunctionBody& body, | 1831 bool PrintAst(AccountingAllocator* allocator, const FunctionBody& body, |
1832 std::ostream& os, | 1832 std::ostream& os, |
1833 std::vector<std::tuple<uint32_t, int, int>>* offset_table) { | 1833 std::vector<std::tuple<uint32_t, int, int>>* offset_table) { |
1834 Zone zone(allocator); | 1834 Zone zone(allocator, ZONE_NAME); |
1835 WasmFullDecoder decoder(&zone, nullptr, body); | 1835 WasmFullDecoder decoder(&zone, nullptr, body); |
1836 int line_nr = 0; | 1836 int line_nr = 0; |
1837 | 1837 |
1838 // Print the function signature. | 1838 // Print the function signature. |
1839 if (body.sig) { | 1839 if (body.sig) { |
1840 os << "// signature: " << *body.sig << std::endl; | 1840 os << "// signature: " << *body.sig << std::endl; |
1841 ++line_nr; | 1841 ++line_nr; |
1842 } | 1842 } |
1843 | 1843 |
1844 // Print the local declarations. | 1844 // Print the local declarations. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1951 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 1951 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
1952 const byte* start, const byte* end) { | 1952 const byte* start, const byte* end) { |
1953 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 1953 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
1954 WasmFullDecoder decoder(zone, nullptr, body); | 1954 WasmFullDecoder decoder(zone, nullptr, body); |
1955 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 1955 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
1956 } | 1956 } |
1957 | 1957 |
1958 } // namespace wasm | 1958 } // namespace wasm |
1959 } // namespace internal | 1959 } // namespace internal |
1960 } // namespace v8 | 1960 } // namespace v8 |
OLD | NEW |