| 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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 } else if (prop != NULL) { | 737 } else if (prop != NULL) { |
| 738 // A const declaration aliasing a parameter is an illegal redeclaration. | 738 // A const declaration aliasing a parameter is an illegal redeclaration. |
| 739 ASSERT(mode != Variable::CONST); | 739 ASSERT(mode != Variable::CONST); |
| 740 if (function != NULL) { | 740 if (function != NULL) { |
| 741 // We are declaring a function that rewrites to a property. | 741 // We are declaring a function that rewrites to a property. |
| 742 // Use (keyed) IC to set the initial value. We cannot visit the | 742 // Use (keyed) IC to set the initial value. We cannot visit the |
| 743 // rewrite because it's shared and we risk recording duplicate AST | 743 // rewrite because it's shared and we risk recording duplicate AST |
| 744 // IDs for bailouts from optimized code. | 744 // IDs for bailouts from optimized code. |
| 745 ASSERT(prop->obj()->AsVariableProxy() != NULL); | 745 ASSERT(prop->obj()->AsVariableProxy() != NULL); |
| 746 { AccumulatorValueContext for_object(this); | 746 { AccumulatorValueContext for_object(this); |
| 747 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); | 747 EmitVariableLoad(prop->obj()->AsVariableProxy()); |
| 748 } | 748 } |
| 749 | 749 |
| 750 __ push(eax); | 750 __ push(eax); |
| 751 VisitForAccumulatorValue(function); | 751 VisitForAccumulatorValue(function); |
| 752 __ pop(edx); | 752 __ pop(edx); |
| 753 | 753 |
| 754 ASSERT(prop->key()->AsLiteral() != NULL && | 754 ASSERT(prop->key()->AsLiteral() != NULL && |
| 755 prop->key()->AsLiteral()->handle()->IsSmi()); | 755 prop->key()->AsLiteral()->handle()->IsSmi()); |
| 756 __ SafeSet(ecx, Immediate(prop->key()->AsLiteral()->handle())); | 756 __ SafeSet(ecx, Immediate(prop->key()->AsLiteral()->handle())); |
| 757 | 757 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 ? isolate()->factory()->true_value() | 1057 ? isolate()->factory()->true_value() |
| 1058 : isolate()->factory()->false_value())); | 1058 : isolate()->factory()->false_value())); |
| 1059 __ CallRuntime(Runtime::kNewClosure, 3); | 1059 __ CallRuntime(Runtime::kNewClosure, 3); |
| 1060 } | 1060 } |
| 1061 context()->Plug(eax); | 1061 context()->Plug(eax); |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 | 1064 |
| 1065 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | 1065 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
| 1066 Comment cmnt(masm_, "[ VariableProxy"); | 1066 Comment cmnt(masm_, "[ VariableProxy"); |
| 1067 EmitVariableLoad(expr->var()); | 1067 EmitVariableLoad(expr); |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 | 1070 |
| 1071 void FullCodeGenerator::EmitLoadGlobalSlotCheckExtensions( | 1071 void FullCodeGenerator::EmitLoadGlobalSlotCheckExtensions( |
| 1072 Slot* slot, | 1072 Slot* slot, |
| 1073 TypeofState typeof_state, | 1073 TypeofState typeof_state, |
| 1074 Label* slow) { | 1074 Label* slow) { |
| 1075 Register context = esi; | 1075 Register context = esi; |
| 1076 Register temp = edx; | 1076 Register temp = edx; |
| 1077 | 1077 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 isolate()->builtins()->KeyedLoadIC_Initialize(); | 1207 isolate()->builtins()->KeyedLoadIC_Initialize(); |
| 1208 __ call(ic, RelocInfo::CODE_TARGET, GetPropertyId(property)); | 1208 __ call(ic, RelocInfo::CODE_TARGET, GetPropertyId(property)); |
| 1209 __ jmp(done); | 1209 __ jmp(done); |
| 1210 } | 1210 } |
| 1211 } | 1211 } |
| 1212 } | 1212 } |
| 1213 } | 1213 } |
| 1214 } | 1214 } |
| 1215 | 1215 |
| 1216 | 1216 |
| 1217 void FullCodeGenerator::EmitVariableLoad(Variable* var) { | 1217 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { |
| 1218 // Record position before possible IC call. |
| 1219 SetSourcePosition(proxy->position()); |
| 1220 Variable* var = proxy->var(); |
| 1221 |
| 1218 // Three cases: non-this global variables, lookup slots, and all other | 1222 // Three cases: non-this global variables, lookup slots, and all other |
| 1219 // types of slots. | 1223 // types of slots. |
| 1220 Slot* slot = var->AsSlot(); | 1224 Slot* slot = var->AsSlot(); |
| 1221 ASSERT((var->is_global() && !var->is_this()) == (slot == NULL)); | 1225 ASSERT((var->is_global() && !var->is_this()) == (slot == NULL)); |
| 1222 | 1226 |
| 1223 if (slot == NULL) { | 1227 if (slot == NULL) { |
| 1224 Comment cmnt(masm_, "Global variable"); | 1228 Comment cmnt(masm_, "Global variable"); |
| 1225 // Use inline caching. Variable name is passed in ecx and the global | 1229 // Use inline caching. Variable name is passed in ecx and the global |
| 1226 // object on the stack. | 1230 // object on the stack. |
| 1227 __ mov(eax, GlobalObjectOperand()); | 1231 __ mov(eax, GlobalObjectOperand()); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 break; | 1537 break; |
| 1534 } | 1538 } |
| 1535 } | 1539 } |
| 1536 | 1540 |
| 1537 // For compound assignments we need another deoptimization point after the | 1541 // For compound assignments we need another deoptimization point after the |
| 1538 // variable/property load. | 1542 // variable/property load. |
| 1539 if (expr->is_compound()) { | 1543 if (expr->is_compound()) { |
| 1540 { AccumulatorValueContext context(this); | 1544 { AccumulatorValueContext context(this); |
| 1541 switch (assign_type) { | 1545 switch (assign_type) { |
| 1542 case VARIABLE: | 1546 case VARIABLE: |
| 1543 EmitVariableLoad(expr->target()->AsVariableProxy()->var()); | 1547 EmitVariableLoad(expr->target()->AsVariableProxy()); |
| 1544 PrepareForBailout(expr->target(), TOS_REG); | 1548 PrepareForBailout(expr->target(), TOS_REG); |
| 1545 break; | 1549 break; |
| 1546 case NAMED_PROPERTY: | 1550 case NAMED_PROPERTY: |
| 1547 EmitNamedPropertyLoad(property); | 1551 EmitNamedPropertyLoad(property); |
| 1548 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); | 1552 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); |
| 1549 break; | 1553 break; |
| 1550 case KEYED_PROPERTY: | 1554 case KEYED_PROPERTY: |
| 1551 EmitKeyedPropertyLoad(property); | 1555 EmitKeyedPropertyLoad(property); |
| 1552 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); | 1556 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); |
| 1553 break; | 1557 break; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 : isolate()->builtins()->StoreIC_Initialize(); | 1766 : isolate()->builtins()->StoreIC_Initialize(); |
| 1763 __ call(ic); | 1767 __ call(ic); |
| 1764 break; | 1768 break; |
| 1765 } | 1769 } |
| 1766 case KEYED_PROPERTY: { | 1770 case KEYED_PROPERTY: { |
| 1767 __ push(eax); // Preserve value. | 1771 __ push(eax); // Preserve value. |
| 1768 if (prop->is_synthetic()) { | 1772 if (prop->is_synthetic()) { |
| 1769 ASSERT(prop->obj()->AsVariableProxy() != NULL); | 1773 ASSERT(prop->obj()->AsVariableProxy() != NULL); |
| 1770 ASSERT(prop->key()->AsLiteral() != NULL); | 1774 ASSERT(prop->key()->AsLiteral() != NULL); |
| 1771 { AccumulatorValueContext for_object(this); | 1775 { AccumulatorValueContext for_object(this); |
| 1772 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); | 1776 EmitVariableLoad(prop->obj()->AsVariableProxy()); |
| 1773 } | 1777 } |
| 1774 __ mov(edx, eax); | 1778 __ mov(edx, eax); |
| 1775 __ SafeSet(ecx, Immediate(prop->key()->AsLiteral()->handle())); | 1779 __ SafeSet(ecx, Immediate(prop->key()->AsLiteral()->handle())); |
| 1776 } else { | 1780 } else { |
| 1777 VisitForStackValue(prop->obj()); | 1781 VisitForStackValue(prop->obj()); |
| 1778 VisitForAccumulatorValue(prop->key()); | 1782 VisitForAccumulatorValue(prop->key()); |
| 1779 __ mov(ecx, eax); | 1783 __ mov(ecx, eax); |
| 1780 __ pop(edx); | 1784 __ pop(edx); |
| 1781 } | 1785 } |
| 1782 __ pop(eax); // Restore value. | 1786 __ pop(eax); // Restore value. |
| (...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3761 // of the key to detect a named property. | 3765 // of the key to detect a named property. |
| 3762 if (prop != NULL) { | 3766 if (prop != NULL) { |
| 3763 assign_type = | 3767 assign_type = |
| 3764 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; | 3768 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; |
| 3765 } | 3769 } |
| 3766 | 3770 |
| 3767 // Evaluate expression and get value. | 3771 // Evaluate expression and get value. |
| 3768 if (assign_type == VARIABLE) { | 3772 if (assign_type == VARIABLE) { |
| 3769 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); | 3773 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); |
| 3770 AccumulatorValueContext context(this); | 3774 AccumulatorValueContext context(this); |
| 3771 EmitVariableLoad(expr->expression()->AsVariableProxy()->var()); | 3775 EmitVariableLoad(expr->expression()->AsVariableProxy()); |
| 3772 } else { | 3776 } else { |
| 3773 // Reserve space for result of postfix operation. | 3777 // Reserve space for result of postfix operation. |
| 3774 if (expr->is_postfix() && !context()->IsEffect()) { | 3778 if (expr->is_postfix() && !context()->IsEffect()) { |
| 3775 __ push(Immediate(Smi::FromInt(0))); | 3779 __ push(Immediate(Smi::FromInt(0))); |
| 3776 } | 3780 } |
| 3777 if (assign_type == NAMED_PROPERTY) { | 3781 if (assign_type == NAMED_PROPERTY) { |
| 3778 // Put the object both on the stack and in the accumulator. | 3782 // Put the object both on the stack and in the accumulator. |
| 3779 VisitForAccumulatorValue(prop->obj()); | 3783 VisitForAccumulatorValue(prop->obj()); |
| 3780 __ push(eax); | 3784 __ push(eax); |
| 3781 EmitNamedPropertyLoad(prop); | 3785 EmitNamedPropertyLoad(prop); |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4247 __ add(Operand(edx), Immediate(masm_->CodeObject())); | 4251 __ add(Operand(edx), Immediate(masm_->CodeObject())); |
| 4248 __ jmp(Operand(edx)); | 4252 __ jmp(Operand(edx)); |
| 4249 } | 4253 } |
| 4250 | 4254 |
| 4251 | 4255 |
| 4252 #undef __ | 4256 #undef __ |
| 4253 | 4257 |
| 4254 } } // namespace v8::internal | 4258 } } // namespace v8::internal |
| 4255 | 4259 |
| 4256 #endif // V8_TARGET_ARCH_IA32 | 4260 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |