Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: src/wasm/ast-decoder.cc

Issue 2110053002: [wasm] Cleanup AST decoder. Remove Tree and TreeResult. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/ast-decoder.h ('k') | src/wasm/module-decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/ast-decoder.cc
diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc
index a1416a97fea0fbf7908bc1c54a0236a50c5e5442..18e3b820a0555db800e0059b470671ffbe34ae25 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -31,17 +31,6 @@ namespace wasm {
#define TRACE(...)
#endif
-// The root of a decoded tree.
-struct Tree {
- LocalType type; // tree type.
- uint32_t count; // number of children.
- const byte* pc; // start of the syntax tree.
- TFNode* node; // node in the TurboFan graph.
- Tree* children[1]; // pointers to children.
-
- WasmOpcode opcode() const { return static_cast<WasmOpcode>(*pc); }
-};
-
// An SsaEnv environment carries the current local variable renaming
// as well as the current effect and control dependency in the TF graph.
// It maintains a control state that tracks whether the environment
@@ -409,11 +398,11 @@ class WasmDecoder : public Decoder {
}
};
-// A shift-reduce-parser strategy for decoding Wasm code that uses an explicit
-// shift-reduce strategy with multiple internal stacks.
-class SR_WasmDecoder : public WasmDecoder {
+// The full WASM decoder for bytecode. Both verifies bytecode and generates
+// a TurboFan IR graph.
+class WasmFullDecoder : public WasmDecoder {
public:
- SR_WasmDecoder(Zone* zone, TFBuilder* builder, const FunctionBody& body)
+ WasmFullDecoder(Zone* zone, TFBuilder* builder, const FunctionBody& body)
: WasmDecoder(body.module, body.sig, body.start, body.end),
zone_(zone),
builder_(builder),
@@ -1495,39 +1484,24 @@ bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start,
base::AccountingAllocator allocator;
Zone tmp(&allocator);
FunctionBody body = {nullptr, nullptr, nullptr, start, end};
- SR_WasmDecoder decoder(&tmp, nullptr, body);
+ WasmFullDecoder decoder(&tmp, nullptr, body);
return decoder.DecodeLocalDecls(decls);
}
-TreeResult VerifyWasmCode(base::AccountingAllocator* allocator,
- FunctionBody& body) {
+DecodeResult VerifyWasmCode(base::AccountingAllocator* allocator,
+ FunctionBody& body) {
Zone zone(allocator);
- SR_WasmDecoder decoder(&zone, nullptr, body);
+ WasmFullDecoder decoder(&zone, nullptr, body);
decoder.Decode();
- return decoder.toResult<Tree*>(nullptr);
+ return decoder.toResult<DecodeStruct*>(nullptr);
}
-TreeResult BuildTFGraph(base::AccountingAllocator* allocator,
- TFBuilder* builder, FunctionBody& body) {
+DecodeResult BuildTFGraph(base::AccountingAllocator* allocator,
+ TFBuilder* builder, FunctionBody& body) {
Zone zone(allocator);
- SR_WasmDecoder decoder(&zone, builder, body);
+ WasmFullDecoder decoder(&zone, builder, body);
decoder.Decode();
- return decoder.toResult<Tree*>(nullptr);
-}
-
-std::ostream& operator<<(std::ostream& os, const Tree& tree) {
- if (tree.pc == nullptr) {
- os << "null";
- return os;
- }
- PrintF("%s", WasmOpcodes::OpcodeName(tree.opcode()));
- if (tree.count > 0) os << "(";
- for (uint32_t i = 0; i < tree.count; ++i) {
- if (i > 0) os << ", ";
- os << *tree.children[i];
- }
- if (tree.count > 0) os << ")";
- return os;
+ return decoder.toResult<DecodeStruct*>(nullptr);
}
unsigned OpcodeLength(const byte* pc, const byte* end) {
@@ -1550,7 +1524,7 @@ bool PrintAst(base::AccountingAllocator* allocator, const FunctionBody& body,
std::ostream& os,
std::vector<std::tuple<uint32_t, int, int>>* offset_table) {
Zone zone(allocator);
- SR_WasmDecoder decoder(&zone, nullptr, body);
+ WasmFullDecoder decoder(&zone, nullptr, body);
int line_nr = 0;
// Print the function signature.
@@ -1679,7 +1653,7 @@ bool PrintAst(base::AccountingAllocator* allocator, const FunctionBody& body,
BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
const byte* start, const byte* end) {
FunctionBody body = {nullptr, nullptr, nullptr, start, end};
- SR_WasmDecoder decoder(zone, nullptr, body);
+ WasmFullDecoder decoder(zone, nullptr, body);
return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals);
}
« no previous file with comments | « src/wasm/ast-decoder.h ('k') | src/wasm/module-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698