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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 VisitForAccumulatorValue(function); | 759 VisitForAccumulatorValue(function); |
760 __ pop(r2); | 760 __ pop(r2); |
761 } else { | 761 } else { |
762 __ mov(r2, r0); | 762 __ mov(r2, r0); |
763 __ LoadRoot(r0, Heap::kTheHoleValueRootIndex); | 763 __ LoadRoot(r0, Heap::kTheHoleValueRootIndex); |
764 } | 764 } |
765 ASSERT(prop->key()->AsLiteral() != NULL && | 765 ASSERT(prop->key()->AsLiteral() != NULL && |
766 prop->key()->AsLiteral()->handle()->IsSmi()); | 766 prop->key()->AsLiteral()->handle()->IsSmi()); |
767 __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); | 767 __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); |
768 | 768 |
769 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); | 769 Handle<Code> ic(Builtins::builtin(is_strict() |
| 770 ? Builtins::KeyedStoreIC_Initialize_Strict |
| 771 : Builtins::KeyedStoreIC_Initialize)); |
770 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 772 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
771 // Value in r0 is ignored (declarations are statements). | 773 // Value in r0 is ignored (declarations are statements). |
772 } | 774 } |
773 } | 775 } |
774 } | 776 } |
775 | 777 |
776 | 778 |
777 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { | 779 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { |
778 EmitDeclaration(decl->proxy()->var(), decl->mode(), decl->fun()); | 780 EmitDeclaration(decl->proxy()->var(), decl->mode(), decl->fun()); |
779 } | 781 } |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 break; | 1355 break; |
1354 } | 1356 } |
1355 // Fall through. | 1357 // Fall through. |
1356 case ObjectLiteral::Property::PROTOTYPE: | 1358 case ObjectLiteral::Property::PROTOTYPE: |
1357 // Duplicate receiver on stack. | 1359 // Duplicate receiver on stack. |
1358 __ ldr(r0, MemOperand(sp)); | 1360 __ ldr(r0, MemOperand(sp)); |
1359 __ push(r0); | 1361 __ push(r0); |
1360 VisitForStackValue(key); | 1362 VisitForStackValue(key); |
1361 VisitForStackValue(value); | 1363 VisitForStackValue(value); |
1362 if (property->emit_store()) { | 1364 if (property->emit_store()) { |
1363 __ CallRuntime(Runtime::kSetProperty, 3); | 1365 __ mov(r0, Operand(Smi::FromInt(NONE))); // PropertyAttributes |
| 1366 __ push(r0); |
| 1367 __ CallRuntime(Runtime::kSetProperty, 4); |
1364 } else { | 1368 } else { |
1365 __ Drop(3); | 1369 __ Drop(3); |
1366 } | 1370 } |
1367 break; | 1371 break; |
1368 case ObjectLiteral::Property::GETTER: | 1372 case ObjectLiteral::Property::GETTER: |
1369 case ObjectLiteral::Property::SETTER: | 1373 case ObjectLiteral::Property::SETTER: |
1370 // Duplicate receiver on stack. | 1374 // Duplicate receiver on stack. |
1371 __ ldr(r0, MemOperand(sp)); | 1375 __ ldr(r0, MemOperand(sp)); |
1372 __ push(r0); | 1376 __ push(r0); |
1373 VisitForStackValue(key); | 1377 VisitForStackValue(key); |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1947 EffectContext context(this); | 1951 EffectContext context(this); |
1948 EmitVariableAssignment(var, Token::ASSIGN); | 1952 EmitVariableAssignment(var, Token::ASSIGN); |
1949 break; | 1953 break; |
1950 } | 1954 } |
1951 case NAMED_PROPERTY: { | 1955 case NAMED_PROPERTY: { |
1952 __ push(r0); // Preserve value. | 1956 __ push(r0); // Preserve value. |
1953 VisitForAccumulatorValue(prop->obj()); | 1957 VisitForAccumulatorValue(prop->obj()); |
1954 __ mov(r1, r0); | 1958 __ mov(r1, r0); |
1955 __ pop(r0); // Restore value. | 1959 __ pop(r0); // Restore value. |
1956 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); | 1960 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); |
1957 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 1961 Handle<Code> ic(Builtins::builtin( |
| 1962 is_strict() ? Builtins::StoreIC_Initialize_Strict |
| 1963 : Builtins::StoreIC_Initialize)); |
1958 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 1964 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
1959 break; | 1965 break; |
1960 } | 1966 } |
1961 case KEYED_PROPERTY: { | 1967 case KEYED_PROPERTY: { |
1962 __ push(r0); // Preserve value. | 1968 __ push(r0); // Preserve value. |
1963 if (prop->is_synthetic()) { | 1969 if (prop->is_synthetic()) { |
1964 ASSERT(prop->obj()->AsVariableProxy() != NULL); | 1970 ASSERT(prop->obj()->AsVariableProxy() != NULL); |
1965 ASSERT(prop->key()->AsLiteral() != NULL); | 1971 ASSERT(prop->key()->AsLiteral() != NULL); |
1966 { AccumulatorValueContext for_object(this); | 1972 { AccumulatorValueContext for_object(this); |
1967 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); | 1973 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); |
1968 } | 1974 } |
1969 __ mov(r2, r0); | 1975 __ mov(r2, r0); |
1970 __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); | 1976 __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); |
1971 } else { | 1977 } else { |
1972 VisitForStackValue(prop->obj()); | 1978 VisitForStackValue(prop->obj()); |
1973 VisitForAccumulatorValue(prop->key()); | 1979 VisitForAccumulatorValue(prop->key()); |
1974 __ mov(r1, r0); | 1980 __ mov(r1, r0); |
1975 __ pop(r2); | 1981 __ pop(r2); |
1976 } | 1982 } |
1977 __ pop(r0); // Restore value. | 1983 __ pop(r0); // Restore value. |
1978 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); | 1984 Handle<Code> ic(Builtins::builtin( |
| 1985 is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict |
| 1986 : Builtins::KeyedStoreIC_Initialize)); |
1979 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 1987 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
1980 break; | 1988 break; |
1981 } | 1989 } |
1982 } | 1990 } |
1983 PrepareForBailoutForId(bailout_ast_id, TOS_REG); | 1991 PrepareForBailoutForId(bailout_ast_id, TOS_REG); |
1984 context()->Plug(r0); | 1992 context()->Plug(r0); |
1985 } | 1993 } |
1986 | 1994 |
1987 | 1995 |
1988 void FullCodeGenerator::EmitVariableAssignment(Variable* var, | 1996 void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
1989 Token::Value op) { | 1997 Token::Value op) { |
1990 // Left-hand sides that rewrite to explicit property accesses do not reach | 1998 // Left-hand sides that rewrite to explicit property accesses do not reach |
1991 // here. | 1999 // here. |
1992 ASSERT(var != NULL); | 2000 ASSERT(var != NULL); |
1993 ASSERT(var->is_global() || var->AsSlot() != NULL); | 2001 ASSERT(var->is_global() || var->AsSlot() != NULL); |
1994 | 2002 |
1995 if (var->is_global()) { | 2003 if (var->is_global()) { |
1996 ASSERT(!var->is_this()); | 2004 ASSERT(!var->is_this()); |
1997 // Assignment to a global variable. Use inline caching for the | 2005 // Assignment to a global variable. Use inline caching for the |
1998 // assignment. Right-hand-side value is passed in r0, variable name in | 2006 // assignment. Right-hand-side value is passed in r0, variable name in |
1999 // r2, and the global object in r1. | 2007 // r2, and the global object in r1. |
2000 __ mov(r2, Operand(var->name())); | 2008 __ mov(r2, Operand(var->name())); |
2001 __ ldr(r1, GlobalObjectOperand()); | 2009 __ ldr(r1, GlobalObjectOperand()); |
2002 Handle<Code> ic(Builtins::builtin(is_strict() | 2010 Handle<Code> ic(Builtins::builtin( |
2003 ? Builtins::StoreIC_Initialize_Strict | 2011 is_strict() ? Builtins::StoreIC_Initialize_Strict |
2004 : Builtins::StoreIC_Initialize)); | 2012 : Builtins::StoreIC_Initialize)); |
2005 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); | 2013 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); |
2006 | 2014 |
2007 } else if (var->mode() != Variable::CONST || op == Token::INIT_CONST) { | 2015 } else if (var->mode() != Variable::CONST || op == Token::INIT_CONST) { |
2008 // Perform the assignment for non-const variables and for initialization | 2016 // Perform the assignment for non-const variables and for initialization |
2009 // of const variables. Const assignments are simply skipped. | 2017 // of const variables. Const assignments are simply skipped. |
2010 Label done; | 2018 Label done; |
2011 Slot* slot = var->AsSlot(); | 2019 Slot* slot = var->AsSlot(); |
2012 switch (slot->type()) { | 2020 switch (slot->type()) { |
2013 case Slot::PARAMETER: | 2021 case Slot::PARAMETER: |
2014 case Slot::LOCAL: | 2022 case Slot::LOCAL: |
(...skipping 29 matching lines...) Expand all Loading... |
2044 case Slot::LOOKUP: | 2052 case Slot::LOOKUP: |
2045 // Call the runtime for the assignment. The runtime will ignore | 2053 // Call the runtime for the assignment. The runtime will ignore |
2046 // const reinitialization. | 2054 // const reinitialization. |
2047 __ push(r0); // Value. | 2055 __ push(r0); // Value. |
2048 __ mov(r0, Operand(slot->var()->name())); | 2056 __ mov(r0, Operand(slot->var()->name())); |
2049 __ Push(cp, r0); // Context and name. | 2057 __ Push(cp, r0); // Context and name. |
2050 if (op == Token::INIT_CONST) { | 2058 if (op == Token::INIT_CONST) { |
2051 // The runtime will ignore const redeclaration. | 2059 // The runtime will ignore const redeclaration. |
2052 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); | 2060 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); |
2053 } else { | 2061 } else { |
2054 __ CallRuntime(Runtime::kStoreContextSlot, 3); | 2062 __ mov(r0, Operand(Smi::FromInt(strict_mode_flag()))); |
| 2063 __ push(r0); |
| 2064 __ CallRuntime(Runtime::kStoreContextSlot, 4); |
2055 } | 2065 } |
2056 break; | 2066 break; |
2057 } | 2067 } |
2058 __ bind(&done); | 2068 __ bind(&done); |
2059 } | 2069 } |
2060 } | 2070 } |
2061 | 2071 |
2062 | 2072 |
2063 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 2073 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
2064 // Assignment to a property, using a named store IC. | 2074 // Assignment to a property, using a named store IC. |
(...skipping 16 matching lines...) Expand all Loading... |
2081 SetSourcePosition(expr->position()); | 2091 SetSourcePosition(expr->position()); |
2082 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); | 2092 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); |
2083 // Load receiver to r1. Leave a copy in the stack if needed for turning the | 2093 // Load receiver to r1. Leave a copy in the stack if needed for turning the |
2084 // receiver into fast case. | 2094 // receiver into fast case. |
2085 if (expr->ends_initialization_block()) { | 2095 if (expr->ends_initialization_block()) { |
2086 __ ldr(r1, MemOperand(sp)); | 2096 __ ldr(r1, MemOperand(sp)); |
2087 } else { | 2097 } else { |
2088 __ pop(r1); | 2098 __ pop(r1); |
2089 } | 2099 } |
2090 | 2100 |
2091 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 2101 Handle<Code> ic(Builtins::builtin( |
| 2102 is_strict() ? Builtins::StoreIC_Initialize_Strict |
| 2103 : Builtins::StoreIC_Initialize)); |
2092 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 2104 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
2093 | 2105 |
2094 // If the assignment ends an initialization block, revert to fast case. | 2106 // If the assignment ends an initialization block, revert to fast case. |
2095 if (expr->ends_initialization_block()) { | 2107 if (expr->ends_initialization_block()) { |
2096 __ push(r0); // Result of assignment, saved even if not needed. | 2108 __ push(r0); // Result of assignment, saved even if not needed. |
2097 // Receiver is under the result value. | 2109 // Receiver is under the result value. |
2098 __ ldr(ip, MemOperand(sp, kPointerSize)); | 2110 __ ldr(ip, MemOperand(sp, kPointerSize)); |
2099 __ push(ip); | 2111 __ push(ip); |
2100 __ CallRuntime(Runtime::kToFastProperties, 1); | 2112 __ CallRuntime(Runtime::kToFastProperties, 1); |
2101 __ pop(r0); | 2113 __ pop(r0); |
(...skipping 23 matching lines...) Expand all Loading... |
2125 SetSourcePosition(expr->position()); | 2137 SetSourcePosition(expr->position()); |
2126 __ pop(r1); // Key. | 2138 __ pop(r1); // Key. |
2127 // Load receiver to r2. Leave a copy in the stack if needed for turning the | 2139 // Load receiver to r2. Leave a copy in the stack if needed for turning the |
2128 // receiver into fast case. | 2140 // receiver into fast case. |
2129 if (expr->ends_initialization_block()) { | 2141 if (expr->ends_initialization_block()) { |
2130 __ ldr(r2, MemOperand(sp)); | 2142 __ ldr(r2, MemOperand(sp)); |
2131 } else { | 2143 } else { |
2132 __ pop(r2); | 2144 __ pop(r2); |
2133 } | 2145 } |
2134 | 2146 |
2135 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); | 2147 Handle<Code> ic(Builtins::builtin( |
| 2148 is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict |
| 2149 : Builtins::KeyedStoreIC_Initialize)); |
2136 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 2150 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
2137 | 2151 |
2138 // If the assignment ends an initialization block, revert to fast case. | 2152 // If the assignment ends an initialization block, revert to fast case. |
2139 if (expr->ends_initialization_block()) { | 2153 if (expr->ends_initialization_block()) { |
2140 __ push(r0); // Result of assignment, saved even if not needed. | 2154 __ push(r0); // Result of assignment, saved even if not needed. |
2141 // Receiver is under the result value. | 2155 // Receiver is under the result value. |
2142 __ ldr(ip, MemOperand(sp, kPointerSize)); | 2156 __ ldr(ip, MemOperand(sp, kPointerSize)); |
2143 __ push(ip); | 2157 __ push(ip); |
2144 __ CallRuntime(Runtime::kToFastProperties, 1); | 2158 __ CallRuntime(Runtime::kToFastProperties, 1); |
2145 __ pop(r0); | 2159 __ pop(r0); |
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3638 } else { | 3652 } else { |
3639 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3653 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
3640 Token::ASSIGN); | 3654 Token::ASSIGN); |
3641 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3655 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
3642 context()->Plug(r0); | 3656 context()->Plug(r0); |
3643 } | 3657 } |
3644 break; | 3658 break; |
3645 case NAMED_PROPERTY: { | 3659 case NAMED_PROPERTY: { |
3646 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); | 3660 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); |
3647 __ pop(r1); | 3661 __ pop(r1); |
3648 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 3662 Handle<Code> ic(Builtins::builtin( |
| 3663 is_strict() ? Builtins::StoreIC_Initialize_Strict |
| 3664 : Builtins::StoreIC_Initialize)); |
3649 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 3665 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
3650 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3666 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
3651 if (expr->is_postfix()) { | 3667 if (expr->is_postfix()) { |
3652 if (!context()->IsEffect()) { | 3668 if (!context()->IsEffect()) { |
3653 context()->PlugTOS(); | 3669 context()->PlugTOS(); |
3654 } | 3670 } |
3655 } else { | 3671 } else { |
3656 context()->Plug(r0); | 3672 context()->Plug(r0); |
3657 } | 3673 } |
3658 break; | 3674 break; |
3659 } | 3675 } |
3660 case KEYED_PROPERTY: { | 3676 case KEYED_PROPERTY: { |
3661 __ pop(r1); // Key. | 3677 __ pop(r1); // Key. |
3662 __ pop(r2); // Receiver. | 3678 __ pop(r2); // Receiver. |
3663 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); | 3679 Handle<Code> ic(Builtins::builtin( |
| 3680 is_strict() ? Builtins::KeyedStoreIC_Initialize_Strict |
| 3681 : Builtins::KeyedStoreIC_Initialize)); |
3664 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 3682 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
3665 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3683 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
3666 if (expr->is_postfix()) { | 3684 if (expr->is_postfix()) { |
3667 if (!context()->IsEffect()) { | 3685 if (!context()->IsEffect()) { |
3668 context()->PlugTOS(); | 3686 context()->PlugTOS(); |
3669 } | 3687 } |
3670 } else { | 3688 } else { |
3671 context()->Plug(r0); | 3689 context()->Plug(r0); |
3672 } | 3690 } |
3673 break; | 3691 break; |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4025 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. | 4043 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. |
4026 __ add(pc, r1, Operand(masm_->CodeObject())); | 4044 __ add(pc, r1, Operand(masm_->CodeObject())); |
4027 } | 4045 } |
4028 | 4046 |
4029 | 4047 |
4030 #undef __ | 4048 #undef __ |
4031 | 4049 |
4032 } } // namespace v8::internal | 4050 } } // namespace v8::internal |
4033 | 4051 |
4034 #endif // V8_TARGET_ARCH_ARM | 4052 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |