| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1802 | 1802 |
| 1803 // Call operator. | 1803 // Call operator. |
| 1804 GenerateBinaryOperatorCall(node->id(), node->token_index(), node->Name()); | 1804 GenerateBinaryOperatorCall(node->id(), node->token_index(), node->Name()); |
| 1805 // Result is in EAX. | 1805 // Result is in EAX. |
| 1806 if (IsResultNeeded(node)) { | 1806 if (IsResultNeeded(node)) { |
| 1807 __ pushl(EAX); | 1807 __ pushl(EAX); |
| 1808 } | 1808 } |
| 1809 } | 1809 } |
| 1810 | 1810 |
| 1811 | 1811 |
| 1812 void CodeGenerator::HandleBackwardBranch( |
| 1813 intptr_t loop_id, intptr_t token_index) { |
| 1814 // Use stack overflow check to eventually stop execution of loops. |
| 1815 // This is necessary only if a loop does not have calls. |
| 1816 __ cmpl(ESP, |
| 1817 Address::Absolute(Isolate::Current()->stack_limit_address())); |
| 1818 Label no_stack_overflow; |
| 1819 __ j(ABOVE, &no_stack_overflow); |
| 1820 GenerateCallRuntime(loop_id, |
| 1821 token_index, |
| 1822 kStackOverflowRuntimeEntry); |
| 1823 __ Bind(&no_stack_overflow); |
| 1824 } |
| 1825 |
| 1826 |
| 1812 void CodeGenerator::VisitWhileNode(WhileNode* node) { | 1827 void CodeGenerator::VisitWhileNode(WhileNode* node) { |
| 1813 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); | 1828 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); |
| 1814 SourceLabel* label = node->label(); | 1829 SourceLabel* label = node->label(); |
| 1815 __ Bind(label->continue_label()); | 1830 __ Bind(label->continue_label()); |
| 1816 node->condition()->Visit(this); | 1831 node->condition()->Visit(this); |
| 1817 GenerateConditionTypeCheck(node->id(), node->condition()->token_index()); | 1832 GenerateConditionTypeCheck(node->id(), node->condition()->token_index()); |
| 1818 __ popl(EAX); | 1833 __ popl(EAX); |
| 1819 __ LoadObject(EDX, bool_true); | 1834 __ LoadObject(EDX, bool_true); |
| 1820 __ cmpl(EAX, EDX); | 1835 __ cmpl(EAX, EDX); |
| 1821 __ j(NOT_EQUAL, label->break_label()); | 1836 __ j(NOT_EQUAL, label->break_label()); |
| 1822 node->body()->Visit(this); | 1837 node->body()->Visit(this); |
| 1838 HandleBackwardBranch(node->id(), node->token_index()); |
| 1823 __ jmp(label->continue_label()); | 1839 __ jmp(label->continue_label()); |
| 1824 __ Bind(label->break_label()); | 1840 __ Bind(label->break_label()); |
| 1825 } | 1841 } |
| 1826 | 1842 |
| 1827 | 1843 |
| 1828 void CodeGenerator::VisitDoWhileNode(DoWhileNode* node) { | 1844 void CodeGenerator::VisitDoWhileNode(DoWhileNode* node) { |
| 1829 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); | 1845 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); |
| 1830 SourceLabel* label = node->label(); | 1846 SourceLabel* label = node->label(); |
| 1831 Label loop; | 1847 Label loop; |
| 1832 __ Bind(&loop); | 1848 __ Bind(&loop); |
| 1833 node->body()->Visit(this); | 1849 node->body()->Visit(this); |
| 1850 HandleBackwardBranch(node->id(), node->token_index()); |
| 1834 __ Bind(label->continue_label()); | 1851 __ Bind(label->continue_label()); |
| 1835 node->condition()->Visit(this); | 1852 node->condition()->Visit(this); |
| 1836 GenerateConditionTypeCheck(node->id(), node->condition()->token_index()); | 1853 GenerateConditionTypeCheck(node->id(), node->condition()->token_index()); |
| 1837 __ popl(EAX); | 1854 __ popl(EAX); |
| 1838 __ LoadObject(EDX, bool_true); | 1855 __ LoadObject(EDX, bool_true); |
| 1839 __ cmpl(EAX, EDX); | 1856 __ cmpl(EAX, EDX); |
| 1840 __ j(EQUAL, &loop); | 1857 __ j(EQUAL, &loop); |
| 1841 __ Bind(label->break_label()); | 1858 __ Bind(label->break_label()); |
| 1842 } | 1859 } |
| 1843 | 1860 |
| 1844 | 1861 |
| 1845 void CodeGenerator::VisitForNode(ForNode* node) { | 1862 void CodeGenerator::VisitForNode(ForNode* node) { |
| 1846 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); | 1863 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); |
| 1847 node->initializer()->Visit(this); | 1864 node->initializer()->Visit(this); |
| 1848 SourceLabel* label = node->label(); | 1865 SourceLabel* label = node->label(); |
| 1849 Label loop; | 1866 Label loop; |
| 1850 __ Bind(&loop); | 1867 __ Bind(&loop); |
| 1851 if (node->condition() != NULL) { | 1868 if (node->condition() != NULL) { |
| 1852 node->condition()->Visit(this); | 1869 node->condition()->Visit(this); |
| 1853 GenerateConditionTypeCheck(node->id(), node->condition()->token_index()); | 1870 GenerateConditionTypeCheck(node->id(), node->condition()->token_index()); |
| 1854 __ popl(EAX); | 1871 __ popl(EAX); |
| 1855 __ LoadObject(EDX, bool_true); | 1872 __ LoadObject(EDX, bool_true); |
| 1856 __ cmpl(EAX, EDX); | 1873 __ cmpl(EAX, EDX); |
| 1857 __ j(NOT_EQUAL, label->break_label()); | 1874 __ j(NOT_EQUAL, label->break_label()); |
| 1858 } | 1875 } |
| 1859 node->body()->Visit(this); | 1876 node->body()->Visit(this); |
| 1877 HandleBackwardBranch(node->id(), node->token_index()); |
| 1860 __ Bind(label->continue_label()); | 1878 __ Bind(label->continue_label()); |
| 1861 node->increment()->Visit(this); | 1879 node->increment()->Visit(this); |
| 1862 __ jmp(&loop); | 1880 __ jmp(&loop); |
| 1863 __ Bind(label->break_label()); | 1881 __ Bind(label->break_label()); |
| 1864 } | 1882 } |
| 1865 | 1883 |
| 1866 | 1884 |
| 1867 void CodeGenerator::VisitJumpNode(JumpNode* node) { | 1885 void CodeGenerator::VisitJumpNode(JumpNode* node) { |
| 1868 SourceLabel* label = node->label(); | 1886 SourceLabel* label = node->label(); |
| 1869 | 1887 |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2701 const Error& error = Error::Handle( | 2719 const Error& error = Error::Handle( |
| 2702 Parser::FormatError(script, token_index, "Error", format, args)); | 2720 Parser::FormatError(script, token_index, "Error", format, args)); |
| 2703 va_end(args); | 2721 va_end(args); |
| 2704 Isolate::Current()->long_jump_base()->Jump(1, error); | 2722 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2705 UNREACHABLE(); | 2723 UNREACHABLE(); |
| 2706 } | 2724 } |
| 2707 | 2725 |
| 2708 } // namespace dart | 2726 } // namespace dart |
| 2709 | 2727 |
| 2710 #endif // defined TARGET_ARCH_IA32 | 2728 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |