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 // TODO(rmcilroy): Remove this define after this flag is turned on globally | 5 // TODO(rmcilroy): Remove this define after this flag is turned on globally |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 | 257 |
258 | 258 |
259 TEST(PrimitiveExpressions) { | 259 TEST(PrimitiveExpressions) { |
260 InitializedHandleScope handle_scope; | 260 InitializedHandleScope handle_scope; |
261 BytecodeGeneratorHelper helper; | 261 BytecodeGeneratorHelper helper; |
262 | 262 |
263 ExpectedSnippet<int> snippets[] = { | 263 ExpectedSnippet<int> snippets[] = { |
264 {"var x = 0; return x;", | 264 {"var x = 0; return x;", |
265 kPointerSize, | 265 kPointerSize, |
266 1, | 266 1, |
267 6, | 267 4, |
268 {B(LdaZero), // | 268 {B(LdaZero), // |
269 B(Star), R(0), // | 269 B(Star), R(0), // |
270 B(Ldar), R(0), // | |
271 B(Return)}, | 270 B(Return)}, |
272 0}, | 271 0}, |
273 {"var x = 0; return x + 3;", | 272 {"var x = 0; return x + 3;", |
274 kPointerSize, | 273 kPointerSize, |
275 1, | 274 1, |
276 8, | 275 8, |
277 {B(LdaZero), // | 276 {B(LdaZero), // |
278 B(Star), R(0), // | 277 B(Star), R(0), // |
279 B(LdaSmi8), U8(3), // | 278 B(LdaSmi8), U8(3), // |
280 B(Add), R(0), // | 279 B(Add), R(0), // |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 | 399 |
401 TEST(LogicalExpressions) { | 400 TEST(LogicalExpressions) { |
402 InitializedHandleScope handle_scope; | 401 InitializedHandleScope handle_scope; |
403 BytecodeGeneratorHelper helper; | 402 BytecodeGeneratorHelper helper; |
404 | 403 |
405 | 404 |
406 ExpectedSnippet<int> snippets[] = { | 405 ExpectedSnippet<int> snippets[] = { |
407 {"var x = 0; return x || 3;", | 406 {"var x = 0; return x || 3;", |
408 1 * kPointerSize, | 407 1 * kPointerSize, |
409 1, | 408 1, |
410 10, | 409 8, |
411 {B(LdaZero), // | 410 {B(LdaZero), // |
412 B(Star), R(0), // | 411 B(Star), R(0), // |
413 B(Ldar), R(0), // | |
414 B(JumpIfToBooleanTrue), U8(4), // | 412 B(JumpIfToBooleanTrue), U8(4), // |
415 B(LdaSmi8), U8(3), // | 413 B(LdaSmi8), U8(3), // |
416 B(Return)}, | 414 B(Return)}, |
417 0}, | 415 0}, |
418 {"var x = 0; return (x == 1) || 3;", | 416 {"var x = 0; return (x == 1) || 3;", |
419 1 * kPointerSize, | 417 1 * kPointerSize, |
420 1, | 418 1, |
421 12, | 419 12, |
422 {B(LdaZero), // | 420 {B(LdaZero), // |
423 B(Star), R(0), // | 421 B(Star), R(0), // |
424 B(LdaSmi8), U8(1), // | 422 B(LdaSmi8), U8(1), // |
425 B(TestEqual), R(0), // | 423 B(TestEqual), R(0), // |
426 B(JumpIfTrue), U8(4), // | 424 B(JumpIfTrue), U8(4), // |
427 B(LdaSmi8), U8(3), // | 425 B(LdaSmi8), U8(3), // |
428 B(Return)}, | 426 B(Return)}, |
429 0}, | 427 0}, |
430 {"var x = 0; return x && 3;", | 428 {"var x = 0; return x && 3;", |
431 1 * kPointerSize, | 429 1 * kPointerSize, |
432 1, | 430 1, |
433 10, | 431 8, |
434 {B(LdaZero), // | 432 {B(LdaZero), // |
435 B(Star), R(0), // | 433 B(Star), R(0), // |
436 B(Ldar), R(0), // | |
437 B(JumpIfToBooleanFalse), U8(4), // | 434 B(JumpIfToBooleanFalse), U8(4), // |
438 B(LdaSmi8), U8(3), // | 435 B(LdaSmi8), U8(3), // |
439 B(Return)}, | 436 B(Return)}, |
440 0}, | 437 0}, |
441 {"var x = 0; return (x == 0) && 3;", | 438 {"var x = 0; return (x == 0) && 3;", |
442 1 * kPointerSize, | 439 1 * kPointerSize, |
443 1, | 440 1, |
444 11, | 441 11, |
445 {B(LdaZero), // | 442 {B(LdaZero), // |
446 B(Star), R(0), // | 443 B(Star), R(0), // |
447 B(LdaZero), // | 444 B(LdaZero), // |
448 B(TestEqual), R(0), // | 445 B(TestEqual), R(0), // |
449 B(JumpIfFalse), U8(4), // | 446 B(JumpIfFalse), U8(4), // |
450 B(LdaSmi8), U8(3), // | 447 B(LdaSmi8), U8(3), // |
451 B(Return)}, | 448 B(Return)}, |
452 0}, | 449 0}, |
453 {"var x = 0; return x || (1, 2, 3);", | 450 {"var x = 0; return x || (1, 2, 3);", |
454 1 * kPointerSize, | 451 1 * kPointerSize, |
455 1, | 452 1, |
456 10, | 453 8, |
457 {B(LdaZero), // | 454 {B(LdaZero), // |
458 B(Star), R(0), // | 455 B(Star), R(0), // |
459 B(Ldar), R(0), // | |
460 B(JumpIfToBooleanTrue), U8(4), // | 456 B(JumpIfToBooleanTrue), U8(4), // |
461 B(LdaSmi8), U8(3), // | 457 B(LdaSmi8), U8(3), // |
462 B(Return)}, | 458 B(Return)}, |
463 0}, | 459 0}, |
464 {"var a = 2, b = 3, c = 4; return a || (a, b, a, b, c = 5, 3);", | 460 {"var a = 2, b = 3, c = 4; return a || (a, b, a, b, c = 5, 3);", |
465 3 * kPointerSize, | 461 3 * kPointerSize, |
466 1, | 462 1, |
467 23, | 463 23, |
468 {B(LdaSmi8), U8(2), // | 464 {B(LdaSmi8), U8(2), // |
469 B(Star), R(0), // | 465 B(Star), R(0), // |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 {"return 1 || 3;", | 578 {"return 1 || 3;", |
583 0 * kPointerSize, | 579 0 * kPointerSize, |
584 1, | 580 1, |
585 3, | 581 3, |
586 {B(LdaSmi8), U8(1), // | 582 {B(LdaSmi8), U8(1), // |
587 B(Return)}, | 583 B(Return)}, |
588 0}, | 584 0}, |
589 {"var x = 1; return x && 3 || 0, 1;", | 585 {"var x = 1; return x && 3 || 0, 1;", |
590 1 * kPointerSize, | 586 1 * kPointerSize, |
591 1, | 587 1, |
592 16, | 588 14, |
593 {B(LdaSmi8), U8(1), // | 589 {B(LdaSmi8), U8(1), // |
594 B(Star), R(0), // | 590 B(Star), R(0), // |
595 B(Ldar), R(0), // | |
596 B(JumpIfToBooleanFalse), U8(4), // | 591 B(JumpIfToBooleanFalse), U8(4), // |
597 B(LdaSmi8), U8(3), // | 592 B(LdaSmi8), U8(3), // |
598 B(JumpIfToBooleanTrue), U8(3), // | 593 B(JumpIfToBooleanTrue), U8(3), // |
599 B(LdaZero), // | 594 B(LdaZero), // |
600 B(LdaSmi8), U8(1), // | 595 B(LdaSmi8), U8(1), // |
601 B(Return)}, | 596 B(Return)}, |
602 0}}; | 597 0}}; |
603 | 598 |
604 for (size_t i = 0; i < arraysize(snippets); i++) { | 599 for (size_t i = 0; i < arraysize(snippets); i++) { |
605 Handle<BytecodeArray> bytecode_array = | 600 Handle<BytecodeArray> bytecode_array = |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1656 2, | 1651 2, |
1657 { | 1652 { |
1658 B(LdaUndefined), // | 1653 B(LdaUndefined), // |
1659 B(Return), // | 1654 B(Return), // |
1660 }, | 1655 }, |
1661 0, | 1656 0, |
1662 {unused, unused, unused, unused, unused, unused}}, | 1657 {unused, unused, unused, unused, unused, unused}}, |
1663 {"function f() { var a = 1; if (a) { a += 1; } else { return 2; } } f();", | 1658 {"function f() { var a = 1; if (a) { a += 1; } else { return 2; } } f();", |
1664 1 * kPointerSize, | 1659 1 * kPointerSize, |
1665 1, | 1660 1, |
1666 21, | 1661 19, |
1667 { | 1662 { |
1668 B(LdaSmi8), U8(1), // | 1663 B(LdaSmi8), U8(1), // |
1669 B(Star), R(0), // | 1664 B(Star), R(0), // |
1670 B(Ldar), R(0), // | |
1671 B(JumpIfToBooleanFalse), U8(10), // | 1665 B(JumpIfToBooleanFalse), U8(10), // |
1672 B(LdaSmi8), U8(1), // | 1666 B(LdaSmi8), U8(1), // |
1673 B(Add), R(0), // | 1667 B(Add), R(0), // |
1674 B(Star), R(0), // | 1668 B(Star), R(0), // |
1675 B(Jump), U8(5), // | 1669 B(Jump), U8(5), // |
1676 B(LdaSmi8), U8(2), // | 1670 B(LdaSmi8), U8(2), // |
1677 B(Return), // | 1671 B(Return), // |
1678 B(LdaUndefined), // | 1672 B(LdaUndefined), // |
1679 B(Return), // | 1673 B(Return), // |
1680 }, | 1674 }, |
(...skipping 30 matching lines...) Expand all Loading... | |
1711 B(JumpIfFalse), U8(5), // | 1705 B(JumpIfFalse), U8(5), // |
1712 B(LdaConstant), U8(0), // | 1706 B(LdaConstant), U8(0), // |
1713 B(Return), // | 1707 B(Return), // |
1714 B(LdaUndefined), // | 1708 B(LdaUndefined), // |
1715 B(Return), // | 1709 B(Return), // |
1716 }, | 1710 }, |
1717 1, | 1711 1, |
1718 {helper.factory()->NewNumberFromInt(200), unused, unused, unused, unused, | 1712 {helper.factory()->NewNumberFromInt(200), unused, unused, unused, unused, |
1719 unused}}, | 1713 unused}}, |
1720 {"function f(z) { var a = 0; var b = 0; if (a === 0.01) { " | 1714 {"function f(z) { var a = 0; var b = 0; if (a === 0.01) { " |
1721 REPEAT_32(SPACE, "b = a; a = b; ") | 1715 REPEAT_64(SPACE, "b = a; a = b; ") |
1722 " return 200; } else { return -200; } } f(0.001)", | 1716 " return 200; } else { return -200; } } f(0.001)", |
1723 2 * kPointerSize, | 1717 2 * kPointerSize, |
1724 2, | 1718 2, |
1725 276, | 1719 278, |
1726 { | 1720 { |
1727 B(LdaZero), // | 1721 B(LdaZero), // |
1728 B(Star), R(0), // | 1722 B(Star), R(0), // |
1729 B(LdaZero), // | 1723 B(LdaZero), // |
1730 B(Star), R(1), // | 1724 B(Star), R(1), // |
1731 B(LdaConstant), U8(0), // | 1725 B(LdaConstant), U8(0), // |
1732 B(TestEqualStrict), R(0), // | 1726 B(TestEqualStrict), R(0), // |
1733 B(JumpIfFalseConstant), U8(2), // | 1727 B(JumpIfFalseConstant), U8(2), // |
1734 REPEAT_32(COMMA, // | 1728 B(Ldar), R(0), // |
1735 B(Ldar), R(0), // | 1729 REPEAT_64(COMMA, // |
1736 B(Star), R(1), // | 1730 B(Star), R(1), // |
1737 B(Ldar), R(1), // | |
1738 B(Star), R(0)), // | 1731 B(Star), R(0)), // |
1739 B(LdaConstant), U8(1), // | 1732 B(LdaConstant), U8(1), // |
1740 B(Return), // | 1733 B(Return), // |
1741 B(LdaConstant), U8(3), // | 1734 B(LdaConstant), U8(3), // |
1742 B(Return), // | 1735 B(Return), // |
1743 B(LdaUndefined), // | 1736 B(LdaUndefined), // |
1744 B(Return)}, // | 1737 B(Return)}, // |
1745 4, | 1738 4, |
1746 {helper.factory()->NewHeapNumber(0.01), | 1739 {helper.factory()->NewHeapNumber(0.01), |
1747 helper.factory()->NewNumberFromInt(200), | 1740 helper.factory()->NewNumberFromInt(200), |
1748 helper.factory()->NewNumberFromInt(261), | 1741 helper.factory()->NewNumberFromInt(263), |
1749 helper.factory()->NewNumberFromInt(-200), unused, unused}}, | 1742 helper.factory()->NewNumberFromInt(-200), unused, unused}}, |
1750 {"function f() { var a = 0; var b = 0; if (a) { " | 1743 {"function f() { var a = 0; var b = 0; if (a) { " |
1751 REPEAT_32(SPACE, "b = a; a = b; ") | 1744 REPEAT_64(SPACE, "b = a; a = b; ") |
1752 " return 200; } else { return -200; } } f()", | 1745 " return 200; } else { return -200; } } f()", |
1753 2 * kPointerSize, | 1746 2 * kPointerSize, |
1754 1, | 1747 1, |
1755 274, | 1748 276, |
1756 { | 1749 { |
1757 B(LdaZero), // | 1750 B(LdaZero), // |
1758 B(Star), R(0), // | 1751 B(Star), R(0), // |
1759 B(LdaZero), // | 1752 B(LdaZero), // |
1760 B(Star), R(1), // | 1753 B(Star), R(1), // |
1761 B(Ldar), R(0), // | 1754 B(Ldar), R(0), // |
1762 B(JumpIfToBooleanFalseConstant), U8(1), // | 1755 B(JumpIfToBooleanFalseConstant), U8(1), // |
1763 REPEAT_32(COMMA, // | 1756 B(Ldar), R(0), // |
1764 B(Ldar), R(0), // | 1757 REPEAT_64(COMMA, // |
1765 B(Star), R(1), // | 1758 B(Star), R(1), // |
1766 B(Ldar), R(1), // | |
1767 B(Star), R(0)), // | 1759 B(Star), R(0)), // |
1768 B(LdaConstant), U8(0), // | 1760 B(LdaConstant), U8(0), // |
1769 B(Return), // | 1761 B(Return), // |
1770 B(LdaConstant), U8(2), // | 1762 B(LdaConstant), U8(2), // |
1771 B(Return), // | 1763 B(Return), // |
1772 B(LdaUndefined), // | 1764 B(LdaUndefined), // |
1773 B(Return)}, // | 1765 B(Return)}, // |
1774 3, | 1766 3, |
1775 {helper.factory()->NewNumberFromInt(200), | 1767 {helper.factory()->NewNumberFromInt(200), |
1776 helper.factory()->NewNumberFromInt(261), | 1768 helper.factory()->NewNumberFromInt(263), |
1777 helper.factory()->NewNumberFromInt(-200), unused, unused, unused}}, | 1769 helper.factory()->NewNumberFromInt(-200), unused, unused, unused}}, |
1778 | 1770 |
1779 {"function f(a, b) {\n" | 1771 {"function f(a, b) {\n" |
1780 " if (a == b) { return 1; }\n" | 1772 " if (a == b) { return 1; }\n" |
1781 " if (a === b) { return 1; }\n" | 1773 " if (a === b) { return 1; }\n" |
1782 " if (a < b) { return 1; }\n" | 1774 " if (a < b) { return 1; }\n" |
1783 " if (a > b) { return 1; }\n" | 1775 " if (a > b) { return 1; }\n" |
1784 " if (a <= b) { return 1; }\n" | 1776 " if (a <= b) { return 1; }\n" |
1785 " if (a >= b) { return 1; }\n" | 1777 " if (a >= b) { return 1; }\n" |
1786 " if (a in b) { return 1; }\n" | 1778 " if (a in b) { return 1; }\n" |
(...skipping 26 matching lines...) Expand all Loading... | |
1813 {"function f() {" | 1805 {"function f() {" |
1814 " var a = 0;" | 1806 " var a = 0;" |
1815 " if (a) {" | 1807 " if (a) {" |
1816 " return 20;" | 1808 " return 20;" |
1817 "} else {" | 1809 "} else {" |
1818 " return -20;}" | 1810 " return -20;}" |
1819 "};" | 1811 "};" |
1820 "f();", | 1812 "f();", |
1821 1 * kPointerSize, | 1813 1 * kPointerSize, |
1822 1, | 1814 1, |
1823 15, | 1815 13, |
1824 { | 1816 { |
1825 B(LdaZero), // | 1817 B(LdaZero), // |
1826 B(Star), R(0), // | 1818 B(Star), R(0), // |
1827 B(Ldar), R(0), // | |
1828 B(JumpIfToBooleanFalse), U8(5), // | 1819 B(JumpIfToBooleanFalse), U8(5), // |
1829 B(LdaSmi8), U8(20), // | 1820 B(LdaSmi8), U8(20), // |
1830 B(Return), // | 1821 B(Return), // |
1831 B(LdaSmi8), U8(-20), // | 1822 B(LdaSmi8), U8(-20), // |
1832 B(Return), // | 1823 B(Return), // |
1833 B(LdaUndefined), // | 1824 B(LdaUndefined), // |
1834 B(Return) | 1825 B(Return) |
1835 }, | 1826 }, |
1836 0, | 1827 0, |
1837 {unused, unused, unused, unused, unused, unused}} | 1828 {unused, unused, unused, unused, unused, unused}}}; |
1838 }; | |
1839 | 1829 |
1840 for (size_t i = 0; i < arraysize(snippets); i++) { | 1830 for (size_t i = 0; i < arraysize(snippets); i++) { |
1841 Handle<BytecodeArray> bytecode_array = | 1831 Handle<BytecodeArray> bytecode_array = |
1842 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 1832 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
1843 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1833 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
1844 } | 1834 } |
1845 } | 1835 } |
1846 | 1836 |
1847 | 1837 |
1848 TEST(DeclareGlobals) { | 1838 TEST(DeclareGlobals) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1900 B(Star), R(1), // | 1890 B(Star), R(1), // |
1901 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(0), U8(2), // | 1891 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(0), U8(2), // |
1902 B(LdaUndefined), // | 1892 B(LdaUndefined), // |
1903 B(Return) // | 1893 B(Return) // |
1904 }, | 1894 }, |
1905 1, | 1895 1, |
1906 {InstanceType::FIXED_ARRAY_TYPE}}, | 1896 {InstanceType::FIXED_ARRAY_TYPE}}, |
1907 {"var a = 1;\na=2;", | 1897 {"var a = 1;\na=2;", |
1908 4 * kPointerSize, | 1898 4 * kPointerSize, |
1909 1, | 1899 1, |
1910 38, | 1900 36, |
1911 { | 1901 { |
1912 B(LdaConstant), U8(0), // | 1902 B(LdaConstant), U8(0), // |
1913 B(Star), R(1), // | 1903 B(Star), R(1), // |
1914 B(LdaZero), // | 1904 B(LdaZero), // |
1915 B(Star), R(2), // | 1905 B(Star), R(2), // |
1916 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // | 1906 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // |
1917 B(LdaConstant), U8(1), // | 1907 B(LdaConstant), U8(1), // |
1918 B(Star), R(1), // | 1908 B(Star), R(1), // |
1919 B(LdaZero), // | 1909 B(LdaZero), // |
1920 B(Star), R(2), // | 1910 B(Star), R(2), // |
1921 B(LdaSmi8), U8(1), // | 1911 B(LdaSmi8), U8(1), // |
1922 B(Star), R(3), // | 1912 B(Star), R(3), // |
1923 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), // | 1913 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), // |
1924 B(LdaSmi8), U8(2), // | 1914 B(LdaSmi8), U8(2), // |
1925 B(StaGlobalSloppy), U8(1), // | 1915 B(StaGlobalSloppy), U8(1), // |
1926 U8(store_vector->GetIndex(store_slot_2)), // | 1916 U8(store_vector->GetIndex(store_slot_2)), // |
1927 B(Star), R(0), // | 1917 B(Star), R(0), // |
1928 B(Ldar), R(0), // | |
1929 B(Return) // | 1918 B(Return) // |
1930 }, | 1919 }, |
1931 2, | 1920 2, |
1932 {InstanceType::FIXED_ARRAY_TYPE, | 1921 {InstanceType::FIXED_ARRAY_TYPE, |
1933 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 1922 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
1934 {"function f() {}\nf();", | 1923 {"function f() {}\nf();", |
1935 3 * kPointerSize, | 1924 3 * kPointerSize, |
1936 1, | 1925 1, |
1937 29, | 1926 27, |
1938 { | 1927 { |
1939 B(LdaConstant), U8(0), // | 1928 B(LdaConstant), U8(0), // |
1940 B(Star), R(1), // | 1929 B(Star), R(1), // |
1941 B(LdaZero), // | 1930 B(LdaZero), // |
1942 B(Star), R(2), // | 1931 B(Star), R(2), // |
1943 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // | 1932 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // |
1944 B(LdaUndefined), // | 1933 B(LdaUndefined), // |
1945 B(Star), R(2), // | 1934 B(Star), R(2), // |
1946 B(LdaGlobalSloppy), U8(1), // | 1935 B(LdaGlobalSloppy), U8(1), // |
1947 U8(load_vector->GetIndex(load_slot_1)), // | 1936 U8(load_vector->GetIndex(load_slot_1)), // |
1948 B(Star), R(1), // | 1937 B(Star), R(1), // |
1949 B(Call), R(1), R(2), U8(0), // | 1938 B(Call), R(1), R(2), U8(0), // |
1950 B(Star), R(0), // | 1939 B(Star), R(0), // |
1951 B(Ldar), R(0), // | |
1952 B(Return) // | 1940 B(Return) // |
1953 }, | 1941 }, |
1954 2, | 1942 2, |
1955 {InstanceType::FIXED_ARRAY_TYPE, | 1943 {InstanceType::FIXED_ARRAY_TYPE, |
1956 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 1944 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
1957 }; | 1945 }; |
1958 | 1946 |
1959 for (size_t i = 0; i < arraysize(snippets); i++) { | 1947 for (size_t i = 0; i < arraysize(snippets); i++) { |
1960 Handle<BytecodeArray> bytecode_array = | 1948 Handle<BytecodeArray> bytecode_array = |
1961 helper.MakeTopLevelBytecode(snippets[i].code_snippet); | 1949 helper.MakeTopLevelBytecode(snippets[i].code_snippet); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2188 B(LdaSmi8), U8(1), // | 2176 B(LdaSmi8), U8(1), // |
2189 B(Sub), R(0), // | 2177 B(Sub), R(0), // |
2190 B(Star), R(0), // | 2178 B(Star), R(0), // |
2191 B(Ldar), R(0), // | 2179 B(Ldar), R(0), // |
2192 B(JumpIfToBooleanTrue), U8(-14), // | 2180 B(JumpIfToBooleanTrue), U8(-14), // |
2193 B(Ldar), R(1), // | 2181 B(Ldar), R(1), // |
2194 B(Return), // | 2182 B(Return), // |
2195 }, | 2183 }, |
2196 0}, | 2184 0}, |
2197 {"var x = 10;" | 2185 {"var x = 10;" |
2198 "var y = 1;" | 2186 "var y = 1;" |
2199 "do {" | 2187 "do {" |
2200 " y = y * 12;" | 2188 " y = y * 12;" |
2201 " x = x - 1;" | 2189 " x = x - 1;" |
2202 "} while(x);" | 2190 "} while(x);" |
2203 "return y;", | 2191 "return y;", |
2204 2 * kPointerSize, | 2192 2 * kPointerSize, |
2205 1, | 2193 1, |
2206 27, | 2194 27, |
2207 { | 2195 { |
2208 B(LdaSmi8), U8(10), // | 2196 B(LdaSmi8), U8(10), // |
2209 B(Star), R(0), // | 2197 B(Star), R(0), // |
2210 B(LdaSmi8), U8(1), // | 2198 B(LdaSmi8), U8(1), // |
2211 B(Star), R(1), // | 2199 B(Star), R(1), // |
2212 B(LdaSmi8), U8(12), // | 2200 B(LdaSmi8), U8(12), // |
2213 B(Mul), R(1), // | 2201 B(Mul), R(1), // |
2214 B(Star), R(1), // | 2202 B(Star), R(1), // |
2215 B(LdaSmi8), U8(1), // | 2203 B(LdaSmi8), U8(1), // |
2216 B(Sub), R(0), // | 2204 B(Sub), R(0), // |
2217 B(Star), R(0), // | 2205 B(Star), R(0), // |
2218 B(Ldar), R(0), // | 2206 B(Ldar), R(0), // |
2219 B(JumpIfToBooleanTrue), U8(-14), // | 2207 B(JumpIfToBooleanTrue), U8(-14), // |
2220 B(Ldar), R(1), // | 2208 B(Ldar), R(1), // |
2221 B(Return), // | 2209 B(Return), // |
2222 }, | 2210 }, |
2223 0}, | 2211 0}, |
2224 {"var y = 1;" | 2212 {"var y = 1;" |
2225 "for (var x = 10; x; --x) {" | 2213 "for (var x = 10; x; --x) {" |
2226 " y = y * 12;" | 2214 " y = y * 12;" |
2227 "}" | 2215 "}" |
2228 "return y;", | 2216 "return y;", |
2229 2 * kPointerSize, | 2217 2 * kPointerSize, |
2230 1, | 2218 1, |
2231 29, | 2219 29, |
2232 { | 2220 { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2317 B(Return), // | 2305 B(Return), // |
2318 }, | 2306 }, |
2319 0}, | 2307 0}, |
2320 {"var x = 0;" | 2308 {"var x = 0;" |
2321 "while(false) {" | 2309 "while(false) {" |
2322 " x = x + 1;" | 2310 " x = x + 1;" |
2323 "};" | 2311 "};" |
2324 "return x;", | 2312 "return x;", |
2325 1 * kPointerSize, | 2313 1 * kPointerSize, |
2326 1, | 2314 1, |
2327 6, | 2315 4, |
2328 { | 2316 { |
2329 B(LdaZero), // | 2317 B(LdaZero), // |
2330 B(Star), R(0), // | 2318 B(Star), R(0), // |
2331 B(Ldar), R(0), // | |
2332 B(Return), // | 2319 B(Return), // |
2333 }, | 2320 }, |
2334 0}, | 2321 0}, |
2335 {"var x = 0;" | 2322 {"var x = 0;" |
2336 "for( var i = 0; false; i++) {" | 2323 "for( var i = 0; false; i++) {" |
2337 " x = x + 1;" | 2324 " x = x + 1;" |
2338 "};" | 2325 "};" |
2339 "return x;", | 2326 "return x;", |
2340 2 * kPointerSize, | 2327 2 * kPointerSize, |
2341 1, | 2328 1, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2450 B(Mul), R(0), // | 2437 B(Mul), R(0), // |
2451 B(LdaUndefined), // | 2438 B(LdaUndefined), // |
2452 B(Return), // | 2439 B(Return), // |
2453 }, | 2440 }, |
2454 0}, | 2441 0}, |
2455 {"var x = 1234;" | 2442 {"var x = 1234;" |
2456 "var y = void (x * x - 1);" | 2443 "var y = void (x * x - 1);" |
2457 "return y;", | 2444 "return y;", |
2458 3 * kPointerSize, | 2445 3 * kPointerSize, |
2459 1, | 2446 1, |
2460 20, | 2447 16, |
2461 { | 2448 { |
2462 B(LdaConstant), U8(0), // | 2449 B(LdaConstant), U8(0), // |
2463 B(Star), R(0), // | 2450 B(Star), R(0), // |
2464 B(Ldar), R(0), // | |
2465 B(Mul), R(0), // | 2451 B(Mul), R(0), // |
2466 B(Star), R(2), // | 2452 B(Star), R(2), // |
2467 B(LdaSmi8), U8(1), // | 2453 B(LdaSmi8), U8(1), // |
2468 B(Sub), R(2), // | 2454 B(Sub), R(2), // |
2469 B(LdaUndefined), // | 2455 B(LdaUndefined), // |
2470 B(Star), R(1), // | 2456 B(Star), R(1), // |
2471 B(Ldar), R(1), // | |
2472 B(Return), // | 2457 B(Return), // |
2473 }, | 2458 }, |
2474 1, | 2459 1, |
2475 {1234}}, | 2460 {1234}}, |
2476 {"var x = 13;" | 2461 {"var x = 13;" |
2477 "return ~x;", | 2462 "return ~x;", |
2478 1 * kPointerSize, | 2463 1 * kPointerSize, |
2479 1, | 2464 1, |
2480 9, | 2465 9, |
2481 { | 2466 { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2532 Handle<i::TypeFeedbackVector> vector = | 2517 Handle<i::TypeFeedbackVector> vector = |
2533 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 2518 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
2534 | 2519 |
2535 ExpectedSnippet<const char*> snippets[] = { | 2520 ExpectedSnippet<const char*> snippets[] = { |
2536 {"function f() {\n" | 2521 {"function f() {\n" |
2537 " var x = 13;\n" | 2522 " var x = 13;\n" |
2538 " return typeof(x);\n" | 2523 " return typeof(x);\n" |
2539 "}; f();", | 2524 "}; f();", |
2540 kPointerSize, | 2525 kPointerSize, |
2541 1, | 2526 1, |
2542 8, | 2527 6, |
2543 { | 2528 { |
2544 B(LdaSmi8), U8(13), // | 2529 B(LdaSmi8), U8(13), // |
2545 B(Star), R(0), // TODO(oth): Ldar R(X) following Star R(X) | 2530 B(Star), R(0), // |
2546 B(Ldar), R(0), // could be culled in bytecode array builder. | |
2547 B(TypeOf), // | 2531 B(TypeOf), // |
2548 B(Return), // | 2532 B(Return), // |
2549 }}, | 2533 }}, |
2550 {"var x = 13;\n" | 2534 {"var x = 13;\n" |
2551 "function f() {\n" | 2535 "function f() {\n" |
2552 " return typeof(x);\n" | 2536 " return typeof(x);\n" |
2553 "}; f();", | 2537 "}; f();", |
2554 0, | 2538 0, |
2555 1, | 2539 1, |
2556 5, | 2540 5, |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3525 3, | 3509 3, |
3526 { | 3510 { |
3527 B(LdaConstant), U8(0), // | 3511 B(LdaConstant), U8(0), // |
3528 B(Throw), // | 3512 B(Throw), // |
3529 }, | 3513 }, |
3530 1, | 3514 1, |
3531 {"Error"}}, | 3515 {"Error"}}, |
3532 {"var a = 1; if (a) { throw 'Error'; };", | 3516 {"var a = 1; if (a) { throw 'Error'; };", |
3533 1 * kPointerSize, | 3517 1 * kPointerSize, |
3534 1, | 3518 1, |
3535 13, | 3519 11, |
3536 { | 3520 { |
3537 B(LdaSmi8), U8(1), // | 3521 B(LdaSmi8), U8(1), // |
3538 B(Star), R(0), // | 3522 B(Star), R(0), // |
3539 B(Ldar), R(0), // | |
3540 B(JumpIfToBooleanFalse), U8(5), // | 3523 B(JumpIfToBooleanFalse), U8(5), // |
3541 B(LdaConstant), U8(0), // | 3524 B(LdaConstant), U8(0), // |
3542 B(Throw), // | 3525 B(Throw), // |
3543 B(LdaUndefined), // | 3526 B(LdaUndefined), // |
3544 B(Return), // | 3527 B(Return), // |
3545 }, | 3528 }, |
3546 1, | 3529 1, |
3547 {"Error"}}, | 3530 {"Error"}}, |
3548 }; | 3531 }; |
3549 | 3532 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3917 | 3900 |
3918 int object_literal_flags = | 3901 int object_literal_flags = |
3919 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; | 3902 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; |
3920 int array_literal_flags = | 3903 int array_literal_flags = |
3921 ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements; | 3904 ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements; |
3922 | 3905 |
3923 ExpectedSnippet<InstanceType> snippets[] = { | 3906 ExpectedSnippet<InstanceType> snippets[] = { |
3924 {"var a = 1; return ++a;", | 3907 {"var a = 1; return ++a;", |
3925 1 * kPointerSize, | 3908 1 * kPointerSize, |
3926 1, | 3909 1, |
3927 11, | 3910 9, |
3928 { | 3911 { |
3929 B(LdaSmi8), U8(1), // | 3912 B(LdaSmi8), U8(1), // |
3930 B(Star), R(0), // | 3913 B(Star), R(0), // |
3931 B(Ldar), R(0), // | |
3932 B(ToNumber), // | 3914 B(ToNumber), // |
3933 B(Inc), // | 3915 B(Inc), // |
3934 B(Star), R(0), // | 3916 B(Star), R(0), // |
3935 B(Return), // | 3917 B(Return), // |
3936 }}, | 3918 }}, |
3937 {"var a = 1; return a++;", | 3919 {"var a = 1; return a++;", |
3938 2 * kPointerSize, | 3920 2 * kPointerSize, |
3939 1, | 3921 1, |
3940 15, | 3922 13, |
3941 { | 3923 { |
3942 B(LdaSmi8), U8(1), // | 3924 B(LdaSmi8), U8(1), // |
3943 B(Star), R(0), // | 3925 B(Star), R(0), // |
3944 B(Ldar), R(0), // | |
3945 B(ToNumber), // | 3926 B(ToNumber), // |
3946 B(Star), R(1), // | 3927 B(Star), R(1), // |
3947 B(Inc), // | 3928 B(Inc), // |
3948 B(Star), R(0), // | 3929 B(Star), R(0), // |
3949 B(Ldar), R(1), // | 3930 B(Ldar), R(1), // |
3950 B(Return), // | 3931 B(Return), // |
3951 }}, | 3932 }}, |
3952 {"var a = 1; return --a;", | 3933 {"var a = 1; return --a;", |
3953 1 * kPointerSize, | 3934 1 * kPointerSize, |
3954 1, | 3935 1, |
3955 11, | 3936 9, |
3956 { | 3937 { |
3957 B(LdaSmi8), U8(1), // | 3938 B(LdaSmi8), U8(1), // |
3958 B(Star), R(0), // | 3939 B(Star), R(0), // |
3959 B(Ldar), R(0), // | |
3960 B(ToNumber), // | 3940 B(ToNumber), // |
3961 B(Dec), // | 3941 B(Dec), // |
3962 B(Star), R(0), // | 3942 B(Star), R(0), // |
3963 B(Return), // | 3943 B(Return), // |
3964 }}, | 3944 }}, |
3965 {"var a = 1; return a--;", | 3945 {"var a = 1; return a--;", |
3966 2 * kPointerSize, | 3946 2 * kPointerSize, |
3967 1, | 3947 1, |
3968 15, | 3948 13, |
3969 { | 3949 { |
3970 B(LdaSmi8), U8(1), // | 3950 B(LdaSmi8), U8(1), // |
3971 B(Star), R(0), // | 3951 B(Star), R(0), // |
3972 B(Ldar), R(0), // | |
3973 B(ToNumber), // | 3952 B(ToNumber), // |
3974 B(Star), R(1), // | 3953 B(Star), R(1), // |
3975 B(Dec), // | 3954 B(Dec), // |
3976 B(Star), R(0), // | 3955 B(Star), R(0), // |
3977 B(Ldar), R(1), // | 3956 B(Ldar), R(1), // |
3978 B(Return), // | 3957 B(Return), // |
3979 }}, | 3958 }}, |
3980 {"var a = { val: 1 }; return a.val++;", | 3959 {"var a = { val: 1 }; return a.val++;", |
3981 2 * kPointerSize, | 3960 2 * kPointerSize, |
3982 1, | 3961 1, |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4390 FeedbackVectorSpec feedback_spec(&zone); | 4369 FeedbackVectorSpec feedback_spec(&zone); |
4391 FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot(); | 4370 FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot(); |
4392 | 4371 |
4393 Handle<i::TypeFeedbackVector> vector = | 4372 Handle<i::TypeFeedbackVector> vector = |
4394 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 4373 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
4395 | 4374 |
4396 ExpectedSnippet<const char*> snippets[] = { | 4375 ExpectedSnippet<const char*> snippets[] = { |
4397 {"function f() { return arguments; }", | 4376 {"function f() { return arguments; }", |
4398 1 * kPointerSize, | 4377 1 * kPointerSize, |
4399 1, | 4378 1, |
4400 6, | 4379 4, |
4401 { | 4380 { |
4402 B(CreateMappedArguments), // | 4381 B(CreateMappedArguments), // |
4403 B(Star), R(0), // | 4382 B(Star), R(0), // |
4404 B(Ldar), R(0), // | |
4405 B(Return), // | 4383 B(Return), // |
4406 }}, | 4384 }}, |
4407 {"function f() { return arguments[0]; }", | 4385 {"function f() { return arguments[0]; }", |
4408 1 * kPointerSize, | 4386 1 * kPointerSize, |
4409 1, | 4387 1, |
4410 8, | 4388 8, |
4411 { | 4389 { |
4412 B(CreateMappedArguments), // | 4390 B(CreateMappedArguments), // |
4413 B(Star), R(0), // | 4391 B(Star), R(0), // |
4414 B(LdaZero), // | 4392 B(LdaZero), // |
4415 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot)), // | 4393 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot)), // |
4416 B(Return), // | 4394 B(Return), // |
4417 }}, | 4395 }}, |
4418 {"function f() { 'use strict'; return arguments; }", | 4396 {"function f() { 'use strict'; return arguments; }", |
4419 1 * kPointerSize, | 4397 1 * kPointerSize, |
4420 1, | 4398 1, |
4421 6, | 4399 4, |
4422 { | 4400 { |
4423 B(CreateUnmappedArguments), // | 4401 B(CreateUnmappedArguments), // |
4424 B(Star), R(0), // | 4402 B(Star), R(0), // |
4425 B(Ldar), R(0), // | |
4426 B(Return), // | 4403 B(Return), // |
4427 }}, | 4404 }}, |
4428 {"function f(a) { return arguments[0]; }", | 4405 {"function f(a) { return arguments[0]; }", |
4429 2 * kPointerSize, | 4406 2 * kPointerSize, |
4430 2, | 4407 2, |
4431 20, | 4408 20, |
4432 { | 4409 { |
4433 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 4410 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
4434 U8(1), // | 4411 U8(1), // |
4435 B(PushContext), R(1), // | 4412 B(PushContext), R(1), // |
4436 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // | 4413 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // |
4437 B(StaContextSlot), R(1), U8(first_context_slot), // | 4414 B(StaContextSlot), R(1), U8(first_context_slot), // |
4438 B(CreateMappedArguments), // | 4415 B(CreateMappedArguments), // |
4439 B(Star), R(0), // | 4416 B(Star), R(0), // |
4440 B(LdaZero), // | 4417 B(LdaZero), // |
4441 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot)), // | 4418 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot)), // |
4442 B(Return), // | 4419 B(Return), // |
4443 }}, | 4420 }}, |
4444 {"function f(a, b, c) { return arguments; }", | 4421 {"function f(a, b, c) { return arguments; }", |
4445 2 * kPointerSize, | 4422 2 * kPointerSize, |
4446 4, | 4423 4, |
4447 28, | 4424 26, |
4448 { | 4425 { |
4449 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 4426 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
4450 U8(1), // | 4427 U8(1), // |
4451 B(PushContext), R(1), // | 4428 B(PushContext), R(1), // |
4452 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 2), // | 4429 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 2), // |
4453 B(StaContextSlot), R(1), U8(first_context_slot + 2), // | 4430 B(StaContextSlot), R(1), U8(first_context_slot + 2), // |
4454 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 1), // | 4431 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 1), // |
4455 B(StaContextSlot), R(1), U8(first_context_slot + 1), // | 4432 B(StaContextSlot), R(1), U8(first_context_slot + 1), // |
4456 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // | 4433 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // |
4457 B(StaContextSlot), R(1), U8(first_context_slot), // | 4434 B(StaContextSlot), R(1), U8(first_context_slot), // |
4458 B(CreateMappedArguments), // | 4435 B(CreateMappedArguments), // |
4459 B(Star), R(0), // | 4436 B(Star), R(0), // |
4460 B(Ldar), R(0), // | |
4461 B(Return), // | 4437 B(Return), // |
4462 }}, | 4438 }}, |
4463 {"function f(a, b, c) { 'use strict'; return arguments; }", | 4439 {"function f(a, b, c) { 'use strict'; return arguments; }", |
4464 1 * kPointerSize, | 4440 1 * kPointerSize, |
4465 4, | 4441 4, |
4466 6, | 4442 4, |
4467 { | 4443 { |
4468 B(CreateUnmappedArguments), // | 4444 B(CreateUnmappedArguments), // |
4469 B(Star), R(0), // | 4445 B(Star), R(0), // |
4470 B(Ldar), R(0), // | |
4471 B(Return), // | 4446 B(Return), // |
4472 }}, | 4447 }}, |
4473 }; | 4448 }; |
4474 | 4449 |
4475 for (size_t i = 0; i < arraysize(snippets); i++) { | 4450 for (size_t i = 0; i < arraysize(snippets); i++) { |
4476 Handle<BytecodeArray> bytecode_array = | 4451 Handle<BytecodeArray> bytecode_array = |
4477 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 4452 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
4478 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 4453 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
4479 } | 4454 } |
4480 } | 4455 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4537 {"for (var p in undefined) {}", | 4512 {"for (var p in undefined) {}", |
4538 2 * kPointerSize, | 4513 2 * kPointerSize, |
4539 1, | 4514 1, |
4540 2, | 4515 2, |
4541 {B(LdaUndefined), B(Return)}, | 4516 {B(LdaUndefined), B(Return)}, |
4542 0}, | 4517 0}, |
4543 {"var x = 'potatoes';\n" | 4518 {"var x = 'potatoes';\n" |
4544 "for (var p in x) { return p; }", | 4519 "for (var p in x) { return p; }", |
4545 5 * kPointerSize, | 4520 5 * kPointerSize, |
4546 1, | 4521 1, |
4547 52, | 4522 46, |
4548 { | 4523 { |
4549 B(LdaConstant), U8(0), // | 4524 B(LdaConstant), U8(0), // |
4550 B(Star), R(1), // | 4525 B(Star), R(1), // |
4551 B(Ldar), R(1), // | 4526 B(JumpIfUndefined), U8(40), // |
4552 B(JumpIfUndefined), U8(44), // | 4527 B(JumpIfNull), U8(38), // |
4553 B(JumpIfNull), U8(42), // | |
4554 B(ToObject), // | 4528 B(ToObject), // |
4555 B(Star), R(3), // | 4529 B(Star), R(3), // |
4556 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // | 4530 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // |
4557 B(ForInPrepare), R(3), // | 4531 B(ForInPrepare), R(3), // |
4558 B(JumpIfUndefined), U8(30), // | 4532 B(JumpIfUndefined), U8(26), // |
4559 B(Star), R(4), // | 4533 B(Star), R(4), // |
4560 B(LdaZero), // | 4534 B(LdaZero), // |
4561 B(Star), R(3), // | 4535 B(Star), R(3), // |
4562 B(ForInDone), R(4), // | 4536 B(ForInDone), R(4), // |
4563 B(JumpIfTrue), U8(21), // | 4537 B(JumpIfTrue), U8(17), // |
4564 B(ForInNext), R(4), R(3), // | 4538 B(ForInNext), R(4), R(3), // |
4565 B(JumpIfUndefined), U8(11), // | 4539 B(JumpIfUndefined), U8(7), // |
4566 B(Star), R(0), // | 4540 B(Star), R(0), // |
4567 B(Ldar), R(0), // | |
4568 B(Star), R(2), // | 4541 B(Star), R(2), // |
4569 B(Ldar), R(2), // | |
4570 B(Return), // | 4542 B(Return), // |
4571 B(Ldar), R(3), // | 4543 B(Ldar), R(3), // |
4572 B(Inc), // | 4544 B(Inc), // |
4573 B(Jump), U8(-23), // | 4545 B(Jump), U8(-19), // |
4574 B(LdaUndefined), // | 4546 B(LdaUndefined), // |
4575 B(Return), // | 4547 B(Return), // |
4576 }, | 4548 }, |
4577 1, | 4549 1, |
4578 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 4550 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
4579 {"var x = 0;\n" | 4551 {"var x = 0;\n" |
4580 "for (var p in [1,2,3]) { x += p; }", | 4552 "for (var p in [1,2,3]) { x += p; }", |
4581 5 * kPointerSize, | 4553 5 * kPointerSize, |
4582 1, | 4554 1, |
4583 57, | 4555 53, |
4584 { | 4556 { |
4585 B(LdaZero), // | 4557 B(LdaZero), // |
4586 B(Star), R(1), // | 4558 B(Star), R(1), // |
4587 B(LdaConstant), U8(0), // | 4559 B(LdaConstant), U8(0), // |
4588 B(CreateArrayLiteral), U8(0), U8(simple_flags), // | 4560 B(CreateArrayLiteral), U8(0), U8(simple_flags), // |
4589 B(JumpIfUndefined), U8(47), // | 4561 B(JumpIfUndefined), U8(43), // |
4590 B(JumpIfNull), U8(45), // | 4562 B(JumpIfNull), U8(41), // |
4591 B(ToObject), // | 4563 B(ToObject), // |
4592 B(Star), R(3), // | 4564 B(Star), R(3), // |
4593 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // | 4565 B(CallRuntime), U16(Runtime::kGetPropertyNamesFast), R(3), U8(1), // |
4594 B(ForInPrepare), R(3), // | 4566 B(ForInPrepare), R(3), // |
4595 B(JumpIfUndefined), U8(33), // | 4567 B(JumpIfUndefined), U8(29), // |
4596 B(Star), R(4), // | 4568 B(Star), R(4), // |
4597 B(LdaZero), // | 4569 B(LdaZero), // |
4598 B(Star), R(3), // | 4570 B(Star), R(3), // |
4599 B(ForInDone), R(4), // | 4571 B(ForInDone), R(4), // |
4600 B(JumpIfTrue), U8(24), // | 4572 B(JumpIfTrue), U8(20), // |
4601 B(ForInNext), R(4), R(3), // | 4573 B(ForInNext), R(4), R(3), // |
4602 B(JumpIfUndefined), U8(14), // | 4574 B(JumpIfUndefined), U8(10), // |
4603 B(Star), R(0), // | 4575 B(Star), R(0), // |
4604 B(Ldar), R(0), // | |
4605 B(Star), R(2), // | 4576 B(Star), R(2), // |
4606 B(Ldar), R(2), // | |
4607 B(Add), R(1), // | 4577 B(Add), R(1), // |
4608 B(Star), R(1), // | 4578 B(Star), R(1), // |
4609 B(Ldar), R(3), // | 4579 B(Ldar), R(3), // |
4610 B(Inc), // | 4580 B(Inc), // |
4611 B(Jump), U8(-26), // | 4581 B(Jump), U8(-22), // |
4612 B(LdaUndefined), // | 4582 B(LdaUndefined), // |
4613 B(Return), // | 4583 B(Return), // |
4614 }, | 4584 }, |
4615 1, | 4585 1, |
4616 {InstanceType::FIXED_ARRAY_TYPE}}, | 4586 {InstanceType::FIXED_ARRAY_TYPE}}, |
4617 {"var x = { 'a': 1, 'b': 2 };\n" | 4587 {"var x = { 'a': 1, 'b': 2 };\n" |
4618 "for (x['a'] in [10, 20, 30]) {\n" | 4588 "for (x['a'] in [10, 20, 30]) {\n" |
4619 " if (x['a'] == 10) continue;\n" | 4589 " if (x['a'] == 10) continue;\n" |
4620 " if (x['a'] == 20) break;\n" | 4590 " if (x['a'] == 20) break;\n" |
4621 "}", | 4591 "}", |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4764 BytecodeGeneratorHelper helper; | 4734 BytecodeGeneratorHelper helper; |
4765 | 4735 |
4766 ExpectedSnippet<int> snippets[] = { | 4736 ExpectedSnippet<int> snippets[] = { |
4767 {"var a = 1;\n" | 4737 {"var a = 1;\n" |
4768 "switch(a) {\n" | 4738 "switch(a) {\n" |
4769 " case 1: return 2;\n" | 4739 " case 1: return 2;\n" |
4770 " case 2: return 3;\n" | 4740 " case 2: return 3;\n" |
4771 "}\n", | 4741 "}\n", |
4772 2 * kPointerSize, | 4742 2 * kPointerSize, |
4773 1, | 4743 1, |
4774 30, | 4744 28, |
4775 { | 4745 { |
4776 B(LdaSmi8), U8(1), // | 4746 B(LdaSmi8), U8(1), // |
4777 B(Star), R(1), // The tag variable is allocated as a | 4747 B(Star), R(1), // The tag variable is allocated as a |
4778 B(Ldar), R(1), // local by the parser, hence this | 4748 B(Star), R(0), // local by the parser, hence this |
4779 B(Star), R(0), // strange shuffling. | 4749 B(LdaSmi8), U8(1), // strange shuffling. |
rmcilroy
2015/11/12 14:24:26
Update the comment - "hence the store to another l
mythria
2015/11/13 10:14:37
Done.
| |
4780 B(LdaSmi8), U8(1), // | |
4781 B(TestEqualStrict), R(0), // | 4750 B(TestEqualStrict), R(0), // |
4782 B(JumpIfTrue), U8(10), // | 4751 B(JumpIfTrue), U8(10), // |
4783 B(LdaSmi8), U8(2), // | 4752 B(LdaSmi8), U8(2), // |
4784 B(TestEqualStrict), R(0), // | 4753 B(TestEqualStrict), R(0), // |
4785 B(JumpIfTrue), U8(7), // | 4754 B(JumpIfTrue), U8(7), // |
4786 B(Jump), U8(8), // | 4755 B(Jump), U8(8), // |
4787 B(LdaSmi8), U8(2), // | 4756 B(LdaSmi8), U8(2), // |
4788 B(Return), // | 4757 B(Return), // |
4789 B(LdaSmi8), U8(3), // | 4758 B(LdaSmi8), U8(3), // |
4790 B(Return), // | 4759 B(Return), // |
4791 B(LdaUndefined), // | 4760 B(LdaUndefined), // |
4792 B(Return), // | 4761 B(Return), // |
4793 }}, | 4762 }}, |
4794 {"var a = 1;\n" | 4763 {"var a = 1;\n" |
4795 "switch(a) {\n" | 4764 "switch(a) {\n" |
4796 " case 1: a = 2; break;\n" | 4765 " case 1: a = 2; break;\n" |
4797 " case 2: a = 3; break;\n" | 4766 " case 2: a = 3; break;\n" |
4798 "}\n", | 4767 "}\n", |
4799 2 * kPointerSize, | 4768 2 * kPointerSize, |
4800 1, | 4769 1, |
4801 36, | 4770 34, |
4802 { | 4771 { |
4803 B(LdaSmi8), U8(1), // | 4772 B(LdaSmi8), U8(1), // |
4804 B(Star), R(1), // | 4773 B(Star), R(1), // |
4805 B(Ldar), R(1), // | |
4806 B(Star), R(0), // | 4774 B(Star), R(0), // |
4807 B(LdaSmi8), U8(1), // | 4775 B(LdaSmi8), U8(1), // |
4808 B(TestEqualStrict), R(0), // | 4776 B(TestEqualStrict), R(0), // |
4809 B(JumpIfTrue), U8(10), // | 4777 B(JumpIfTrue), U8(10), // |
4810 B(LdaSmi8), U8(2), // | 4778 B(LdaSmi8), U8(2), // |
4811 B(TestEqualStrict), R(0), // | 4779 B(TestEqualStrict), R(0), // |
4812 B(JumpIfTrue), U8(10), // | 4780 B(JumpIfTrue), U8(10), // |
4813 B(Jump), U8(14), // | 4781 B(Jump), U8(14), // |
4814 B(LdaSmi8), U8(2), // | 4782 B(LdaSmi8), U8(2), // |
4815 B(Star), R(1), // | 4783 B(Star), R(1), // |
4816 B(Jump), U8(8), // | 4784 B(Jump), U8(8), // |
4817 B(LdaSmi8), U8(3), // | 4785 B(LdaSmi8), U8(3), // |
4818 B(Star), R(1), // | 4786 B(Star), R(1), // |
4819 B(Jump), U8(2), // | 4787 B(Jump), U8(2), // |
4820 B(LdaUndefined), // | 4788 B(LdaUndefined), // |
4821 B(Return), // | 4789 B(Return), // |
4822 }}, | 4790 }}, |
4823 {"var a = 1;\n" | 4791 {"var a = 1;\n" |
4824 "switch(a) {\n" | 4792 "switch(a) {\n" |
4825 " case 1: a = 2; // fall-through\n" | 4793 " case 1: a = 2; // fall-through\n" |
4826 " case 2: a = 3; break;\n" | 4794 " case 2: a = 3; break;\n" |
4827 "}\n", | 4795 "}\n", |
4828 2 * kPointerSize, | 4796 2 * kPointerSize, |
4829 1, | 4797 1, |
4830 34, | 4798 32, |
4831 { | 4799 { |
4832 B(LdaSmi8), U8(1), // | 4800 B(LdaSmi8), U8(1), // |
4833 B(Star), R(1), // | 4801 B(Star), R(1), // |
4834 B(Ldar), R(1), // | |
4835 B(Star), R(0), // | 4802 B(Star), R(0), // |
4836 B(LdaSmi8), U8(1), // | 4803 B(LdaSmi8), U8(1), // |
4837 B(TestEqualStrict), R(0), // | 4804 B(TestEqualStrict), R(0), // |
4838 B(JumpIfTrue), U8(10), // | 4805 B(JumpIfTrue), U8(10), // |
4839 B(LdaSmi8), U8(2), // | 4806 B(LdaSmi8), U8(2), // |
4840 B(TestEqualStrict), R(0), // | 4807 B(TestEqualStrict), R(0), // |
4841 B(JumpIfTrue), U8(8), // | 4808 B(JumpIfTrue), U8(8), // |
4842 B(Jump), U8(12), // | 4809 B(Jump), U8(12), // |
4843 B(LdaSmi8), U8(2), // | 4810 B(LdaSmi8), U8(2), // |
4844 B(Star), R(1), // | 4811 B(Star), R(1), // |
4845 B(LdaSmi8), U8(3), // | 4812 B(LdaSmi8), U8(3), // |
4846 B(Star), R(1), // | 4813 B(Star), R(1), // |
4847 B(Jump), U8(2), // | 4814 B(Jump), U8(2), // |
4848 B(LdaUndefined), // | 4815 B(LdaUndefined), // |
4849 B(Return), // | 4816 B(Return), // |
4850 }}, | 4817 }}, |
4851 {"var a = 1;\n" | 4818 {"var a = 1;\n" |
4852 "switch(a) {\n" | 4819 "switch(a) {\n" |
4853 " case 2: break;\n" | 4820 " case 2: break;\n" |
4854 " case 3: break;\n" | 4821 " case 3: break;\n" |
4855 " default: a = 1; break;\n" | 4822 " default: a = 1; break;\n" |
4856 "}\n", | 4823 "}\n", |
4857 2 * kPointerSize, | 4824 2 * kPointerSize, |
4858 1, | 4825 1, |
4859 34, | 4826 32, |
4860 { | 4827 { |
4861 B(LdaSmi8), U8(1), // | 4828 B(LdaSmi8), U8(1), // |
4862 B(Star), R(1), // | 4829 B(Star), R(1), // |
4863 B(Ldar), R(1), // | |
4864 B(Star), R(0), // | 4830 B(Star), R(0), // |
4865 B(LdaSmi8), U8(2), // | 4831 B(LdaSmi8), U8(2), // |
4866 B(TestEqualStrict), R(0), // | 4832 B(TestEqualStrict), R(0), // |
4867 B(JumpIfTrue), U8(10), // | 4833 B(JumpIfTrue), U8(10), // |
4868 B(LdaSmi8), U8(3), // | 4834 B(LdaSmi8), U8(3), // |
4869 B(TestEqualStrict), R(0), // | 4835 B(TestEqualStrict), R(0), // |
4870 B(JumpIfTrue), U8(6), // | 4836 B(JumpIfTrue), U8(6), // |
4871 B(Jump), U8(6), // | 4837 B(Jump), U8(6), // |
4872 B(Jump), U8(10), // | 4838 B(Jump), U8(10), // |
4873 B(Jump), U8(8), // | 4839 B(Jump), U8(8), // |
4874 B(LdaSmi8), U8(1), // | 4840 B(LdaSmi8), U8(1), // |
4875 B(Star), R(1), // | 4841 B(Star), R(1), // |
4876 B(Jump), U8(2), // | 4842 B(Jump), U8(2), // |
4877 B(LdaUndefined), // | 4843 B(LdaUndefined), // |
4878 B(Return), // | 4844 B(Return), // |
4879 }}, | 4845 }}, |
4880 {"var a = 1;\n" | 4846 {"var a = 1;\n" |
4881 "switch(typeof(a)) {\n" | 4847 "switch(typeof(a)) {\n" |
4882 " case 2: a = 1; break;\n" | 4848 " case 2: a = 1; break;\n" |
4883 " case 3: a = 2; break;\n" | 4849 " case 3: a = 2; break;\n" |
4884 " default: a = 3; break;\n" | 4850 " default: a = 3; break;\n" |
4885 "}\n", | 4851 "}\n", |
4886 2 * kPointerSize, | 4852 2 * kPointerSize, |
4887 1, | 4853 1, |
4888 43, | 4854 41, |
4889 { | 4855 { |
4890 B(LdaSmi8), U8(1), // | 4856 B(LdaSmi8), U8(1), // |
4891 B(Star), R(1), // | 4857 B(Star), R(1), // |
4892 B(Ldar), R(1), // | |
4893 B(TypeOf), // | 4858 B(TypeOf), // |
4894 B(Star), R(0), // | 4859 B(Star), R(0), // |
4895 B(LdaSmi8), U8(2), // | 4860 B(LdaSmi8), U8(2), // |
4896 B(TestEqualStrict), R(0), // | 4861 B(TestEqualStrict), R(0), // |
4897 B(JumpIfTrue), U8(10), // | 4862 B(JumpIfTrue), U8(10), // |
4898 B(LdaSmi8), U8(3), // | 4863 B(LdaSmi8), U8(3), // |
4899 B(TestEqualStrict), R(0), // | 4864 B(TestEqualStrict), R(0), // |
4900 B(JumpIfTrue), U8(10), // | 4865 B(JumpIfTrue), U8(10), // |
4901 B(Jump), U8(14), // | 4866 B(Jump), U8(14), // |
4902 B(LdaSmi8), U8(1), // | 4867 B(LdaSmi8), U8(1), // |
4903 B(Star), R(1), // | 4868 B(Star), R(1), // |
4904 B(Jump), U8(14), // | 4869 B(Jump), U8(14), // |
4905 B(LdaSmi8), U8(2), // | 4870 B(LdaSmi8), U8(2), // |
4906 B(Star), R(1), // | 4871 B(Star), R(1), // |
4907 B(Jump), U8(8), // | 4872 B(Jump), U8(8), // |
4908 B(LdaSmi8), U8(3), // | 4873 B(LdaSmi8), U8(3), // |
4909 B(Star), R(1), // | 4874 B(Star), R(1), // |
4910 B(Jump), U8(2), // | 4875 B(Jump), U8(2), // |
4911 B(LdaUndefined), // | 4876 B(LdaUndefined), // |
4912 B(Return), // | 4877 B(Return), // |
4913 }}, | 4878 }}, |
4914 {"var a = 1;\n" | 4879 {"var a = 1;\n" |
4915 "switch(a) {\n" | 4880 "switch(a) {\n" |
4916 " case typeof(a): a = 1; break;\n" | 4881 " case typeof(a): a = 1; break;\n" |
4917 " default: a = 2; break;\n" | 4882 " default: a = 2; break;\n" |
4918 "}\n", | 4883 "}\n", |
4919 2 * kPointerSize, | 4884 2 * kPointerSize, |
4920 1, | 4885 1, |
4921 31, | 4886 29, |
4922 { | 4887 { |
4923 B(LdaSmi8), U8(1), // | 4888 B(LdaSmi8), U8(1), // |
4924 B(Star), R(1), // | 4889 B(Star), R(1), // |
4925 B(Ldar), R(1), // | |
4926 B(Star), R(0), // | 4890 B(Star), R(0), // |
4927 B(Ldar), R(1), // | 4891 B(Ldar), R(1), // |
4928 B(TypeOf), // | 4892 B(TypeOf), // |
4929 B(TestEqualStrict), R(0), // | 4893 B(TestEqualStrict), R(0), // |
4930 B(JumpIfTrue), U8(4), // | 4894 B(JumpIfTrue), U8(4), // |
4931 B(Jump), U8(8), // | 4895 B(Jump), U8(8), // |
4932 B(LdaSmi8), U8(1), // | 4896 B(LdaSmi8), U8(1), // |
4933 B(Star), R(1), // | 4897 B(Star), R(1), // |
4934 B(Jump), U8(8), // | 4898 B(Jump), U8(8), // |
4935 B(LdaSmi8), U8(2), // | 4899 B(LdaSmi8), U8(2), // |
4936 B(Star), R(1), // | 4900 B(Star), R(1), // |
4937 B(Jump), U8(2), // | 4901 B(Jump), U8(2), // |
4938 B(LdaUndefined), // | 4902 B(LdaUndefined), // |
4939 B(Return), // | 4903 B(Return), // |
4940 }}, | 4904 }}, |
4941 {"var a = 1;\n" | 4905 {"var a = 1;\n" |
4942 "switch(a) {\n" | 4906 "switch(a) {\n" |
4943 " case 1:\n" REPEAT_64(SPACE, " a = 2;") | 4907 " case 1:\n" REPEAT_64(SPACE, " a = 2;") |
4944 "break;\n" | 4908 "break;\n" |
4945 " case 2: a = 3; break;" | 4909 " case 2: a = 3; break;" |
4946 "}\n", | 4910 "}\n", |
4947 2 * kPointerSize, | 4911 2 * kPointerSize, |
4948 1, | 4912 1, |
4949 288, | 4913 286, |
4950 { | 4914 { |
4951 B(LdaSmi8), U8(1), // | 4915 B(LdaSmi8), U8(1), // |
4952 B(Star), R(1), // | 4916 B(Star), R(1), // |
4953 B(Ldar), R(1), // | |
4954 B(Star), R(0), // | 4917 B(Star), R(0), // |
4955 B(LdaSmi8), U8(1), // | 4918 B(LdaSmi8), U8(1), // |
4956 B(TestEqualStrict), R(0), // | 4919 B(TestEqualStrict), R(0), // |
4957 B(JumpIfTrue), U8(10), // | 4920 B(JumpIfTrue), U8(10), // |
4958 B(LdaSmi8), U8(2), // | 4921 B(LdaSmi8), U8(2), // |
4959 B(TestEqualStrict), R(0), // | 4922 B(TestEqualStrict), R(0), // |
4960 B(JumpIfTrueConstant), U8(0), // | 4923 B(JumpIfTrueConstant), U8(0), // |
4961 B(JumpConstant), U8(1), // | 4924 B(JumpConstant), U8(1), // |
4962 REPEAT_64(COMMA, // | 4925 REPEAT_64(COMMA, // |
4963 B(LdaSmi8), U8(2), // | 4926 B(LdaSmi8), U8(2), // |
(...skipping 11 matching lines...) Expand all Loading... | |
4975 "switch(a) {\n" | 4938 "switch(a) {\n" |
4976 " case 1: \n" | 4939 " case 1: \n" |
4977 " switch(a + 1) {\n" | 4940 " switch(a + 1) {\n" |
4978 " case 2 : a = 1; break;\n" | 4941 " case 2 : a = 1; break;\n" |
4979 " default : a = 2; break;\n" | 4942 " default : a = 2; break;\n" |
4980 " } // fall-through\n" | 4943 " } // fall-through\n" |
4981 " case 2: a = 3;\n" | 4944 " case 2: a = 3;\n" |
4982 "}\n", | 4945 "}\n", |
4983 3 * kPointerSize, | 4946 3 * kPointerSize, |
4984 1, | 4947 1, |
4985 54, | 4948 52, |
4986 { | 4949 { |
4987 B(LdaSmi8), U8(1), // | 4950 B(LdaSmi8), U8(1), // |
4988 B(Star), R(2), // | 4951 B(Star), R(2), // |
4989 B(Ldar), R(2), // | |
4990 B(Star), R(0), // | 4952 B(Star), R(0), // |
4991 B(LdaSmi8), U8(1), // | 4953 B(LdaSmi8), U8(1), // |
4992 B(TestEqualStrict), R(0), // | 4954 B(TestEqualStrict), R(0), // |
4993 B(JumpIfTrue), U8(10), // | 4955 B(JumpIfTrue), U8(10), // |
4994 B(LdaSmi8), U8(2), // | 4956 B(LdaSmi8), U8(2), // |
4995 B(TestEqualStrict), R(0), // | 4957 B(TestEqualStrict), R(0), // |
4996 B(JumpIfTrue), U8(30), // | 4958 B(JumpIfTrue), U8(30), // |
4997 B(Jump), U8(32), // | 4959 B(Jump), U8(32), // |
4998 B(LdaSmi8), U8(1), // | 4960 B(LdaSmi8), U8(1), // |
4999 B(Add), R(2), // | 4961 B(Add), R(2), // |
(...skipping 26 matching lines...) Expand all Loading... | |
5026 TEST(BasicBlockToBoolean) { | 4988 TEST(BasicBlockToBoolean) { |
5027 InitializedHandleScope handle_scope; | 4989 InitializedHandleScope handle_scope; |
5028 BytecodeGeneratorHelper helper; | 4990 BytecodeGeneratorHelper helper; |
5029 | 4991 |
5030 // Check that we don't omit ToBoolean calls if they are at the start of basic | 4992 // Check that we don't omit ToBoolean calls if they are at the start of basic |
5031 // blocks. | 4993 // blocks. |
5032 ExpectedSnippet<int> snippets[] = { | 4994 ExpectedSnippet<int> snippets[] = { |
5033 {"var a = 1; if (a || a < 0) { return 1; }", | 4995 {"var a = 1; if (a || a < 0) { return 1; }", |
5034 1 * kPointerSize, | 4996 1 * kPointerSize, |
5035 1, | 4997 1, |
5036 18, | 4998 16, |
5037 { | 4999 { |
5038 B(LdaSmi8), U8(1), // | 5000 B(LdaSmi8), U8(1), // |
5039 B(Star), R(0), // | 5001 B(Star), R(0), // |
5040 B(Ldar), R(0), // | |
5041 B(JumpIfToBooleanTrue), U8(5), // | 5002 B(JumpIfToBooleanTrue), U8(5), // |
5042 B(LdaZero), // | 5003 B(LdaZero), // |
5043 B(TestLessThan), R(0), // | 5004 B(TestLessThan), R(0), // |
5044 B(JumpIfToBooleanFalse), U8(5), // | 5005 B(JumpIfToBooleanFalse), U8(5), // |
5045 B(LdaSmi8), U8(1), // | 5006 B(LdaSmi8), U8(1), // |
5046 B(Return), // | 5007 B(Return), // |
5047 B(LdaUndefined), // | 5008 B(LdaUndefined), // |
5048 B(Return), // | 5009 B(Return), // |
5049 }}, | 5010 }}, |
5050 {"var a = 1; if (a && a < 0) { return 1; }", | 5011 {"var a = 1; if (a && a < 0) { return 1; }", |
5051 1 * kPointerSize, | 5012 1 * kPointerSize, |
5052 1, | 5013 1, |
5053 18, | 5014 16, |
5054 { | 5015 { |
5055 B(LdaSmi8), U8(1), // | 5016 B(LdaSmi8), U8(1), // |
5056 B(Star), R(0), // | 5017 B(Star), R(0), // |
5057 B(Ldar), R(0), // | |
5058 B(JumpIfToBooleanFalse), U8(5), // | 5018 B(JumpIfToBooleanFalse), U8(5), // |
5059 B(LdaZero), // | 5019 B(LdaZero), // |
5060 B(TestLessThan), R(0), // | 5020 B(TestLessThan), R(0), // |
5061 B(JumpIfToBooleanFalse), U8(5), // | 5021 B(JumpIfToBooleanFalse), U8(5), // |
5062 B(LdaSmi8), U8(1), // | 5022 B(LdaSmi8), U8(1), // |
5063 B(Return), // | 5023 B(Return), // |
5064 B(LdaUndefined), // | 5024 B(LdaUndefined), // |
5065 B(Return), // | 5025 B(Return), // |
5066 }}, | 5026 }}, |
5067 {"var a = 1; a = (a || a < 0) ? 2 : 3;", | 5027 {"var a = 1; a = (a || a < 0) ? 2 : 3;", |
5068 1 * kPointerSize, | 5028 1 * kPointerSize, |
5069 1, | 5029 1, |
5070 23, | 5030 21, |
5071 { | 5031 { |
5072 B(LdaSmi8), U8(1), // | 5032 B(LdaSmi8), U8(1), // |
5073 B(Star), R(0), // | 5033 B(Star), R(0), // |
5074 B(Ldar), R(0), // | |
5075 B(JumpIfToBooleanTrue), U8(5), // | 5034 B(JumpIfToBooleanTrue), U8(5), // |
5076 B(LdaZero), // | 5035 B(LdaZero), // |
5077 B(TestLessThan), R(0), // | 5036 B(TestLessThan), R(0), // |
5078 B(JumpIfToBooleanFalse), U8(6), // | 5037 B(JumpIfToBooleanFalse), U8(6), // |
5079 B(LdaSmi8), U8(2), // | 5038 B(LdaSmi8), U8(2), // |
5080 B(Jump), U8(4), // | 5039 B(Jump), U8(4), // |
5081 B(LdaSmi8), U8(3), // | 5040 B(LdaSmi8), U8(3), // |
5082 B(Star), R(0), // | 5041 B(Star), R(0), // |
5083 B(LdaUndefined), // | 5042 B(LdaUndefined), // |
5084 B(Return), // | 5043 B(Return), // |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5120 0, | 5079 0, |
5121 1, | 5080 1, |
5122 3, | 5081 3, |
5123 { | 5082 { |
5124 B(LdaSmi8), U8(1), // | 5083 B(LdaSmi8), U8(1), // |
5125 B(Return), // | 5084 B(Return), // |
5126 }}, | 5085 }}, |
5127 {"var a = 1; if (a) { return 1; }; return 2;", | 5086 {"var a = 1; if (a) { return 1; }; return 2;", |
5128 1 * kPointerSize, | 5087 1 * kPointerSize, |
5129 1, | 5088 1, |
5130 14, | 5089 12, |
5131 { | 5090 { |
5132 B(LdaSmi8), U8(1), // | 5091 B(LdaSmi8), U8(1), // |
5133 B(Star), R(0), // | 5092 B(Star), R(0), // |
5134 B(Ldar), R(0), // | |
5135 B(JumpIfToBooleanFalse), U8(5), // | 5093 B(JumpIfToBooleanFalse), U8(5), // |
5136 B(LdaSmi8), U8(1), // | 5094 B(LdaSmi8), U8(1), // |
5137 B(Return), // | 5095 B(Return), // |
5138 B(LdaSmi8), U8(2), // | 5096 B(LdaSmi8), U8(2), // |
5139 B(Return), // | 5097 B(Return), // |
5140 }}, | 5098 }}, |
5141 }; | 5099 }; |
5142 | 5100 |
5143 for (size_t i = 0; i < arraysize(snippets); i++) { | 5101 for (size_t i = 0; i < arraysize(snippets); i++) { |
5144 Handle<BytecodeArray> bytecode_array = | 5102 Handle<BytecodeArray> bytecode_array = |
(...skipping 18 matching lines...) Expand all Loading... | |
5163 B(LdaTheHole), // | 5121 B(LdaTheHole), // |
5164 B(Star), R(0), // | 5122 B(Star), R(0), // |
5165 B(Ldar), R(closure), // | 5123 B(Ldar), R(closure), // |
5166 B(Star), R(0), // | 5124 B(Star), R(0), // |
5167 B(LdaUndefined), // | 5125 B(LdaUndefined), // |
5168 B(Return), // | 5126 B(Return), // |
5169 }}, | 5127 }}, |
5170 {"var f;\n f = function f() { return f; }", | 5128 {"var f;\n f = function f() { return f; }", |
5171 1 * kPointerSize, | 5129 1 * kPointerSize, |
5172 1, | 5130 1, |
5173 10, | 5131 8, |
5174 { | 5132 { |
5175 B(LdaTheHole), // | 5133 B(LdaTheHole), // |
5176 B(Star), R(0), // | 5134 B(Star), R(0), // |
5177 B(Ldar), R(closure), // | 5135 B(Ldar), R(closure), // |
5178 B(Star), R(0), // | 5136 B(Star), R(0), // |
5179 B(Ldar), R(0), // | |
5180 B(Return), // | 5137 B(Return), // |
5181 }}, | 5138 }}, |
5182 }; | 5139 }; |
5183 | 5140 |
5184 for (size_t i = 0; i < arraysize(snippets); i++) { | 5141 for (size_t i = 0; i < arraysize(snippets); i++) { |
5185 Handle<BytecodeArray> bytecode_array = | 5142 Handle<BytecodeArray> bytecode_array = |
5186 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 5143 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
5187 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 5144 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
5188 } | 5145 } |
5189 } | 5146 } |
5190 | 5147 |
5191 | 5148 |
5192 TEST(NewTarget) { | 5149 TEST(NewTarget) { |
5193 InitializedHandleScope handle_scope; | 5150 InitializedHandleScope handle_scope; |
5194 BytecodeGeneratorHelper helper; | 5151 BytecodeGeneratorHelper helper; |
5195 | 5152 |
5196 ExpectedSnippet<int> snippets[] = { | 5153 ExpectedSnippet<int> snippets[] = { |
5197 {"return new.target;", | 5154 {"return new.target;", |
5198 1 * kPointerSize, | 5155 1 * kPointerSize, |
5199 1, | 5156 1, |
5200 10, | 5157 8, |
5201 { | 5158 { |
5202 B(CallRuntime), U16(Runtime::kGetOriginalConstructor), R(0), // | 5159 B(CallRuntime), U16(Runtime::kGetOriginalConstructor), R(0), // |
5203 U8(0), // | 5160 U8(0), // |
5204 B(Star), R(0), // | 5161 B(Star), R(0), // |
5205 B(Ldar), R(0), // | |
5206 B(Return), // | 5162 B(Return), // |
5207 }}, | 5163 }}, |
5208 }; | 5164 }; |
5209 | 5165 |
5210 for (size_t i = 0; i < arraysize(snippets); i++) { | 5166 for (size_t i = 0; i < arraysize(snippets); i++) { |
5211 Handle<BytecodeArray> bytecode_array = | 5167 Handle<BytecodeArray> bytecode_array = |
5212 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 5168 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
5213 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 5169 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
5214 } | 5170 } |
5215 } | 5171 } |
5216 | 5172 |
5173 | |
5174 TEST(RemoveRedundantLdar) { | |
5175 InitializedHandleScope handle_scope; | |
5176 BytecodeGeneratorHelper helper; | |
5177 | |
5178 ExpectedSnippet<int> snippets[] = { | |
rmcilroy
2015/11/12 14:24:26
nit - add a comment that you are actually checking
mythria
2015/11/13 10:14:37
Done.
| |
5179 {"var ld_a = 1;\n" | |
5180 "while(true) {\n" | |
5181 " ld_a = ld_a + ld_a;\n" | |
5182 " if (ld_a > 10) break;\n" | |
5183 "}\n" | |
5184 "return ld_a;", | |
5185 1 * kPointerSize, | |
5186 1, | |
5187 23, | |
5188 { | |
5189 B(LdaSmi8), U8(1), // | |
5190 B(Star), R(0), // | |
5191 B(Ldar), R(0), // | |
5192 B(Add), R(0), // | |
5193 B(Star), R(0), // | |
5194 B(LdaSmi8), U8(10), // | |
5195 B(TestGreaterThan), R(0), // | |
5196 B(JumpIfFalse), U8(4), // | |
5197 B(Jump), U8(4), // | |
5198 B(Jump), U8(-14), // | |
5199 B(Ldar), R(0), // | |
5200 B(Return) | |
5201 }}, | |
5202 {"var ld_a = 1;\n" | |
5203 "do {\n" | |
5204 " ld_a = ld_a + ld_a;\n" | |
5205 " if (ld_a > 10) continue;\n" | |
5206 "} while(false);\n" | |
5207 "return ld_a;", | |
5208 1 * kPointerSize, | |
5209 1, | |
5210 19, | |
5211 { | |
5212 B(LdaSmi8), U8(1), // | |
5213 B(Star), R(0), // | |
5214 B(Add), R(0), // | |
5215 B(Star), R(0), // | |
5216 B(LdaSmi8), U8(10), // | |
5217 B(TestGreaterThan), R(0), // | |
5218 B(JumpIfFalse), U8(4), // | |
5219 B(Jump), U8(2), // | |
5220 B(Ldar), R(0), // | |
5221 B(Return) | |
5222 }}, | |
5223 }; | |
5224 | |
5225 for (size_t i = 0; i < arraysize(snippets); i++) { | |
5226 Handle<BytecodeArray> bytecode_array = | |
5227 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | |
5228 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | |
5229 } | |
5230 } | |
5231 | |
5217 } // namespace interpreter | 5232 } // namespace interpreter |
5218 } // namespace internal | 5233 } // namespace internal |
5219 } // namespace v8 | 5234 } // namespace v8 |
OLD | NEW |