| 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 } else if (prop != NULL) { | 776 } else if (prop != NULL) { |
| 777 // A const declaration aliasing a parameter is an illegal redeclaration. | 777 // A const declaration aliasing a parameter is an illegal redeclaration. |
| 778 ASSERT(mode != Variable::CONST); | 778 ASSERT(mode != Variable::CONST); |
| 779 if (function != NULL) { | 779 if (function != NULL) { |
| 780 // We are declaring a function that rewrites to a property. | 780 // We are declaring a function that rewrites to a property. |
| 781 // Use (keyed) IC to set the initial value. We cannot visit the | 781 // Use (keyed) IC to set the initial value. We cannot visit the |
| 782 // rewrite because it's shared and we risk recording duplicate AST | 782 // rewrite because it's shared and we risk recording duplicate AST |
| 783 // IDs for bailouts from optimized code. | 783 // IDs for bailouts from optimized code. |
| 784 ASSERT(prop->obj()->AsVariableProxy() != NULL); | 784 ASSERT(prop->obj()->AsVariableProxy() != NULL); |
| 785 { AccumulatorValueContext for_object(this); | 785 { AccumulatorValueContext for_object(this); |
| 786 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); | 786 EmitVariableLoad(prop->obj()->AsVariableProxy()); |
| 787 } | 787 } |
| 788 | 788 |
| 789 __ push(result_register()); | 789 __ push(result_register()); |
| 790 VisitForAccumulatorValue(function); | 790 VisitForAccumulatorValue(function); |
| 791 __ mov(a0, result_register()); | 791 __ mov(a0, result_register()); |
| 792 __ pop(a2); | 792 __ pop(a2); |
| 793 | 793 |
| 794 ASSERT(prop->key()->AsLiteral() != NULL && | 794 ASSERT(prop->key()->AsLiteral() != NULL && |
| 795 prop->key()->AsLiteral()->handle()->IsSmi()); | 795 prop->key()->AsLiteral()->handle()->IsSmi()); |
| 796 __ li(a1, Operand(prop->key()->AsLiteral()->handle())); | 796 __ li(a1, Operand(prop->key()->AsLiteral()->handle())); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 : Heap::kFalseValueRootIndex); | 1110 : Heap::kFalseValueRootIndex); |
| 1111 __ Push(cp, a0, a1); | 1111 __ Push(cp, a0, a1); |
| 1112 __ CallRuntime(Runtime::kNewClosure, 3); | 1112 __ CallRuntime(Runtime::kNewClosure, 3); |
| 1113 } | 1113 } |
| 1114 context()->Plug(v0); | 1114 context()->Plug(v0); |
| 1115 } | 1115 } |
| 1116 | 1116 |
| 1117 | 1117 |
| 1118 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | 1118 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
| 1119 Comment cmnt(masm_, "[ VariableProxy"); | 1119 Comment cmnt(masm_, "[ VariableProxy"); |
| 1120 EmitVariableLoad(expr->var()); | 1120 EmitVariableLoad(expr); |
| 1121 } | 1121 } |
| 1122 | 1122 |
| 1123 | 1123 |
| 1124 void FullCodeGenerator::EmitLoadGlobalSlotCheckExtensions( | 1124 void FullCodeGenerator::EmitLoadGlobalSlotCheckExtensions( |
| 1125 Slot* slot, | 1125 Slot* slot, |
| 1126 TypeofState typeof_state, | 1126 TypeofState typeof_state, |
| 1127 Label* slow) { | 1127 Label* slow) { |
| 1128 Register current = cp; | 1128 Register current = cp; |
| 1129 Register next = a1; | 1129 Register next = a1; |
| 1130 Register temp = a2; | 1130 Register temp = a2; |
| (...skipping 124 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 __ Branch(done); | 1257 __ Branch(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 a2 and the global | 1277 // Use inline caching. Variable name is passed in a2 and the global |
| 1274 // object (receiver) in a0. | 1278 // object (receiver) in a0. |
| 1275 __ lw(a0, GlobalObjectOperand()); | 1279 __ lw(a0, GlobalObjectOperand()); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 } | 1595 } |
| 1592 break; | 1596 break; |
| 1593 } | 1597 } |
| 1594 | 1598 |
| 1595 // For compound assignments we need another deoptimization point after the | 1599 // For compound assignments we need another deoptimization point after the |
| 1596 // variable/property load. | 1600 // variable/property load. |
| 1597 if (expr->is_compound()) { | 1601 if (expr->is_compound()) { |
| 1598 { AccumulatorValueContext context(this); | 1602 { AccumulatorValueContext context(this); |
| 1599 switch (assign_type) { | 1603 switch (assign_type) { |
| 1600 case VARIABLE: | 1604 case VARIABLE: |
| 1601 EmitVariableLoad(expr->target()->AsVariableProxy()->var()); | 1605 EmitVariableLoad(expr->target()->AsVariableProxy()); |
| 1602 PrepareForBailout(expr->target(), TOS_REG); | 1606 PrepareForBailout(expr->target(), TOS_REG); |
| 1603 break; | 1607 break; |
| 1604 case NAMED_PROPERTY: | 1608 case NAMED_PROPERTY: |
| 1605 EmitNamedPropertyLoad(property); | 1609 EmitNamedPropertyLoad(property); |
| 1606 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); | 1610 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); |
| 1607 break; | 1611 break; |
| 1608 case KEYED_PROPERTY: | 1612 case KEYED_PROPERTY: |
| 1609 EmitKeyedPropertyLoad(property); | 1613 EmitKeyedPropertyLoad(property); |
| 1610 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); | 1614 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); |
| 1611 break; | 1615 break; |
| (...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2773 | 2777 |
| 2774 void FullCodeGenerator::EmitLog(ZoneList<Expression*>* args) { | 2778 void FullCodeGenerator::EmitLog(ZoneList<Expression*>* args) { |
| 2775 // Conditionally generate a log call. | 2779 // Conditionally generate a log call. |
| 2776 // Args: | 2780 // Args: |
| 2777 // 0 (literal string): The type of logging (corresponds to the flags). | 2781 // 0 (literal string): The type of logging (corresponds to the flags). |
| 2778 // This is used to determine whether or not to generate the log call. | 2782 // This is used to determine whether or not to generate the log call. |
| 2779 // 1 (string): Format string. Access the string at argument index 2 | 2783 // 1 (string): Format string. Access the string at argument index 2 |
| 2780 // with '%2s' (see Logger::LogRuntime for all the formats). | 2784 // with '%2s' (see Logger::LogRuntime for all the formats). |
| 2781 // 2 (array): Arguments to the format string. | 2785 // 2 (array): Arguments to the format string. |
| 2782 ASSERT_EQ(args->length(), 3); | 2786 ASSERT_EQ(args->length(), 3); |
| 2783 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 2784 if (CodeGenerator::ShouldGenerateLog(args->at(0))) { | 2787 if (CodeGenerator::ShouldGenerateLog(args->at(0))) { |
| 2785 VisitForStackValue(args->at(1)); | 2788 VisitForStackValue(args->at(1)); |
| 2786 VisitForStackValue(args->at(2)); | 2789 VisitForStackValue(args->at(2)); |
| 2787 __ CallRuntime(Runtime::kLog, 2); | 2790 __ CallRuntime(Runtime::kLog, 2); |
| 2788 } | 2791 } |
| 2789 #endif | 2792 |
| 2790 // Finally, we're expected to leave a value on the top of the stack. | 2793 // Finally, we're expected to leave a value on the top of the stack. |
| 2791 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex); | 2794 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex); |
| 2792 context()->Plug(v0); | 2795 context()->Plug(v0); |
| 2793 } | 2796 } |
| 2794 | 2797 |
| 2795 | 2798 |
| 2796 void FullCodeGenerator::EmitRandomHeapNumber(ZoneList<Expression*>* args) { | 2799 void FullCodeGenerator::EmitRandomHeapNumber(ZoneList<Expression*>* args) { |
| 2797 ASSERT(args->length() == 0); | 2800 ASSERT(args->length() == 0); |
| 2798 | 2801 |
| 2799 Label slow_allocate_heapnumber; | 2802 Label slow_allocate_heapnumber; |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3832 // of the key to detect a named property. | 3835 // of the key to detect a named property. |
| 3833 if (prop != NULL) { | 3836 if (prop != NULL) { |
| 3834 assign_type = | 3837 assign_type = |
| 3835 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; | 3838 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; |
| 3836 } | 3839 } |
| 3837 | 3840 |
| 3838 // Evaluate expression and get value. | 3841 // Evaluate expression and get value. |
| 3839 if (assign_type == VARIABLE) { | 3842 if (assign_type == VARIABLE) { |
| 3840 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); | 3843 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); |
| 3841 AccumulatorValueContext context(this); | 3844 AccumulatorValueContext context(this); |
| 3842 EmitVariableLoad(expr->expression()->AsVariableProxy()->var()); | 3845 EmitVariableLoad(expr->expression()->AsVariableProxy()); |
| 3843 } else { | 3846 } else { |
| 3844 // Reserve space for result of postfix operation. | 3847 // Reserve space for result of postfix operation. |
| 3845 if (expr->is_postfix() && !context()->IsEffect()) { | 3848 if (expr->is_postfix() && !context()->IsEffect()) { |
| 3846 __ li(at, Operand(Smi::FromInt(0))); | 3849 __ li(at, Operand(Smi::FromInt(0))); |
| 3847 __ push(at); | 3850 __ push(at); |
| 3848 } | 3851 } |
| 3849 if (assign_type == NAMED_PROPERTY) { | 3852 if (assign_type == NAMED_PROPERTY) { |
| 3850 // Put the object both on the stack and in the accumulator. | 3853 // Put the object both on the stack and in the accumulator. |
| 3851 VisitForAccumulatorValue(prop->obj()); | 3854 VisitForAccumulatorValue(prop->obj()); |
| 3852 __ push(v0); | 3855 __ push(v0); |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4309 __ Addu(at, a1, Operand(masm_->CodeObject())); | 4312 __ Addu(at, a1, Operand(masm_->CodeObject())); |
| 4310 __ Jump(at); | 4313 __ Jump(at); |
| 4311 } | 4314 } |
| 4312 | 4315 |
| 4313 | 4316 |
| 4314 #undef __ | 4317 #undef __ |
| 4315 | 4318 |
| 4316 } } // namespace v8::internal | 4319 } } // namespace v8::internal |
| 4317 | 4320 |
| 4318 #endif // V8_TARGET_ARCH_MIPS | 4321 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |