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

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

Issue 2405293002: [wasm] Add stack checks to loops. (Closed)
Patch Set: Created 4 years, 2 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 #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/zone-containers.h" 10 #include "src/zone/zone-containers.h"
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 ssa_env_->locals[operand.index] = exception_as_i32; 677 ssa_env_->locals[operand.index] = exception_as_i32;
678 } 678 }
679 } 679 }
680 680
681 break; 681 break;
682 } 682 }
683 case kExprLoop: { 683 case kExprLoop: {
684 BlockTypeOperand operand(this, pc_); 684 BlockTypeOperand operand(this, pc_);
685 SsaEnv* finish_try_env = Steal(ssa_env_); 685 SsaEnv* finish_try_env = Steal(ssa_env_);
686 // The continue environment is the inner environment. 686 // The continue environment is the inner environment.
687 PrepareForLoop(pc_, finish_try_env); 687 PrepareForLoop(pc_, finish_try_env);
titzer 2016/10/11 18:44:33 Can we make PrepareForLoop() return a new environm
ahaas 2016/10/12 18:03:58 Done.
688 SetEnv("loop:start", Split(finish_try_env)); 688 SetEnv("loop:start", SetLoopStackCheck(Split(finish_try_env)));
689 ssa_env_->SetNotMerged(); 689 ssa_env_->SetNotMerged();
690 PushLoop(finish_try_env); 690 PushLoop(finish_try_env);
691 SetBlockType(&control_.back(), operand); 691 SetBlockType(&control_.back(), operand);
692 len = 1 + operand.length; 692 len = 1 + operand.length;
693 break; 693 break;
694 } 694 }
695 case kExprIf: { 695 case kExprIf: {
696 // Condition on top of stack. Split environments for branches. 696 // Condition on top of stack. Split environments for branches.
697 BlockTypeOperand operand(this, pc_); 697 BlockTypeOperand operand(this, pc_);
698 Value cond = Pop(0, kAstI32); 698 Value cond = Pop(0, kAstI32);
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 } 1632 }
1633 } 1633 }
1634 1634
1635 // Conservatively introduce phis for all local variables. 1635 // Conservatively introduce phis for all local variables.
1636 for (int i = EnvironmentCount() - 1; i >= 0; i--) { 1636 for (int i = EnvironmentCount() - 1; i >= 0; i--) {
1637 env->locals[i] = 1637 env->locals[i] =
1638 builder_->Phi(local_type_vec_[i], 1, &env->locals[i], env->control); 1638 builder_->Phi(local_type_vec_[i], 1, &env->locals[i], env->control);
1639 } 1639 }
1640 } 1640 }
1641 1641
1642 SsaEnv* SetLoopStackCheck(SsaEnv* env) {
1643 builder_->StackCheck(position(), &(env->effect), &(env->control));
1644 return env;
1645 }
1646
1642 // Create a complete copy of the {from}. 1647 // Create a complete copy of the {from}.
1643 SsaEnv* Split(SsaEnv* from) { 1648 SsaEnv* Split(SsaEnv* from) {
1644 DCHECK_NOT_NULL(from); 1649 DCHECK_NOT_NULL(from);
1645 SsaEnv* result = reinterpret_cast<SsaEnv*>(zone_->New(sizeof(SsaEnv))); 1650 SsaEnv* result = reinterpret_cast<SsaEnv*>(zone_->New(sizeof(SsaEnv)));
1646 size_t size = sizeof(TFNode*) * EnvironmentCount(); 1651 size_t size = sizeof(TFNode*) * EnvironmentCount();
1647 result->control = from->control; 1652 result->control = from->control;
1648 result->effect = from->effect; 1653 result->effect = from->effect;
1649 1654
1650 if (from->go()) { 1655 if (from->go()) {
1651 result->state = SsaEnv::kReached; 1656 result->state = SsaEnv::kReached;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, 1941 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
1937 const byte* start, const byte* end) { 1942 const byte* start, const byte* end) {
1938 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; 1943 FunctionBody body = {nullptr, nullptr, nullptr, start, end};
1939 WasmFullDecoder decoder(zone, nullptr, body); 1944 WasmFullDecoder decoder(zone, nullptr, body);
1940 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); 1945 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals);
1941 } 1946 }
1942 1947
1943 } // namespace wasm 1948 } // namespace wasm
1944 } // namespace internal 1949 } // namespace internal
1945 } // namespace v8 1950 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698