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

Unified Diff: src/wasm/ast-decoder.cc

Issue 2405293002: [wasm] Add stack checks to loops. (Closed)
Patch Set: comments addressed 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/ast-decoder.cc
diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc
index 025ccdf1d7bfc0d2c159e511600b0d313cf0fa9b..ea43009847f2d820d4a7f57bf2896cabf4304072 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -684,8 +684,8 @@ class WasmFullDecoder : public WasmDecoder {
BlockTypeOperand operand(this, pc_);
SsaEnv* finish_try_env = Steal(ssa_env_);
// The continue environment is the inner environment.
- PrepareForLoop(pc_, finish_try_env);
- SetEnv("loop:start", Split(finish_try_env));
+ SsaEnv* loop_body_env = PrepareForLoop(pc_, finish_try_env);
+ SetEnv("loop:start", loop_body_env);
ssa_env_->SetNotMerged();
PushLoop(finish_try_env);
SetBlockType(&control_.back(), operand);
@@ -1611,10 +1611,10 @@ class WasmFullDecoder : public WasmDecoder {
return tnode;
}
- void PrepareForLoop(const byte* pc, SsaEnv* env) {
- if (!env->go()) return;
+ SsaEnv* PrepareForLoop(const byte* pc, SsaEnv* env) {
+ if (!builder_) return Split(env);
+ if (!env->go()) return Split(env);
env->state = SsaEnv::kMerged;
- if (!builder_) return;
env->control = builder_->Loop(env->control);
env->effect = builder_->EffectPhi(1, &env->effect, env->control);
@@ -1628,7 +1628,10 @@ class WasmFullDecoder : public WasmDecoder {
env->locals[i] = builder_->Phi(local_type_vec_[i], 1, &env->locals[i],
env->control);
}
- return;
+ SsaEnv* loop_body_env = Split(env);
+ builder_->StackCheck(position(), &(loop_body_env->effect),
+ &(loop_body_env->control));
+ return loop_body_env;
}
}
@@ -1637,6 +1640,11 @@ class WasmFullDecoder : public WasmDecoder {
env->locals[i] =
builder_->Phi(local_type_vec_[i], 1, &env->locals[i], env->control);
}
+
+ SsaEnv* loop_body_env = Split(env);
+ builder_->StackCheck(position(), &(loop_body_env->effect),
+ &(loop_body_env->control));
+ return loop_body_env;
}
// Create a complete copy of the {from}.
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698