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

Side by Side Diff: src/wasm/ast-decoder.h

Issue 1661713003: [wasm] Rename local_int32_count to local_i32_count and similar textual replacements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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/wasm-opcodes.h" 9 #include "src/wasm/wasm-opcodes.h"
10 #include "src/wasm/wasm-result.h" 10 #include "src/wasm/wasm-result.h"
(...skipping 10 matching lines...) Expand all
21 namespace wasm { 21 namespace wasm {
22 22
23 typedef compiler::WasmGraphBuilder TFBuilder; 23 typedef compiler::WasmGraphBuilder TFBuilder;
24 struct ModuleEnv; // forward declaration of module interface. 24 struct ModuleEnv; // forward declaration of module interface.
25 25
26 // Interface the function environment during decoding, include the signature 26 // Interface the function environment during decoding, include the signature
27 // and number of locals. 27 // and number of locals.
28 struct FunctionEnv { 28 struct FunctionEnv {
29 ModuleEnv* module; // module environment 29 ModuleEnv* module; // module environment
30 FunctionSig* sig; // signature of this function 30 FunctionSig* sig; // signature of this function
31 uint32_t local_int32_count; // number of int32 locals 31 uint32_t local_i32_count; // number of int32 locals
32 uint32_t local_int64_count; // number of int64 locals 32 uint32_t local_i64_count; // number of int64 locals
33 uint32_t local_float32_count; // number of float32 locals 33 uint32_t local_f32_count; // number of float32 locals
34 uint32_t local_float64_count; // number of float64 locals 34 uint32_t local_f64_count; // number of float64 locals
35 uint32_t total_locals; // sum of parameters and all locals 35 uint32_t total_locals; // sum of parameters and all locals
36 36
37 bool IsValidLocal(uint32_t index) { return index < total_locals; } 37 bool IsValidLocal(uint32_t index) { return index < total_locals; }
38 uint32_t GetLocalCount() { return total_locals; } 38 uint32_t GetLocalCount() { return total_locals; }
39 LocalType GetLocalType(uint32_t index) { 39 LocalType GetLocalType(uint32_t index) {
40 if (index < static_cast<uint32_t>(sig->parameter_count())) { 40 if (index < static_cast<uint32_t>(sig->parameter_count())) {
41 return sig->GetParam(index); 41 return sig->GetParam(index);
42 } 42 }
43 index -= static_cast<uint32_t>(sig->parameter_count()); 43 index -= static_cast<uint32_t>(sig->parameter_count());
44 if (index < local_int32_count) return kAstI32; 44 if (index < local_i32_count) return kAstI32;
45 index -= local_int32_count; 45 index -= local_i32_count;
46 if (index < local_int64_count) return kAstI64; 46 if (index < local_i64_count) return kAstI64;
47 index -= local_int64_count; 47 index -= local_i64_count;
48 if (index < local_float32_count) return kAstF32; 48 if (index < local_f32_count) return kAstF32;
49 index -= local_float32_count; 49 index -= local_f32_count;
50 if (index < local_float64_count) return kAstF64; 50 if (index < local_f64_count) return kAstF64;
51 return kAstStmt; 51 return kAstStmt;
52 } 52 }
53 53
54 void AddLocals(LocalType type, uint32_t count) { 54 void AddLocals(LocalType type, uint32_t count) {
55 switch (type) { 55 switch (type) {
56 case kAstI32: 56 case kAstI32:
57 local_int32_count += count; 57 local_i32_count += count;
58 break; 58 break;
59 case kAstI64: 59 case kAstI64:
60 local_int64_count += count; 60 local_i64_count += count;
61 break; 61 break;
62 case kAstF32: 62 case kAstF32:
63 local_float32_count += count; 63 local_f32_count += count;
64 break; 64 break;
65 case kAstF64: 65 case kAstF64:
66 local_float64_count += count; 66 local_f64_count += count;
67 break; 67 break;
68 default: 68 default:
69 UNREACHABLE(); 69 UNREACHABLE();
70 } 70 }
71 total_locals += count; 71 total_locals += count;
72 DCHECK(total_locals == 72 DCHECK(total_locals ==
73 (sig->parameter_count() + local_int32_count + local_int64_count + 73 (sig->parameter_count() + local_i32_count + local_i64_count +
74 local_float32_count + local_float64_count)); 74 local_f32_count + local_f64_count));
75 } 75 }
76 76
77 void SumLocals() { 77 void SumLocals() {
78 total_locals = static_cast<uint32_t>(sig->parameter_count()) + 78 total_locals = static_cast<uint32_t>(sig->parameter_count()) +
79 local_int32_count + local_int64_count + local_float32_count + 79 local_i32_count + local_i64_count + local_f32_count +
80 local_float64_count; 80 local_f64_count;
81 } 81 }
82 }; 82 };
83 83
84 struct Tree; 84 struct Tree;
85 typedef Result<Tree*> TreeResult; 85 typedef Result<Tree*> TreeResult;
86 86
87 std::ostream& operator<<(std::ostream& os, const Tree& tree); 87 std::ostream& operator<<(std::ostream& os, const Tree& tree);
88 88
89 TreeResult VerifyWasmCode(FunctionEnv* env, const byte* base, const byte* start, 89 TreeResult VerifyWasmCode(FunctionEnv* env, const byte* base, const byte* start,
90 const byte* end); 90 const byte* end);
(...skipping 23 matching lines...) Expand all
114 // Computes the length of the opcode at the given address. 114 // Computes the length of the opcode at the given address.
115 int OpcodeLength(const byte* pc); 115 int OpcodeLength(const byte* pc);
116 116
117 // Computes the arity (number of sub-nodes) of the opcode at the given address. 117 // Computes the arity (number of sub-nodes) of the opcode at the given address.
118 int OpcodeArity(FunctionEnv* env, const byte* pc); 118 int OpcodeArity(FunctionEnv* env, const byte* pc);
119 } // namespace wasm 119 } // namespace wasm
120 } // namespace internal 120 } // namespace internal
121 } // namespace v8 121 } // namespace v8
122 122
123 #endif // V8_WASM_AST_DECODER_H_ 123 #endif // V8_WASM_AST_DECODER_H_
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/ast-decoder.cc » ('j') | src/wasm/wasm-module.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698