OLD | NEW |
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 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/ast-expression-visitor.h" | 8 #include "src/ast/ast-expression-visitor.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/parsing/parser.h" | 10 #include "src/parsing/parser.h" |
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 1319 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1320 CHECK_VAR(x, Bounds(cache.kAsmInt)); | 1320 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1321 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1321 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1322 } | 1322 } |
1323 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 1323 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1324 CHECK_VAR(y, Bounds(cache.kAsmInt)); | 1324 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
1325 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { | 1325 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1326 CHECK_EXPR(Property, Bounds(cache.kAsmInt)) { | 1326 CHECK_EXPR(Property, Bounds(cache.kAsmInt)) { |
1327 CHECK_VAR(i8, Bounds(cache.kInt8Array)); | 1327 CHECK_VAR(i8, Bounds(cache.kInt8Array)); |
1328 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { | 1328 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1329 CHECK_VAR(x, Bounds(cache.kAsmSigned)); | 1329 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1330 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1330 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1331 } | 1331 } |
1332 } | 1332 } |
1333 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1333 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1334 } | 1334 } |
1335 } | 1335 } |
1336 } | 1336 } |
1337 CHECK_SKIP(); | 1337 CHECK_SKIP(); |
1338 } | 1338 } |
1339 CHECK_FUNC_TYPES_END | 1339 CHECK_FUNC_TYPES_END |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 "function foo() { bar(); }") { | 1379 "function foo() { bar(); }") { |
1380 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 1380 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
1381 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 1381 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1382 CHECK_VAR(x, Bounds(cache.kAsmInt)); | 1382 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1383 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1383 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1384 } | 1384 } |
1385 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 1385 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1386 CHECK_EXPR(Property, Bounds::Unbounded()) { | 1386 CHECK_EXPR(Property, Bounds::Unbounded()) { |
1387 CHECK_VAR(i8, Bounds(cache.kInt8Array)); | 1387 CHECK_VAR(i8, Bounds(cache.kInt8Array)); |
1388 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { | 1388 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1389 CHECK_VAR(x, Bounds(cache.kAsmSigned)); | 1389 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1390 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1390 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1391 } | 1391 } |
1392 } | 1392 } |
1393 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1393 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1394 } | 1394 } |
1395 } | 1395 } |
1396 CHECK_SKIP(); | 1396 CHECK_SKIP(); |
1397 } | 1397 } |
1398 CHECK_FUNC_TYPES_END | 1398 CHECK_FUNC_TYPES_END |
1399 } | 1399 } |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 CHECK_EXPR(Assignment, Bounds(FUNC_FOREIGN_TYPE)) { | 1743 CHECK_EXPR(Assignment, Bounds(FUNC_FOREIGN_TYPE)) { |
1744 CHECK_VAR(baz, Bounds(FUNC_FOREIGN_TYPE)); | 1744 CHECK_VAR(baz, Bounds(FUNC_FOREIGN_TYPE)); |
1745 CHECK_EXPR(Property, Bounds(FUNC_FOREIGN_TYPE)) { | 1745 CHECK_EXPR(Property, Bounds(FUNC_FOREIGN_TYPE)) { |
1746 CHECK_VAR(foreign, Bounds::Unbounded()); | 1746 CHECK_VAR(foreign, Bounds::Unbounded()); |
1747 CHECK_EXPR(Literal, Bounds::Unbounded()); | 1747 CHECK_EXPR(Literal, Bounds::Unbounded()); |
1748 } | 1748 } |
1749 } | 1749 } |
1750 CHECK_FUNC_TYPES_END_2() | 1750 CHECK_FUNC_TYPES_END_2() |
1751 } | 1751 } |
1752 | 1752 |
| 1753 TEST(ByteArray) { |
| 1754 // Forbidden by asm.js spec, present in embenchen. |
| 1755 CHECK_FUNC_TYPES_BEGIN( |
| 1756 "function bar() { var x = 0; i8[x] = 2; }\n" |
| 1757 "function foo() { bar(); }") { |
| 1758 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 1759 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1760 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 1761 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1762 } |
| 1763 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1764 CHECK_EXPR(Property, Bounds::Unbounded()) { |
| 1765 CHECK_VAR(i8, Bounds(cache.kInt8Array)); |
| 1766 CHECK_VAR(x, Bounds(cache.kAsmSigned)); |
| 1767 } |
| 1768 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1769 } |
| 1770 } |
| 1771 CHECK_SKIP(); |
| 1772 } |
| 1773 CHECK_FUNC_TYPES_END |
| 1774 } |
1753 | 1775 |
1754 TEST(BadExports) { | 1776 TEST(BadExports) { |
1755 HARNESS_PREAMBLE() | 1777 HARNESS_PREAMBLE() |
1756 "function foo() {};\n" | 1778 "function foo() {};\n" |
1757 "return {foo: foo, bar: 1};" | 1779 "return {foo: foo, bar: 1};" |
1758 "}\n"; | 1780 "}\n"; |
1759 | 1781 |
1760 v8::V8::Initialize(); | 1782 v8::V8::Initialize(); |
1761 HandleAndZoneScope handles; | 1783 HandleAndZoneScope handles; |
1762 Zone* zone = handles.main_zone(); | 1784 Zone* zone = handles.main_zone(); |
1763 ZoneVector<ExpressionTypeEntry> types(zone); | 1785 ZoneVector<ExpressionTypeEntry> types(zone); |
1764 CHECK_EQ("asm: line 40: non-function in function table\n", | 1786 CHECK_EQ("asm: line 40: non-function in function table\n", |
1765 Validate(zone, test_function, &types)); | 1787 Validate(zone, test_function, &types)); |
1766 } | 1788 } |
1767 | 1789 |
1768 | 1790 |
1769 TEST(NestedHeapAssignment) { | 1791 TEST(NestedHeapAssignment) { |
1770 CHECK_FUNC_ERROR( | 1792 CHECK_FUNC_ERROR( |
1771 "function bar() { var x = 0; i8[x = 1] = 2; }\n" | 1793 "function bar() { var x = 0; i16[x = 1] = 2; }\n" |
1772 "function foo() { bar(); }", | 1794 "function foo() { bar(); }", |
1773 "asm: line 39: expected >> in heap access\n"); | 1795 "asm: line 39: expected >> in heap access\n"); |
1774 } | 1796 } |
| 1797 |
| 1798 TEST(BadOperatorHeapAssignment) { |
| 1799 CHECK_FUNC_ERROR( |
| 1800 "function bar() { var x = 0; i16[x & 1] = 2; }\n" |
| 1801 "function foo() { bar(); }", |
| 1802 "asm: line 39: expected >> in heap access\n"); |
| 1803 } |
1775 | 1804 |
1776 | 1805 |
1777 TEST(BadArrayAssignment) { | 1806 TEST(BadArrayAssignment) { |
1778 CHECK_FUNC_ERROR( | 1807 CHECK_FUNC_ERROR( |
1779 "function bar() { i8[0] = 0.0; }\n" | 1808 "function bar() { i8[0] = 0.0; }\n" |
1780 "function foo() { bar(); }", | 1809 "function foo() { bar(); }", |
1781 "asm: line 39: illegal type in assignment\n"); | 1810 "asm: line 39: illegal type in assignment\n"); |
1782 } | 1811 } |
1783 | 1812 |
1784 | 1813 |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 } | 2270 } |
2242 // return { testFunc1: test1, testFunc2: test2 }; | 2271 // return { testFunc1: test1, testFunc2: test2 }; |
2243 CHECK_EXPR(ObjectLiteral, Bounds::Unbounded()) { | 2272 CHECK_EXPR(ObjectLiteral, Bounds::Unbounded()) { |
2244 CHECK_VAR(test1, FUNC_I_TYPE); | 2273 CHECK_VAR(test1, FUNC_I_TYPE); |
2245 CHECK_VAR(test2, FUNC_D_TYPE); | 2274 CHECK_VAR(test2, FUNC_D_TYPE); |
2246 } | 2275 } |
2247 } | 2276 } |
2248 } | 2277 } |
2249 CHECK_TYPES_END | 2278 CHECK_TYPES_END |
2250 } | 2279 } |
OLD | NEW |