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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 480 |
481 private: | 481 private: |
482 static const size_t kErrorMsgSize = 128; | 482 static const size_t kErrorMsgSize = 128; |
483 | 483 |
484 Zone* zone_; | 484 Zone* zone_; |
485 TFBuilder* builder_; | 485 TFBuilder* builder_; |
486 const byte* base_; | 486 const byte* base_; |
487 | 487 |
488 SsaEnv* ssa_env_; | 488 SsaEnv* ssa_env_; |
489 | 489 |
490 ZoneVector<LocalType> local_type_vec_; | 490 ZoneVector<LocalType> local_type_vec_; // types of local variables. |
491 ZoneVector<Value> stack_; | 491 ZoneVector<Value> stack_; // stack of values. |
492 ZoneVector<Control> control_; | 492 ZoneVector<Control> control_; // stack of blocks, loops, and ifs. |
493 | 493 |
494 inline bool build() { return builder_ && ssa_env_->go(); } | 494 inline bool build() { return builder_ && ssa_env_->go(); } |
495 | 495 |
496 void InitSsaEnv() { | 496 void InitSsaEnv() { |
497 TFNode* start = nullptr; | 497 TFNode* start = nullptr; |
498 SsaEnv* ssa_env = reinterpret_cast<SsaEnv*>(zone_->New(sizeof(SsaEnv))); | 498 SsaEnv* ssa_env = reinterpret_cast<SsaEnv*>(zone_->New(sizeof(SsaEnv))); |
499 size_t size = sizeof(TFNode*) * EnvironmentCount(); | 499 size_t size = sizeof(TFNode*) * EnvironmentCount(); |
500 ssa_env->state = SsaEnv::kReached; | 500 ssa_env->state = SsaEnv::kReached; |
501 ssa_env->locals = | 501 ssa_env->locals = |
502 size > 0 ? reinterpret_cast<TFNode**>(zone_->New(size)) : nullptr; | 502 size > 0 ? reinterpret_cast<TFNode**>(zone_->New(size)) : nullptr; |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 if (val.type != kAstEnd) { | 1150 if (val.type != kAstEnd) { |
1151 error(pc_, val.pc, "%s[%d] expected type %s, found %s of type %s", | 1151 error(pc_, val.pc, "%s[%d] expected type %s, found %s of type %s", |
1152 SafeOpcodeNameAt(pc_), index, WasmOpcodes::TypeName(expected), | 1152 SafeOpcodeNameAt(pc_), index, WasmOpcodes::TypeName(expected), |
1153 SafeOpcodeNameAt(val.pc), WasmOpcodes::TypeName(val.type)); | 1153 SafeOpcodeNameAt(val.pc), WasmOpcodes::TypeName(val.type)); |
1154 } | 1154 } |
1155 } | 1155 } |
1156 return val; | 1156 return val; |
1157 } | 1157 } |
1158 | 1158 |
1159 Value Pop() { | 1159 Value Pop() { |
1160 if (stack_.empty()) { | 1160 size_t limit = control_.empty() ? 0 : control_.back().stack_depth; |
| 1161 if (stack_.size() <= limit) { |
1161 Value val = {pc_, nullptr, kAstStmt}; | 1162 Value val = {pc_, nullptr, kAstStmt}; |
1162 error(pc_, pc_, "%s found empty stack", SafeOpcodeNameAt(pc_)); | 1163 error(pc_, pc_, "%s found empty stack", SafeOpcodeNameAt(pc_)); |
1163 return val; | 1164 return val; |
1164 } | 1165 } |
1165 Value val = stack_.back(); | 1166 Value val = stack_.back(); |
1166 stack_.pop_back(); | 1167 stack_.pop_back(); |
1167 return val; | 1168 return val; |
1168 } | 1169 } |
1169 | 1170 |
1170 Value PopUpTo(int stack_depth) { | 1171 Value PopUpTo(int stack_depth) { |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 1648 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
1648 const byte* start, const byte* end) { | 1649 const byte* start, const byte* end) { |
1649 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 1650 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
1650 SR_WasmDecoder decoder(zone, nullptr, body); | 1651 SR_WasmDecoder decoder(zone, nullptr, body); |
1651 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 1652 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
1652 } | 1653 } |
1653 | 1654 |
1654 } // namespace wasm | 1655 } // namespace wasm |
1655 } // namespace internal | 1656 } // namespace internal |
1656 } // namespace v8 | 1657 } // namespace v8 |
OLD | NEW |