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

Side by Side Diff: src/typing-asm.cc

Issue 2040983002: [asmjs] Validator should reject modules with repeated functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | test/cctest/test-asm-validator.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/typing-asm.h" 5 #include "src/typing-asm.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 160
161 161
162 void AsmTyper::VisitFunctionDeclaration(FunctionDeclaration* decl) { 162 void AsmTyper::VisitFunctionDeclaration(FunctionDeclaration* decl) {
163 if (in_function_) { 163 if (in_function_) {
164 FAIL(decl, "function declared inside another"); 164 FAIL(decl, "function declared inside another");
165 } 165 }
166 // Set function type so global references to functions have some type 166 // Set function type so global references to functions have some type
167 // (so they can give a more useful error). 167 // (so they can give a more useful error).
168 Variable* var = decl->proxy()->var(); 168 Variable* var = decl->proxy()->var();
169 if (GetVariableInfo(var)) {
170 // Detect previously-seen functions.
171 FAIL(decl->fun(), "function repeated in module");
172 }
169 SetType(var, Type::Function()); 173 SetType(var, Type::Function());
170 } 174 }
171 175
172 176
173 void AsmTyper::VisitFunctionAnnotation(FunctionLiteral* fun) { 177 void AsmTyper::VisitFunctionAnnotation(FunctionLiteral* fun) {
174 // Extract result type. 178 // Extract result type.
175 ZoneList<Statement*>* body = fun->body(); 179 ZoneList<Statement*>* body = fun->body();
176 Type* result_type = Type::Undefined(); 180 Type* result_type = Type::Undefined();
177 if (body->length() > 0) { 181 if (body->length() > 0) {
178 ReturnStatement* stmt = body->last()->AsReturnStatement(); 182 ReturnStatement* stmt = body->last()->AsReturnStatement();
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 } 1634 }
1631 1635
1632 1636
1633 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) { 1637 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) {
1634 RECURSE(Visit(expr->expression())); 1638 RECURSE(Visit(expr->expression()));
1635 } 1639 }
1636 1640
1637 1641
1638 } // namespace internal 1642 } // namespace internal
1639 } // namespace v8 1643 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698