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

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

Issue 2372823004: [wasm] asm.js: Work around parser converting !0 and !1 to boolean. (Closed)
Patch Set: Created 4 years, 2 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/asmjs/asm-wasm-builder.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 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 // *VIOLATION* asm.js does not allow the use of undefined, but our parser 1657 // *VIOLATION* asm.js does not allow the use of undefined, but our parser
1658 // inserts them, so we have to handle them. 1658 // inserts them, so we have to handle them.
1659 if (literal->IsUndefinedLiteral()) { 1659 if (literal->IsUndefinedLiteral()) {
1660 return AsmType::Void(); 1660 return AsmType::Void();
1661 } 1661 }
1662 1662
1663 if (literal->raw_value()->ContainsDot()) { 1663 if (literal->raw_value()->ContainsDot()) {
1664 return AsmType::Double(); 1664 return AsmType::Double();
1665 } 1665 }
1666 1666
1667 // The parser collapses expressions like !0 and !123 to true/false.
1668 // We therefore need to permit these as alternate versions of 0 / 1.
1669 if (literal->raw_value()->IsTrue() || literal->raw_value()->IsFalse()) {
1670 return AsmType::Int();
1671 }
1672
1667 uint32_t value; 1673 uint32_t value;
1668 if (!literal->value()->ToUint32(&value)) { 1674 if (!literal->value()->ToUint32(&value)) {
1669 int32_t value; 1675 int32_t value;
1670 if (!literal->value()->ToInt32(&value)) { 1676 if (!literal->value()->ToInt32(&value)) {
1671 FAIL(literal, "Integer literal is out of range."); 1677 FAIL(literal, "Integer literal is out of range.");
1672 } 1678 }
1673 // *VIOLATION* Not really a violation, but rather a different in the 1679 // *VIOLATION* Not really a violation, but rather a different in the
1674 // validation. The spec handles -NumericLiteral in ValidateUnaryExpression, 1680 // validation. The spec handles -NumericLiteral in ValidateUnaryExpression,
1675 // but V8's AST represents the negative literals as Literals. 1681 // but V8's AST represents the negative literals as Literals.
1676 return AsmType::Signed(); 1682 return AsmType::Signed();
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2779 return true; 2785 return true;
2780 } 2786 }
2781 2787
2782 *error_message = typer.error_message(); 2788 *error_message = typer.error_message();
2783 return false; 2789 return false;
2784 } 2790 }
2785 2791
2786 } // namespace wasm 2792 } // namespace wasm
2787 } // namespace internal 2793 } // namespace internal
2788 } // namespace v8 2794 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/asmjs/asm-wasm-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698