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

Side by Side Diff: src/asmjs/asm-wasm-builder.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 unified diff | Download patch
« no previous file with comments | « no previous file | src/wasm/function-body-decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/v8.h" 5 #include "src/v8.h"
6 6
7 // Required to get M_E etc. in MSVC. 7 // Required to get M_E etc. in MSVC.
8 #if defined(_WIN32) 8 #if defined(_WIN32)
9 #define _USE_MATH_DEFINES 9 #define _USE_MATH_DEFINES
10 #endif 10 #endif
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 foreign_init_function_->ExportAs( 95 foreign_init_function_->ExportAs(
96 CStrVector(AsmWasmBuilder::foreign_init_name)); 96 CStrVector(AsmWasmBuilder::foreign_init_name));
97 foreign_init_function_->SetSignature(b.Build()); 97 foreign_init_function_->SetSignature(b.Build());
98 for (size_t pos = 0; pos < foreign_variables_.size(); ++pos) { 98 for (size_t pos = 0; pos < foreign_variables_.size(); ++pos) {
99 foreign_init_function_->EmitGetLocal(static_cast<uint32_t>(pos)); 99 foreign_init_function_->EmitGetLocal(static_cast<uint32_t>(pos));
100 ForeignVariable* fv = &foreign_variables_[pos]; 100 ForeignVariable* fv = &foreign_variables_[pos];
101 uint32_t index = LookupOrInsertGlobal(fv->var, fv->type); 101 uint32_t index = LookupOrInsertGlobal(fv->var, fv->type);
102 foreign_init_function_->EmitWithVarInt(kExprSetGlobal, index); 102 foreign_init_function_->EmitWithVarInt(kExprSetGlobal, index);
103 } 103 }
104 foreign_init_function_->Emit(kExprEnd);
105 } 104 }
106 105
107 Handle<FixedArray> GetForeignArgs() { 106 Handle<FixedArray> GetForeignArgs() {
108 Handle<FixedArray> ret = isolate_->factory()->NewFixedArray( 107 Handle<FixedArray> ret = isolate_->factory()->NewFixedArray(
109 static_cast<int>(foreign_variables_.size())); 108 static_cast<int>(foreign_variables_.size()));
110 for (size_t i = 0; i < foreign_variables_.size(); ++i) { 109 for (size_t i = 0; i < foreign_variables_.size(); ++i) {
111 ForeignVariable* fv = &foreign_variables_[i]; 110 ForeignVariable* fv = &foreign_variables_[i];
112 ret->set(static_cast<int>(i), *fv->name); 111 ret->set(static_cast<int>(i), *fv->name);
113 } 112 }
114 return ret; 113 return ret;
(...skipping 10 matching lines...) Expand all
125 return false; 124 return false;
126 } 125 }
127 if (!typer_finished_) { 126 if (!typer_finished_) {
128 typer_->FailWithMessage("Module missing export section."); 127 typer_->FailWithMessage("Module missing export section.");
129 typer_failed_ = true; 128 typer_failed_ = true;
130 } 129 }
131 if (typer_failed_) { 130 if (typer_failed_) {
132 return false; 131 return false;
133 } 132 }
134 BuildForeignInitFunction(); 133 BuildForeignInitFunction();
135 init_function_->Emit(kExprEnd); // finish init function.
136 return true; 134 return true;
137 } 135 }
138 136
139 void VisitVariableDeclaration(VariableDeclaration* decl) {} 137 void VisitVariableDeclaration(VariableDeclaration* decl) {}
140 138
141 void VisitFunctionDeclaration(FunctionDeclaration* decl) { 139 void VisitFunctionDeclaration(FunctionDeclaration* decl) {
142 DCHECK_EQ(kModuleScope, scope_); 140 DCHECK_EQ(kModuleScope, scope_);
143 DCHECK_NULL(current_function_builder_); 141 DCHECK_NULL(current_function_builder_);
144 FunctionLiteral* old_func = decl->fun(); 142 FunctionLiteral* old_func = decl->fun();
145 Zone zone(isolate_->allocator(), ZONE_NAME); 143 Zone zone(isolate_->allocator(), ZONE_NAME);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 DCHECK_NE(kWasmStmt, type); 536 DCHECK_NE(kWasmStmt, type);
539 InsertParameter(scope->parameter(i), type, i); 537 InsertParameter(scope->parameter(i), type, i);
540 } 538 }
541 } else { 539 } else {
542 UNREACHABLE(); 540 UNREACHABLE();
543 } 541 }
544 } 542 }
545 RECURSE(VisitDeclarations(scope->declarations())); 543 RECURSE(VisitDeclarations(scope->declarations()));
546 if (typer_failed_) return; 544 if (typer_failed_) return;
547 RECURSE(VisitStatements(expr->body())); 545 RECURSE(VisitStatements(expr->body()));
548 if (scope_ == kFuncScope) {
549 // Finish the function-body scope block.
550 current_function_builder_->Emit(kExprEnd);
551 }
552 } 546 }
553 547
554 void VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) { 548 void VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) {
555 UNREACHABLE(); 549 UNREACHABLE();
556 } 550 }
557 551
558 void VisitConditional(Conditional* expr) { 552 void VisitConditional(Conditional* expr) {
559 DCHECK_EQ(kFuncScope, scope_); 553 DCHECK_EQ(kFuncScope, scope_);
560 RECURSE(Visit(expr->condition())); 554 RECURSE(Visit(expr->condition()));
561 // WASM ifs come with implicit blocks for both arms. 555 // WASM ifs come with implicit blocks for both arms.
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer); 1995 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer);
2002 return {module_buffer, asm_offsets_buffer, success}; 1996 return {module_buffer, asm_offsets_buffer, success};
2003 } 1997 }
2004 1998
2005 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; 1999 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__";
2006 const char* AsmWasmBuilder::single_function_name = "__single_function__"; 2000 const char* AsmWasmBuilder::single_function_name = "__single_function__";
2007 2001
2008 } // namespace wasm 2002 } // namespace wasm
2009 } // namespace internal 2003 } // namespace internal
2010 } // namespace v8 2004 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/wasm/function-body-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698