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

Side by Side Diff: src/asmjs/asm-wasm-builder.cc

Issue 2620893002: [wasm][asm.js] Ensure final validation phase runs. (Closed)
Patch Set: drop junk 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 | « src/asmjs/asm-typer.cc ('k') | test/mjsunit/asm/regress-676573.js » ('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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 builder_(new (zone) WasmModuleBuilder(zone)), 60 builder_(new (zone) WasmModuleBuilder(zone)),
61 current_function_builder_(nullptr), 61 current_function_builder_(nullptr),
62 literal_(literal), 62 literal_(literal),
63 isolate_(isolate), 63 isolate_(isolate),
64 zone_(zone), 64 zone_(zone),
65 info_(info), 65 info_(info),
66 ast_value_factory_(ast_value_factory), 66 ast_value_factory_(ast_value_factory),
67 script_(script), 67 script_(script),
68 typer_(typer), 68 typer_(typer),
69 typer_failed_(false), 69 typer_failed_(false),
70 typer_finished_(false),
70 breakable_blocks_(zone), 71 breakable_blocks_(zone),
71 foreign_variables_(zone), 72 foreign_variables_(zone),
72 init_function_(nullptr), 73 init_function_(nullptr),
73 foreign_init_function_(nullptr), 74 foreign_init_function_(nullptr),
74 function_tables_(ZoneHashMap::kDefaultHashMapCapacity, 75 function_tables_(ZoneHashMap::kDefaultHashMapCapacity,
75 ZoneAllocationPolicy(zone)), 76 ZoneAllocationPolicy(zone)),
76 imported_function_table_(this), 77 imported_function_table_(this),
77 parent_binop_(nullptr) { 78 parent_binop_(nullptr) {
78 InitializeAstVisitor(isolate); 79 InitializeAstVisitor(isolate);
79 } 80 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 bool Build() { 116 bool Build() {
116 InitializeInitFunction(); 117 InitializeInitFunction();
117 if (!typer_->ValidateBeforeFunctionsPhase()) { 118 if (!typer_->ValidateBeforeFunctionsPhase()) {
118 return false; 119 return false;
119 } 120 }
120 DCHECK(!HasStackOverflow()); 121 DCHECK(!HasStackOverflow());
121 VisitFunctionLiteral(literal_); 122 VisitFunctionLiteral(literal_);
122 if (HasStackOverflow()) { 123 if (HasStackOverflow()) {
123 return false; 124 return false;
124 } 125 }
126 if (!typer_finished_) {
127 typer_->FailWithMessage("Module missing export section.");
128 typer_failed_ = true;
129 }
125 if (typer_failed_) { 130 if (typer_failed_) {
126 return false; 131 return false;
127 } 132 }
128 BuildForeignInitFunction(); 133 BuildForeignInitFunction();
129 return true; 134 return true;
130 } 135 }
131 136
132 void VisitVariableDeclaration(VariableDeclaration* decl) {} 137 void VisitVariableDeclaration(VariableDeclaration* decl) {}
133 138
134 void VisitFunctionDeclaration(FunctionDeclaration* decl) { 139 void VisitFunctionDeclaration(FunctionDeclaration* decl) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 void VisitContinueStatement(ContinueStatement* stmt) { 320 void VisitContinueStatement(ContinueStatement* stmt) {
316 DoBreakOrContinue(stmt->target(), true); 321 DoBreakOrContinue(stmt->target(), true);
317 } 322 }
318 323
319 void VisitBreakStatement(BreakStatement* stmt) { 324 void VisitBreakStatement(BreakStatement* stmt) {
320 DoBreakOrContinue(stmt->target(), false); 325 DoBreakOrContinue(stmt->target(), false);
321 } 326 }
322 327
323 void VisitReturnStatement(ReturnStatement* stmt) { 328 void VisitReturnStatement(ReturnStatement* stmt) {
324 if (scope_ == kModuleScope) { 329 if (scope_ == kModuleScope) {
330 if (typer_finished_) {
331 typer_->FailWithMessage("Module has multiple returns.");
332 typer_failed_ = true;
333 return;
334 }
325 if (!typer_->ValidateAfterFunctionsPhase()) { 335 if (!typer_->ValidateAfterFunctionsPhase()) {
326 typer_failed_ = true; 336 typer_failed_ = true;
327 return; 337 return;
328 } 338 }
339 typer_finished_ = true;
329 scope_ = kExportScope; 340 scope_ = kExportScope;
330 RECURSE(Visit(stmt->expression())); 341 RECURSE(Visit(stmt->expression()));
331 scope_ = kModuleScope; 342 scope_ = kModuleScope;
332 } else if (scope_ == kFuncScope) { 343 } else if (scope_ == kFuncScope) {
333 RECURSE(Visit(stmt->expression())); 344 RECURSE(Visit(stmt->expression()));
334 current_function_builder_->Emit(kExprReturn); 345 current_function_builder_->Emit(kExprReturn);
335 } else { 346 } else {
336 UNREACHABLE(); 347 UNREACHABLE();
337 } 348 }
338 } 349 }
(...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 WasmModuleBuilder* builder_; 1951 WasmModuleBuilder* builder_;
1941 WasmFunctionBuilder* current_function_builder_; 1952 WasmFunctionBuilder* current_function_builder_;
1942 FunctionLiteral* literal_; 1953 FunctionLiteral* literal_;
1943 Isolate* isolate_; 1954 Isolate* isolate_;
1944 Zone* zone_; 1955 Zone* zone_;
1945 CompilationInfo* info_; 1956 CompilationInfo* info_;
1946 AstValueFactory* ast_value_factory_; 1957 AstValueFactory* ast_value_factory_;
1947 Handle<Script> script_; 1958 Handle<Script> script_;
1948 AsmTyper* typer_; 1959 AsmTyper* typer_;
1949 bool typer_failed_; 1960 bool typer_failed_;
1961 bool typer_finished_;
1950 ZoneVector<std::pair<BreakableStatement*, bool>> breakable_blocks_; 1962 ZoneVector<std::pair<BreakableStatement*, bool>> breakable_blocks_;
1951 ZoneVector<ForeignVariable> foreign_variables_; 1963 ZoneVector<ForeignVariable> foreign_variables_;
1952 WasmFunctionBuilder* init_function_; 1964 WasmFunctionBuilder* init_function_;
1953 WasmFunctionBuilder* foreign_init_function_; 1965 WasmFunctionBuilder* foreign_init_function_;
1954 uint32_t next_table_index_; 1966 uint32_t next_table_index_;
1955 ZoneHashMap function_tables_; 1967 ZoneHashMap function_tables_;
1956 ImportedFunctionTable imported_function_table_; 1968 ImportedFunctionTable imported_function_table_;
1957 // Remember the parent node for reporting the correct location for ToNumber 1969 // Remember the parent node for reporting the correct location for ToNumber
1958 // conversions after calls. 1970 // conversions after calls.
1959 BinaryOperation* parent_binop_; 1971 BinaryOperation* parent_binop_;
(...skipping 23 matching lines...) Expand all
1983 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer); 1995 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer);
1984 return {module_buffer, asm_offsets_buffer, success}; 1996 return {module_buffer, asm_offsets_buffer, success};
1985 } 1997 }
1986 1998
1987 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; 1999 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__";
1988 const char* AsmWasmBuilder::single_function_name = "__single_function__"; 2000 const char* AsmWasmBuilder::single_function_name = "__single_function__";
1989 2001
1990 } // namespace wasm 2002 } // namespace wasm
1991 } // namespace internal 2003 } // namespace internal
1992 } // namespace v8 2004 } // namespace v8
OLDNEW
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | test/mjsunit/asm/regress-676573.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698