OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 VisitForAccumulatorValue(function); | 772 VisitForAccumulatorValue(function); |
773 __ pop(r2); | 773 __ pop(r2); |
774 } else { | 774 } else { |
775 __ mov(r2, r0); | 775 __ mov(r2, r0); |
776 __ LoadRoot(r0, Heap::kTheHoleValueRootIndex); | 776 __ LoadRoot(r0, Heap::kTheHoleValueRootIndex); |
777 } | 777 } |
778 ASSERT(prop->key()->AsLiteral() != NULL && | 778 ASSERT(prop->key()->AsLiteral() != NULL && |
779 prop->key()->AsLiteral()->handle()->IsSmi()); | 779 prop->key()->AsLiteral()->handle()->IsSmi()); |
780 __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); | 780 __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); |
781 | 781 |
782 Handle<Code> ic(Builtins::builtin(is_strict() | 782 Handle<Code> ic(Builtins::builtin( |
783 ? Builtins::KeyedStoreIC_Initialize_Strict | 783 is_strict_mode() ? Builtins::KeyedStoreIC_Initialize_Strict |
784 : Builtins::KeyedStoreIC_Initialize)); | 784 : Builtins::KeyedStoreIC_Initialize)); |
785 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 785 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
786 // Value in r0 is ignored (declarations are statements). | 786 // Value in r0 is ignored (declarations are statements). |
787 } | 787 } |
788 } | 788 } |
789 } | 789 } |
790 | 790 |
791 | 791 |
792 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { | 792 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { |
793 EmitDeclaration(decl->proxy()->var(), decl->mode(), decl->fun()); | 793 EmitDeclaration(decl->proxy()->var(), decl->mode(), decl->fun()); |
794 } | 794 } |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 EmitVariableAssignment(var, Token::ASSIGN); | 1824 EmitVariableAssignment(var, Token::ASSIGN); |
1825 break; | 1825 break; |
1826 } | 1826 } |
1827 case NAMED_PROPERTY: { | 1827 case NAMED_PROPERTY: { |
1828 __ push(r0); // Preserve value. | 1828 __ push(r0); // Preserve value. |
1829 VisitForAccumulatorValue(prop->obj()); | 1829 VisitForAccumulatorValue(prop->obj()); |
1830 __ mov(r1, r0); | 1830 __ mov(r1, r0); |
1831 __ pop(r0); // Restore value. | 1831 __ pop(r0); // Restore value. |
1832 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); | 1832 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); |
1833 Handle<Code> ic(Builtins::builtin( | 1833 Handle<Code> ic(Builtins::builtin( |
1834 is_strict() ? Builtins::StoreIC_Initialize_Strict | 1834 is_strict_mode() ? Builtins::StoreIC_Initialize_Strict |
1835 : Builtins::StoreIC_Initialize)); | 1835 : Builtins::StoreIC_Initialize)); |
1836 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 1836 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
1837 break; | 1837 break; |
1838 } | 1838 } |
1839 case KEYED_PROPERTY: { | 1839 case KEYED_PROPERTY: { |
1840 __ push(r0); // Preserve value. | 1840 __ push(r0); // Preserve value. |
1841 if (prop->is_synthetic()) { | 1841 if (prop->is_synthetic()) { |
1842 ASSERT(prop->obj()->AsVariableProxy() != NULL); | 1842 ASSERT(prop->obj()->AsVariableProxy() != NULL); |
1843 ASSERT(prop->key()->AsLiteral() != NULL); | 1843 ASSERT(prop->key()->AsLiteral() != NULL); |
1844 { AccumulatorValueContext for_object(this); | 1844 { AccumulatorValueContext for_object(this); |
1845 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); | 1845 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); |
1846 } | 1846 } |
1847 __ mov(r2, r0); | 1847 __ mov(r2, r0); |
1848 __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); | 1848 __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); |
1849 } else { | 1849 } else { |
1850 VisitForStackValue(prop->obj()); | 1850 VisitForStackValue(prop->obj()); |
1851 VisitForAccumulatorValue(prop->key()); | 1851 VisitForAccumulatorValue(prop->key()); |
1852 __ mov(r1, r0); | 1852 __ mov(r1, r0); |
1853 __ pop(r2); | 1853 __ pop(r2); |
1854 } | 1854 } |
1855 __ pop(r0); // Restore value. | 1855 __ pop(r0); // Restore value. |
1856 Handle<Code> ic(Builtins::builtin( | 1856 Handle<Code> ic(Builtins::builtin( |
1857 is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict | 1857 is_strict_mode() ? Builtins::KeyedStoreIC_Initialize_Strict |
1858 : Builtins::KeyedStoreIC_Initialize)); | 1858 : Builtins::KeyedStoreIC_Initialize)); |
1859 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 1859 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
1860 break; | 1860 break; |
1861 } | 1861 } |
1862 } | 1862 } |
1863 PrepareForBailoutForId(bailout_ast_id, TOS_REG); | 1863 PrepareForBailoutForId(bailout_ast_id, TOS_REG); |
1864 context()->Plug(r0); | 1864 context()->Plug(r0); |
1865 } | 1865 } |
1866 | 1866 |
1867 | 1867 |
1868 void FullCodeGenerator::EmitVariableAssignment(Variable* var, | 1868 void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
1869 Token::Value op) { | 1869 Token::Value op) { |
1870 // Left-hand sides that rewrite to explicit property accesses do not reach | 1870 // Left-hand sides that rewrite to explicit property accesses do not reach |
1871 // here. | 1871 // here. |
1872 ASSERT(var != NULL); | 1872 ASSERT(var != NULL); |
1873 ASSERT(var->is_global() || var->AsSlot() != NULL); | 1873 ASSERT(var->is_global() || var->AsSlot() != NULL); |
1874 | 1874 |
1875 if (var->is_global()) { | 1875 if (var->is_global()) { |
1876 ASSERT(!var->is_this()); | 1876 ASSERT(!var->is_this()); |
1877 // Assignment to a global variable. Use inline caching for the | 1877 // Assignment to a global variable. Use inline caching for the |
1878 // assignment. Right-hand-side value is passed in r0, variable name in | 1878 // assignment. Right-hand-side value is passed in r0, variable name in |
1879 // r2, and the global object in r1. | 1879 // r2, and the global object in r1. |
1880 __ mov(r2, Operand(var->name())); | 1880 __ mov(r2, Operand(var->name())); |
1881 __ ldr(r1, GlobalObjectOperand()); | 1881 __ ldr(r1, GlobalObjectOperand()); |
1882 Handle<Code> ic(Builtins::builtin( | 1882 Handle<Code> ic(Builtins::builtin( |
1883 is_strict() ? Builtins::StoreIC_Initialize_Strict | 1883 is_strict_mode() ? Builtins::StoreIC_Initialize_Strict |
1884 : Builtins::StoreIC_Initialize)); | 1884 : Builtins::StoreIC_Initialize)); |
1885 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); | 1885 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); |
1886 | 1886 |
1887 } else if (op == Token::INIT_CONST) { | 1887 } else if (op == Token::INIT_CONST) { |
1888 // Like var declarations, const declarations are hoisted to function | 1888 // Like var declarations, const declarations are hoisted to function |
1889 // scope. However, unlike var initializers, const initializers are able | 1889 // scope. However, unlike var initializers, const initializers are able |
1890 // to drill a hole to that function context, even from inside a 'with' | 1890 // to drill a hole to that function context, even from inside a 'with' |
1891 // context. We thus bypass the normal static scope lookup. | 1891 // context. We thus bypass the normal static scope lookup. |
1892 Slot* slot = var->AsSlot(); | 1892 Slot* slot = var->AsSlot(); |
1893 Label skip; | 1893 Label skip; |
1894 switch (slot->type()) { | 1894 switch (slot->type()) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); | 1982 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); |
1983 // Load receiver to r1. Leave a copy in the stack if needed for turning the | 1983 // Load receiver to r1. Leave a copy in the stack if needed for turning the |
1984 // receiver into fast case. | 1984 // receiver into fast case. |
1985 if (expr->ends_initialization_block()) { | 1985 if (expr->ends_initialization_block()) { |
1986 __ ldr(r1, MemOperand(sp)); | 1986 __ ldr(r1, MemOperand(sp)); |
1987 } else { | 1987 } else { |
1988 __ pop(r1); | 1988 __ pop(r1); |
1989 } | 1989 } |
1990 | 1990 |
1991 Handle<Code> ic(Builtins::builtin( | 1991 Handle<Code> ic(Builtins::builtin( |
1992 is_strict() ? Builtins::StoreIC_Initialize_Strict | 1992 is_strict_mode() ? Builtins::StoreIC_Initialize_Strict |
1993 : Builtins::StoreIC_Initialize)); | 1993 : Builtins::StoreIC_Initialize)); |
1994 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 1994 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
1995 | 1995 |
1996 // If the assignment ends an initialization block, revert to fast case. | 1996 // If the assignment ends an initialization block, revert to fast case. |
1997 if (expr->ends_initialization_block()) { | 1997 if (expr->ends_initialization_block()) { |
1998 __ push(r0); // Result of assignment, saved even if not needed. | 1998 __ push(r0); // Result of assignment, saved even if not needed. |
1999 // Receiver is under the result value. | 1999 // Receiver is under the result value. |
2000 __ ldr(ip, MemOperand(sp, kPointerSize)); | 2000 __ ldr(ip, MemOperand(sp, kPointerSize)); |
2001 __ push(ip); | 2001 __ push(ip); |
2002 __ CallRuntime(Runtime::kToFastProperties, 1); | 2002 __ CallRuntime(Runtime::kToFastProperties, 1); |
2003 __ pop(r0); | 2003 __ pop(r0); |
(...skipping 24 matching lines...) Expand all Loading... |
2028 __ pop(r1); // Key. | 2028 __ pop(r1); // Key. |
2029 // Load receiver to r2. Leave a copy in the stack if needed for turning the | 2029 // Load receiver to r2. Leave a copy in the stack if needed for turning the |
2030 // receiver into fast case. | 2030 // receiver into fast case. |
2031 if (expr->ends_initialization_block()) { | 2031 if (expr->ends_initialization_block()) { |
2032 __ ldr(r2, MemOperand(sp)); | 2032 __ ldr(r2, MemOperand(sp)); |
2033 } else { | 2033 } else { |
2034 __ pop(r2); | 2034 __ pop(r2); |
2035 } | 2035 } |
2036 | 2036 |
2037 Handle<Code> ic(Builtins::builtin( | 2037 Handle<Code> ic(Builtins::builtin( |
2038 is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict | 2038 is_strict_mode() ? Builtins::KeyedStoreIC_Initialize_Strict |
2039 : Builtins::KeyedStoreIC_Initialize)); | 2039 : Builtins::KeyedStoreIC_Initialize)); |
2040 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 2040 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
2041 | 2041 |
2042 // If the assignment ends an initialization block, revert to fast case. | 2042 // If the assignment ends an initialization block, revert to fast case. |
2043 if (expr->ends_initialization_block()) { | 2043 if (expr->ends_initialization_block()) { |
2044 __ push(r0); // Result of assignment, saved even if not needed. | 2044 __ push(r0); // Result of assignment, saved even if not needed. |
2045 // Receiver is under the result value. | 2045 // Receiver is under the result value. |
2046 __ ldr(ip, MemOperand(sp, kPointerSize)); | 2046 __ ldr(ip, MemOperand(sp, kPointerSize)); |
2047 __ push(ip); | 2047 __ push(ip); |
2048 __ CallRuntime(Runtime::kToFastProperties, 1); | 2048 __ CallRuntime(Runtime::kToFastProperties, 1); |
2049 __ pop(r0); | 2049 __ pop(r0); |
(...skipping 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3880 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3880 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
3881 Token::ASSIGN); | 3881 Token::ASSIGN); |
3882 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3882 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
3883 context()->Plug(r0); | 3883 context()->Plug(r0); |
3884 } | 3884 } |
3885 break; | 3885 break; |
3886 case NAMED_PROPERTY: { | 3886 case NAMED_PROPERTY: { |
3887 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); | 3887 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); |
3888 __ pop(r1); | 3888 __ pop(r1); |
3889 Handle<Code> ic(Builtins::builtin( | 3889 Handle<Code> ic(Builtins::builtin( |
3890 is_strict() ? Builtins::StoreIC_Initialize_Strict | 3890 is_strict_mode() ? Builtins::StoreIC_Initialize_Strict |
3891 : Builtins::StoreIC_Initialize)); | 3891 : Builtins::StoreIC_Initialize)); |
3892 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 3892 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
3893 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3893 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
3894 if (expr->is_postfix()) { | 3894 if (expr->is_postfix()) { |
3895 if (!context()->IsEffect()) { | 3895 if (!context()->IsEffect()) { |
3896 context()->PlugTOS(); | 3896 context()->PlugTOS(); |
3897 } | 3897 } |
3898 } else { | 3898 } else { |
3899 context()->Plug(r0); | 3899 context()->Plug(r0); |
3900 } | 3900 } |
3901 break; | 3901 break; |
3902 } | 3902 } |
3903 case KEYED_PROPERTY: { | 3903 case KEYED_PROPERTY: { |
3904 __ pop(r1); // Key. | 3904 __ pop(r1); // Key. |
3905 __ pop(r2); // Receiver. | 3905 __ pop(r2); // Receiver. |
3906 Handle<Code> ic(Builtins::builtin( | 3906 Handle<Code> ic(Builtins::builtin( |
3907 is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict | 3907 is_strict_mode() ? Builtins::KeyedStoreIC_Initialize_Strict |
3908 : Builtins::KeyedStoreIC_Initialize)); | 3908 : Builtins::KeyedStoreIC_Initialize)); |
3909 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 3909 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
3910 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3910 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
3911 if (expr->is_postfix()) { | 3911 if (expr->is_postfix()) { |
3912 if (!context()->IsEffect()) { | 3912 if (!context()->IsEffect()) { |
3913 context()->PlugTOS(); | 3913 context()->PlugTOS(); |
3914 } | 3914 } |
3915 } else { | 3915 } else { |
3916 context()->Plug(r0); | 3916 context()->Plug(r0); |
3917 } | 3917 } |
3918 break; | 3918 break; |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4283 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. | 4283 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. |
4284 __ add(pc, r1, Operand(masm_->CodeObject())); | 4284 __ add(pc, r1, Operand(masm_->CodeObject())); |
4285 } | 4285 } |
4286 | 4286 |
4287 | 4287 |
4288 #undef __ | 4288 #undef __ |
4289 | 4289 |
4290 } } // namespace v8::internal | 4290 } } // namespace v8::internal |
4291 | 4291 |
4292 #endif // V8_TARGET_ARCH_ARM | 4292 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |