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

Side by Side Diff: src/asmjs/asm-typer.cc

Issue 2481103002: [wasm] [asm.js] Don't allow bad return types from a global constant (Closed)
Patch Set: Created 4 years, 1 month 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/asmjs/test-asm-typer.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/asmjs/asm-typer.h" 5 #include "src/asmjs/asm-typer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 2695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 auto* var_info = Lookup(proxy->var()); 2706 auto* var_info = Lookup(proxy->var());
2707 2707
2708 if (var_info == nullptr) { 2708 if (var_info == nullptr) {
2709 FAIL(statement, "Undeclared identifier in return statement."); 2709 FAIL(statement, "Undeclared identifier in return statement.");
2710 } 2710 }
2711 2711
2712 if (var_info->mutability() != VariableInfo::kConstGlobal) { 2712 if (var_info->mutability() != VariableInfo::kConstGlobal) {
2713 FAIL(statement, "Identifier in return statement is not const."); 2713 FAIL(statement, "Identifier in return statement is not const.");
2714 } 2714 }
2715 2715
2716 if (!var_info->type()->IsReturnType()) {
2717 FAIL(statement, "Constant in return must be signed, float, or double.");
2718 }
2719
2716 return var_info->type(); 2720 return var_info->type();
2717 } 2721 }
2718 2722
2719 FAIL(statement, "Invalid return type expression."); 2723 FAIL(statement, "Invalid return type expression.");
2720 } 2724 }
2721 2725
2722 // 5.4 VariableTypeAnnotations 2726 // 5.4 VariableTypeAnnotations
2723 // Also used for 5.5 GlobalVariableTypeAnnotations 2727 // Also used for 5.5 GlobalVariableTypeAnnotations
2724 AsmType* AsmTyper::VariableTypeAnnotations( 2728 AsmType* AsmTyper::VariableTypeAnnotations(
2725 Expression* initializer, VariableInfo::Mutability mutability_type) { 2729 Expression* initializer, VariableInfo::Mutability mutability_type) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 return true; 2857 return true;
2854 } 2858 }
2855 2859
2856 *error_message = typer.error_message(); 2860 *error_message = typer.error_message();
2857 return false; 2861 return false;
2858 } 2862 }
2859 2863
2860 } // namespace wasm 2864 } // namespace wasm
2861 } // namespace internal 2865 } // namespace internal
2862 } // namespace v8 2866 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/asmjs/test-asm-typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698