| 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 #ifndef V8_WASM_AST_DECODER_H_ | 5 #ifndef V8_WASM_AST_DECODER_H_ |
| 6 #define V8_WASM_AST_DECODER_H_ | 6 #define V8_WASM_AST_DECODER_H_ |
| 7 | 7 |
| 8 #include "src/signature.h" | 8 #include "src/signature.h" |
| 9 #include "src/wasm/decoder.h" | 9 #include "src/wasm/decoder.h" |
| 10 #include "src/wasm/wasm-opcodes.h" | 10 #include "src/wasm/wasm-opcodes.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 const byte* base; // base of the module bytes, for error reporting | 187 const byte* base; // base of the module bytes, for error reporting |
| 188 const byte* start; // start of the function body | 188 const byte* start; // start of the function body |
| 189 const byte* end; // end of the function body | 189 const byte* end; // end of the function body |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 struct Tree; | 192 struct Tree; |
| 193 typedef Result<Tree*> TreeResult; | 193 typedef Result<Tree*> TreeResult; |
| 194 | 194 |
| 195 std::ostream& operator<<(std::ostream& os, const Tree& tree); | 195 std::ostream& operator<<(std::ostream& os, const Tree& tree); |
| 196 | 196 |
| 197 TreeResult VerifyWasmCode(FunctionBody& body); | 197 TreeResult VerifyWasmCode(base::AccountingAllocator* allocator, |
| 198 TreeResult BuildTFGraph(TFBuilder* builder, FunctionBody& body); | 198 FunctionBody& body); |
| 199 void PrintAst(FunctionBody& body); | 199 TreeResult BuildTFGraph(base::AccountingAllocator* allocator, |
| 200 TFBuilder* builder, FunctionBody& body); |
| 201 void PrintAst(base::AccountingAllocator* allocator, FunctionBody& body); |
| 200 | 202 |
| 201 inline TreeResult VerifyWasmCode(ModuleEnv* module, FunctionSig* sig, | 203 inline TreeResult VerifyWasmCode(base::AccountingAllocator* allocator, |
| 204 ModuleEnv* module, FunctionSig* sig, |
| 202 const byte* start, const byte* end) { | 205 const byte* start, const byte* end) { |
| 203 FunctionBody body = {module, sig, nullptr, start, end}; | 206 FunctionBody body = {module, sig, nullptr, start, end}; |
| 204 return VerifyWasmCode(body); | 207 return VerifyWasmCode(allocator, body); |
| 205 } | 208 } |
| 206 | 209 |
| 207 inline TreeResult BuildTFGraph(TFBuilder* builder, ModuleEnv* module, | 210 inline TreeResult BuildTFGraph(base::AccountingAllocator* allocator, |
| 211 TFBuilder* builder, ModuleEnv* module, |
| 208 FunctionSig* sig, const byte* start, | 212 FunctionSig* sig, const byte* start, |
| 209 const byte* end) { | 213 const byte* end) { |
| 210 FunctionBody body = {module, sig, nullptr, start, end}; | 214 FunctionBody body = {module, sig, nullptr, start, end}; |
| 211 return BuildTFGraph(builder, body); | 215 return BuildTFGraph(allocator, builder, body); |
| 212 } | 216 } |
| 213 | 217 |
| 214 enum ReadUnsignedLEB128ErrorCode { kNoError, kInvalidLEB128, kMissingLEB128 }; | 218 enum ReadUnsignedLEB128ErrorCode { kNoError, kInvalidLEB128, kMissingLEB128 }; |
| 215 | 219 |
| 216 ReadUnsignedLEB128ErrorCode ReadUnsignedLEB128Operand(const byte*, const byte*, | 220 ReadUnsignedLEB128ErrorCode ReadUnsignedLEB128Operand(const byte*, const byte*, |
| 217 int*, uint32_t*); | 221 int*, uint32_t*); |
| 218 | 222 |
| 219 std::vector<LocalType>* DecodeLocalDeclsForTesting(const byte* start, | 223 std::vector<LocalType>* DecodeLocalDeclsForTesting( |
| 220 const byte* end); | 224 base::AccountingAllocator* allocator, const byte* start, const byte* end); |
| 221 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 225 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
| 222 const byte* start, const byte* end); | 226 const byte* start, const byte* end); |
| 223 | 227 |
| 224 // Computes the length of the opcode at the given address. | 228 // Computes the length of the opcode at the given address. |
| 225 int OpcodeLength(const byte* pc, const byte* end); | 229 int OpcodeLength(const byte* pc, const byte* end); |
| 226 | 230 |
| 227 // Computes the arity (number of sub-nodes) of the opcode at the given address. | 231 // Computes the arity (number of sub-nodes) of the opcode at the given address. |
| 228 int OpcodeArity(ModuleEnv* module, FunctionSig* sig, const byte* pc, | 232 int OpcodeArity(ModuleEnv* module, FunctionSig* sig, const byte* pc, |
| 229 const byte* end); | 233 const byte* end); |
| 230 } // namespace wasm | 234 } // namespace wasm |
| 231 } // namespace internal | 235 } // namespace internal |
| 232 } // namespace v8 | 236 } // namespace v8 |
| 233 | 237 |
| 234 #endif // V8_WASM_AST_DECODER_H_ | 238 #endif // V8_WASM_AST_DECODER_H_ |
| OLD | NEW |