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

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

Issue 2268363002: [Asm.js] Prevents assignments to immutables. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addresses comments. Created 4 years, 4 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/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 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 FAIL(target_as_proxy, 1737 FAIL(target_as_proxy,
1738 "Invalid asm.js identifier in temporary variable."); 1738 "Invalid asm.js identifier in temporary variable.");
1739 } 1739 }
1740 1740
1741 if (!AddLocal(var, var_info)) { 1741 if (!AddLocal(var, var_info)) {
1742 FAIL(assignment, "Failed to add temporary variable to symbol table."); 1742 FAIL(assignment, "Failed to add temporary variable to symbol table.");
1743 } 1743 }
1744 return value_type; 1744 return value_type;
1745 } 1745 }
1746 1746
1747 DCHECK(target_info->type() != AsmType::None()); 1747 if (!target_info->IsMutable()) {
1748 FAIL(assignment, "Can't assign to immutable symbol.");
1749 }
1750
1751 DCHECK_NE(AsmType::None(), target_info->type());
1748 if (!value_type->IsA(target_info->type())) { 1752 if (!value_type->IsA(target_info->type())) {
1749 FAIL(assignment, "Type mismatch in assignment."); 1753 FAIL(assignment, "Type mismatch in assignment.");
1750 } 1754 }
1751 1755
1752 return value_type; 1756 return value_type;
1753 } 1757 }
1754 1758
1755 if (auto* target_as_property = assignment->target()->AsProperty()) { 1759 if (auto* target_as_property = assignment->target()->AsProperty()) {
1756 AsmType* allowed_store_types; 1760 AsmType* allowed_store_types;
1757 RECURSE(allowed_store_types = 1761 RECURSE(allowed_store_types =
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 return true; 2764 return true;
2761 } 2765 }
2762 2766
2763 *error_message = typer.error_message(); 2767 *error_message = typer.error_message();
2764 return false; 2768 return false;
2765 } 2769 }
2766 2770
2767 } // namespace wasm 2771 } // namespace wasm
2768 } // namespace internal 2772 } // namespace internal
2769 } // namespace v8 2773 } // 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