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-containers.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 : Decoder(start, end), | 102 : Decoder(start, end), |
103 module_(module), | 103 module_(module), |
104 sig_(sig), | 104 sig_(sig), |
105 total_locals_(0), | 105 total_locals_(0), |
106 local_types_(nullptr) {} | 106 local_types_(nullptr) {} |
107 ModuleEnv* module_; | 107 ModuleEnv* module_; |
108 FunctionSig* sig_; | 108 FunctionSig* sig_; |
109 size_t total_locals_; | 109 size_t total_locals_; |
110 ZoneVector<LocalType>* local_types_; | 110 ZoneVector<LocalType>* local_types_; |
111 | 111 |
112 byte ByteOperand(const byte* pc, const char* msg = "missing 1-byte operand") { | |
113 if ((pc + sizeof(byte)) >= limit_) { | |
114 error(pc, msg); | |
115 return 0; | |
116 } | |
117 return pc[1]; | |
118 } | |
119 | |
120 uint32_t Uint32Operand(const byte* pc) { | |
121 if ((pc + sizeof(uint32_t)) >= limit_) { | |
122 error(pc, "missing 4-byte operand"); | |
123 return 0; | |
124 } | |
125 return read_u32(pc + 1); | |
126 } | |
127 | |
128 uint64_t Uint64Operand(const byte* pc) { | |
129 if ((pc + sizeof(uint64_t)) >= limit_) { | |
130 error(pc, "missing 8-byte operand"); | |
131 return 0; | |
132 } | |
133 return read_u64(pc + 1); | |
134 } | |
135 | |
136 inline bool Validate(const byte* pc, LocalIndexOperand& operand) { | 112 inline bool Validate(const byte* pc, LocalIndexOperand& operand) { |
137 if (operand.index < total_locals_) { | 113 if (operand.index < total_locals_) { |
138 if (local_types_) { | 114 if (local_types_) { |
139 operand.type = local_types_->at(operand.index); | 115 operand.type = local_types_->at(operand.index); |
140 } else { | 116 } else { |
141 operand.type = kAstStmt; | 117 operand.type = kAstStmt; |
142 } | 118 } |
143 return true; | 119 return true; |
144 } | 120 } |
145 error(pc, pc + 1, "invalid local index"); | 121 error(pc, pc + 1, "invalid local index"); |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 1655 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
1680 const byte* start, const byte* end) { | 1656 const byte* start, const byte* end) { |
1681 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 1657 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
1682 SR_WasmDecoder decoder(zone, nullptr, body); | 1658 SR_WasmDecoder decoder(zone, nullptr, body); |
1683 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 1659 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
1684 } | 1660 } |
1685 | 1661 |
1686 } // namespace wasm | 1662 } // namespace wasm |
1687 } // namespace internal | 1663 } // namespace internal |
1688 } // namespace v8 | 1664 } // namespace v8 |
OLD | NEW |