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

Unified Diff: src/wasm/function-body-decoder.cc

Issue 2628883006: Revert of [wasm] Enforce that function bodies end with the \"end\" opcode. (Closed)
Patch Set: Created 3 years, 11 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/asmjs/asm-wasm-builder.cc ('k') | src/wasm/wasm-macro-gen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/function-body-decoder.cc
diff --git a/src/wasm/function-body-decoder.cc b/src/wasm/function-body-decoder.cc
index 152fba1ffe92a42b9cd27c05f1180134cde89ef9..b50d97eb3d01602dfa4d73ab31da186f755db5b1 100644
--- a/src/wasm/function-body-decoder.cc
+++ b/src/wasm/function-body-decoder.cc
@@ -39,6 +39,8 @@
error("Invalid opcode (enable with --" #flag ")"); \
break; \
}
+// TODO(titzer): this is only for intermediate migration.
+#define IMPLICIT_FUNCTION_END 1
// An SsaEnv environment carries the current local variable renaming
// as well as the current effect and control dependency in the TF graph.
@@ -491,14 +493,41 @@
if (failed()) return TraceFailed();
+#if IMPLICIT_FUNCTION_END
+ // With implicit end support (old style), the function block
+ // remains on the stack. Other control blocks are an error.
+ if (control_.size() > 1) {
+ error(pc_, control_.back().pc, "unterminated control structure");
+ return TraceFailed();
+ }
+
+ // Assume an implicit end to the function body block.
+ if (control_.size() == 1) {
+ Control* c = &control_.back();
+ if (ssa_env_->go()) {
+ FallThruTo(c);
+ }
+
+ if (c->end_env->go()) {
+ // Push the end values onto the stack.
+ stack_.resize(c->stack_depth);
+ if (c->merge.arity == 1) {
+ stack_.push_back(c->merge.vals.first);
+ } else {
+ for (unsigned i = 0; i < c->merge.arity; i++) {
+ stack_.push_back(c->merge.vals.array[i]);
+ }
+ }
+
+ TRACE(" @%-8d #xx:%-20s|", startrel(pc_), "ImplicitReturn");
+ SetEnv("function:end", c->end_env);
+ DoReturn();
+ TRACE("\n");
+ }
+ }
+#else
if (!control_.empty()) {
- // Generate a better error message whether the unterminated control
- // structure is the function body block or an innner structure.
- if (control_.size() > 1) {
- error(pc_, control_.back().pc, "unterminated control structure");
- } else {
- error("function body must end with \"end\" opcode.");
- }
+ error(pc_, control_.back().pc, "unterminated control structure");
return TraceFailed();
}
@@ -506,6 +535,7 @@
error("function body must end with \"end\" opcode.");
return false;
}
+#endif
if (FLAG_trace_wasm_decode_time) {
double ms = decode_timer.Elapsed().InMillisecondsF();
« no previous file with comments | « src/asmjs/asm-wasm-builder.cc ('k') | src/wasm/wasm-macro-gen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698