| 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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 } else if (prop != NULL) { | 769 } else if (prop != NULL) { |
| 770 // A const declaration aliasing a parameter is an illegal redeclaration. | 770 // A const declaration aliasing a parameter is an illegal redeclaration. |
| 771 ASSERT(mode != Variable::CONST); | 771 ASSERT(mode != Variable::CONST); |
| 772 if (function != NULL) { | 772 if (function != NULL) { |
| 773 // We are declaring a function that rewrites to a property. | 773 // We are declaring a function that rewrites to a property. |
| 774 // Use (keyed) IC to set the initial value. We cannot visit the | 774 // Use (keyed) IC to set the initial value. We cannot visit the |
| 775 // rewrite because it's shared and we risk recording duplicate AST | 775 // rewrite because it's shared and we risk recording duplicate AST |
| 776 // IDs for bailouts from optimized code. | 776 // IDs for bailouts from optimized code. |
| 777 ASSERT(prop->obj()->AsVariableProxy() != NULL); | 777 ASSERT(prop->obj()->AsVariableProxy() != NULL); |
| 778 { AccumulatorValueContext for_object(this); | 778 { AccumulatorValueContext for_object(this); |
| 779 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); | 779 EmitVariableLoad(prop->obj()->AsVariableProxy()); |
| 780 } | 780 } |
| 781 | 781 |
| 782 __ push(r0); | 782 __ push(r0); |
| 783 VisitForAccumulatorValue(function); | 783 VisitForAccumulatorValue(function); |
| 784 __ pop(r2); | 784 __ pop(r2); |
| 785 | 785 |
| 786 ASSERT(prop->key()->AsLiteral() != NULL && | 786 ASSERT(prop->key()->AsLiteral() != NULL && |
| 787 prop->key()->AsLiteral()->handle()->IsSmi()); | 787 prop->key()->AsLiteral()->handle()->IsSmi()); |
| 788 __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); | 788 __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); |
| 789 | 789 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 : Heap::kFalseValueRootIndex); | 1106 : Heap::kFalseValueRootIndex); |
| 1107 __ Push(cp, r0, r1); | 1107 __ Push(cp, r0, r1); |
| 1108 __ CallRuntime(Runtime::kNewClosure, 3); | 1108 __ CallRuntime(Runtime::kNewClosure, 3); |
| 1109 } | 1109 } |
| 1110 context()->Plug(r0); | 1110 context()->Plug(r0); |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 | 1113 |
| 1114 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | 1114 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
| 1115 Comment cmnt(masm_, "[ VariableProxy"); | 1115 Comment cmnt(masm_, "[ VariableProxy"); |
| 1116 EmitVariableLoad(expr->var()); | 1116 EmitVariableLoad(expr); |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 | 1119 |
| 1120 void FullCodeGenerator::EmitLoadGlobalSlotCheckExtensions( | 1120 void FullCodeGenerator::EmitLoadGlobalSlotCheckExtensions( |
| 1121 Slot* slot, | 1121 Slot* slot, |
| 1122 TypeofState typeof_state, | 1122 TypeofState typeof_state, |
| 1123 Label* slow) { | 1123 Label* slow) { |
| 1124 Register current = cp; | 1124 Register current = cp; |
| 1125 Register next = r1; | 1125 Register next = r1; |
| 1126 Register temp = r2; | 1126 Register temp = r2; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 isolate()->builtins()->KeyedLoadIC_Initialize(); | 1255 isolate()->builtins()->KeyedLoadIC_Initialize(); |
| 1256 __ Call(ic, RelocInfo::CODE_TARGET, GetPropertyId(property)); | 1256 __ Call(ic, RelocInfo::CODE_TARGET, GetPropertyId(property)); |
| 1257 __ jmp(done); | 1257 __ jmp(done); |
| 1258 } | 1258 } |
| 1259 } | 1259 } |
| 1260 } | 1260 } |
| 1261 } | 1261 } |
| 1262 } | 1262 } |
| 1263 | 1263 |
| 1264 | 1264 |
| 1265 void FullCodeGenerator::EmitVariableLoad(Variable* var) { | 1265 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { |
| 1266 // Record position before possible IC call. |
| 1267 SetSourcePosition(proxy->position()); |
| 1268 Variable* var = proxy->var(); |
| 1269 |
| 1266 // Three cases: non-this global variables, lookup slots, and all other | 1270 // Three cases: non-this global variables, lookup slots, and all other |
| 1267 // types of slots. | 1271 // types of slots. |
| 1268 Slot* slot = var->AsSlot(); | 1272 Slot* slot = var->AsSlot(); |
| 1269 ASSERT((var->is_global() && !var->is_this()) == (slot == NULL)); | 1273 ASSERT((var->is_global() && !var->is_this()) == (slot == NULL)); |
| 1270 | 1274 |
| 1271 if (slot == NULL) { | 1275 if (slot == NULL) { |
| 1272 Comment cmnt(masm_, "Global variable"); | 1276 Comment cmnt(masm_, "Global variable"); |
| 1273 // Use inline caching. Variable name is passed in r2 and the global | 1277 // Use inline caching. Variable name is passed in r2 and the global |
| 1274 // object (receiver) in r0. | 1278 // object (receiver) in r0. |
| 1275 __ ldr(r0, GlobalObjectOperand()); | 1279 __ ldr(r0, GlobalObjectOperand()); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 } | 1590 } |
| 1587 break; | 1591 break; |
| 1588 } | 1592 } |
| 1589 | 1593 |
| 1590 // For compound assignments we need another deoptimization point after the | 1594 // For compound assignments we need another deoptimization point after the |
| 1591 // variable/property load. | 1595 // variable/property load. |
| 1592 if (expr->is_compound()) { | 1596 if (expr->is_compound()) { |
| 1593 { AccumulatorValueContext context(this); | 1597 { AccumulatorValueContext context(this); |
| 1594 switch (assign_type) { | 1598 switch (assign_type) { |
| 1595 case VARIABLE: | 1599 case VARIABLE: |
| 1596 EmitVariableLoad(expr->target()->AsVariableProxy()->var()); | 1600 EmitVariableLoad(expr->target()->AsVariableProxy()); |
| 1597 PrepareForBailout(expr->target(), TOS_REG); | 1601 PrepareForBailout(expr->target(), TOS_REG); |
| 1598 break; | 1602 break; |
| 1599 case NAMED_PROPERTY: | 1603 case NAMED_PROPERTY: |
| 1600 EmitNamedPropertyLoad(property); | 1604 EmitNamedPropertyLoad(property); |
| 1601 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); | 1605 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); |
| 1602 break; | 1606 break; |
| 1603 case KEYED_PROPERTY: | 1607 case KEYED_PROPERTY: |
| 1604 EmitKeyedPropertyLoad(property); | 1608 EmitKeyedPropertyLoad(property); |
| 1605 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); | 1609 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); |
| 1606 break; | 1610 break; |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2765 | 2769 |
| 2766 void FullCodeGenerator::EmitLog(ZoneList<Expression*>* args) { | 2770 void FullCodeGenerator::EmitLog(ZoneList<Expression*>* args) { |
| 2767 // Conditionally generate a log call. | 2771 // Conditionally generate a log call. |
| 2768 // Args: | 2772 // Args: |
| 2769 // 0 (literal string): The type of logging (corresponds to the flags). | 2773 // 0 (literal string): The type of logging (corresponds to the flags). |
| 2770 // This is used to determine whether or not to generate the log call. | 2774 // This is used to determine whether or not to generate the log call. |
| 2771 // 1 (string): Format string. Access the string at argument index 2 | 2775 // 1 (string): Format string. Access the string at argument index 2 |
| 2772 // with '%2s' (see Logger::LogRuntime for all the formats). | 2776 // with '%2s' (see Logger::LogRuntime for all the formats). |
| 2773 // 2 (array): Arguments to the format string. | 2777 // 2 (array): Arguments to the format string. |
| 2774 ASSERT_EQ(args->length(), 3); | 2778 ASSERT_EQ(args->length(), 3); |
| 2775 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 2776 if (CodeGenerator::ShouldGenerateLog(args->at(0))) { | 2779 if (CodeGenerator::ShouldGenerateLog(args->at(0))) { |
| 2777 VisitForStackValue(args->at(1)); | 2780 VisitForStackValue(args->at(1)); |
| 2778 VisitForStackValue(args->at(2)); | 2781 VisitForStackValue(args->at(2)); |
| 2779 __ CallRuntime(Runtime::kLog, 2); | 2782 __ CallRuntime(Runtime::kLog, 2); |
| 2780 } | 2783 } |
| 2781 #endif | 2784 |
| 2782 // Finally, we're expected to leave a value on the top of the stack. | 2785 // Finally, we're expected to leave a value on the top of the stack. |
| 2783 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 2786 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 2784 context()->Plug(r0); | 2787 context()->Plug(r0); |
| 2785 } | 2788 } |
| 2786 | 2789 |
| 2787 | 2790 |
| 2788 void FullCodeGenerator::EmitRandomHeapNumber(ZoneList<Expression*>* args) { | 2791 void FullCodeGenerator::EmitRandomHeapNumber(ZoneList<Expression*>* args) { |
| 2789 ASSERT(args->length() == 0); | 2792 ASSERT(args->length() == 0); |
| 2790 | 2793 |
| 2791 Label slow_allocate_heapnumber; | 2794 Label slow_allocate_heapnumber; |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3809 // of the key to detect a named property. | 3812 // of the key to detect a named property. |
| 3810 if (prop != NULL) { | 3813 if (prop != NULL) { |
| 3811 assign_type = | 3814 assign_type = |
| 3812 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; | 3815 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; |
| 3813 } | 3816 } |
| 3814 | 3817 |
| 3815 // Evaluate expression and get value. | 3818 // Evaluate expression and get value. |
| 3816 if (assign_type == VARIABLE) { | 3819 if (assign_type == VARIABLE) { |
| 3817 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); | 3820 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); |
| 3818 AccumulatorValueContext context(this); | 3821 AccumulatorValueContext context(this); |
| 3819 EmitVariableLoad(expr->expression()->AsVariableProxy()->var()); | 3822 EmitVariableLoad(expr->expression()->AsVariableProxy()); |
| 3820 } else { | 3823 } else { |
| 3821 // Reserve space for result of postfix operation. | 3824 // Reserve space for result of postfix operation. |
| 3822 if (expr->is_postfix() && !context()->IsEffect()) { | 3825 if (expr->is_postfix() && !context()->IsEffect()) { |
| 3823 __ mov(ip, Operand(Smi::FromInt(0))); | 3826 __ mov(ip, Operand(Smi::FromInt(0))); |
| 3824 __ push(ip); | 3827 __ push(ip); |
| 3825 } | 3828 } |
| 3826 if (assign_type == NAMED_PROPERTY) { | 3829 if (assign_type == NAMED_PROPERTY) { |
| 3827 // Put the object both on the stack and in the accumulator. | 3830 // Put the object both on the stack and in the accumulator. |
| 3828 VisitForAccumulatorValue(prop->obj()); | 3831 VisitForAccumulatorValue(prop->obj()); |
| 3829 __ push(r0); | 3832 __ push(r0); |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4289 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. | 4292 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. |
| 4290 __ add(pc, r1, Operand(masm_->CodeObject())); | 4293 __ add(pc, r1, Operand(masm_->CodeObject())); |
| 4291 } | 4294 } |
| 4292 | 4295 |
| 4293 | 4296 |
| 4294 #undef __ | 4297 #undef __ |
| 4295 | 4298 |
| 4296 } } // namespace v8::internal | 4299 } } // namespace v8::internal |
| 4297 | 4300 |
| 4298 #endif // V8_TARGET_ARCH_ARM | 4301 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |