| 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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 } else if (prop != NULL) { | 734 } else if (prop != NULL) { |
| 735 // A const declaration aliasing a parameter is an illegal redeclaration. | 735 // A const declaration aliasing a parameter is an illegal redeclaration. |
| 736 ASSERT(mode != Variable::CONST); | 736 ASSERT(mode != Variable::CONST); |
| 737 if (function != NULL) { | 737 if (function != NULL) { |
| 738 // We are declaring a function that rewrites to a property. | 738 // We are declaring a function that rewrites to a property. |
| 739 // Use (keyed) IC to set the initial value. We cannot visit the | 739 // Use (keyed) IC to set the initial value. We cannot visit the |
| 740 // rewrite because it's shared and we risk recording duplicate AST | 740 // rewrite because it's shared and we risk recording duplicate AST |
| 741 // IDs for bailouts from optimized code. | 741 // IDs for bailouts from optimized code. |
| 742 ASSERT(prop->obj()->AsVariableProxy() != NULL); | 742 ASSERT(prop->obj()->AsVariableProxy() != NULL); |
| 743 { AccumulatorValueContext for_object(this); | 743 { AccumulatorValueContext for_object(this); |
| 744 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); | 744 EmitVariableLoad(prop->obj()->AsVariableProxy()); |
| 745 } | 745 } |
| 746 __ push(rax); | 746 __ push(rax); |
| 747 VisitForAccumulatorValue(function); | 747 VisitForAccumulatorValue(function); |
| 748 __ pop(rdx); | 748 __ pop(rdx); |
| 749 ASSERT(prop->key()->AsLiteral() != NULL && | 749 ASSERT(prop->key()->AsLiteral() != NULL && |
| 750 prop->key()->AsLiteral()->handle()->IsSmi()); | 750 prop->key()->AsLiteral()->handle()->IsSmi()); |
| 751 __ Move(rcx, prop->key()->AsLiteral()->handle()); | 751 __ Move(rcx, prop->key()->AsLiteral()->handle()); |
| 752 | 752 |
| 753 Handle<Code> ic = is_strict_mode() | 753 Handle<Code> ic = is_strict_mode() |
| 754 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() | 754 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 ? isolate()->factory()->true_value() | 1064 ? isolate()->factory()->true_value() |
| 1065 : isolate()->factory()->false_value()); | 1065 : isolate()->factory()->false_value()); |
| 1066 __ CallRuntime(Runtime::kNewClosure, 3); | 1066 __ CallRuntime(Runtime::kNewClosure, 3); |
| 1067 } | 1067 } |
| 1068 context()->Plug(rax); | 1068 context()->Plug(rax); |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 | 1071 |
| 1072 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | 1072 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
| 1073 Comment cmnt(masm_, "[ VariableProxy"); | 1073 Comment cmnt(masm_, "[ VariableProxy"); |
| 1074 EmitVariableLoad(expr->var()); | 1074 EmitVariableLoad(expr); |
| 1075 } | 1075 } |
| 1076 | 1076 |
| 1077 | 1077 |
| 1078 void FullCodeGenerator::EmitLoadGlobalSlotCheckExtensions( | 1078 void FullCodeGenerator::EmitLoadGlobalSlotCheckExtensions( |
| 1079 Slot* slot, | 1079 Slot* slot, |
| 1080 TypeofState typeof_state, | 1080 TypeofState typeof_state, |
| 1081 Label* slow) { | 1081 Label* slow) { |
| 1082 Register context = rsi; | 1082 Register context = rsi; |
| 1083 Register temp = rdx; | 1083 Register temp = rdx; |
| 1084 | 1084 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 isolate()->builtins()->KeyedLoadIC_Initialize(); | 1215 isolate()->builtins()->KeyedLoadIC_Initialize(); |
| 1216 __ call(ic, RelocInfo::CODE_TARGET, GetPropertyId(property)); | 1216 __ call(ic, RelocInfo::CODE_TARGET, GetPropertyId(property)); |
| 1217 __ jmp(done); | 1217 __ jmp(done); |
| 1218 } | 1218 } |
| 1219 } | 1219 } |
| 1220 } | 1220 } |
| 1221 } | 1221 } |
| 1222 } | 1222 } |
| 1223 | 1223 |
| 1224 | 1224 |
| 1225 void FullCodeGenerator::EmitVariableLoad(Variable* var) { | 1225 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { |
| 1226 // Record position before possible IC call. |
| 1227 SetSourcePosition(proxy->position()); |
| 1228 Variable* var = proxy->var(); |
| 1229 |
| 1226 // Three cases: non-this global variables, lookup slots, and all other | 1230 // Three cases: non-this global variables, lookup slots, and all other |
| 1227 // types of slots. | 1231 // types of slots. |
| 1228 Slot* slot = var->AsSlot(); | 1232 Slot* slot = var->AsSlot(); |
| 1229 ASSERT((var->is_global() && !var->is_this()) == (slot == NULL)); | 1233 ASSERT((var->is_global() && !var->is_this()) == (slot == NULL)); |
| 1230 | 1234 |
| 1231 if (slot == NULL) { | 1235 if (slot == NULL) { |
| 1232 Comment cmnt(masm_, "Global variable"); | 1236 Comment cmnt(masm_, "Global variable"); |
| 1233 // Use inline caching. Variable name is passed in rcx and the global | 1237 // Use inline caching. Variable name is passed in rcx and the global |
| 1234 // object on the stack. | 1238 // object on the stack. |
| 1235 __ Move(rcx, var->name()); | 1239 __ Move(rcx, var->name()); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 break; | 1545 break; |
| 1542 } | 1546 } |
| 1543 } | 1547 } |
| 1544 | 1548 |
| 1545 // For compound assignments we need another deoptimization point after the | 1549 // For compound assignments we need another deoptimization point after the |
| 1546 // variable/property load. | 1550 // variable/property load. |
| 1547 if (expr->is_compound()) { | 1551 if (expr->is_compound()) { |
| 1548 { AccumulatorValueContext context(this); | 1552 { AccumulatorValueContext context(this); |
| 1549 switch (assign_type) { | 1553 switch (assign_type) { |
| 1550 case VARIABLE: | 1554 case VARIABLE: |
| 1551 EmitVariableLoad(expr->target()->AsVariableProxy()->var()); | 1555 EmitVariableLoad(expr->target()->AsVariableProxy()); |
| 1552 PrepareForBailout(expr->target(), TOS_REG); | 1556 PrepareForBailout(expr->target(), TOS_REG); |
| 1553 break; | 1557 break; |
| 1554 case NAMED_PROPERTY: | 1558 case NAMED_PROPERTY: |
| 1555 EmitNamedPropertyLoad(property); | 1559 EmitNamedPropertyLoad(property); |
| 1556 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); | 1560 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); |
| 1557 break; | 1561 break; |
| 1558 case KEYED_PROPERTY: | 1562 case KEYED_PROPERTY: |
| 1559 EmitKeyedPropertyLoad(property); | 1563 EmitKeyedPropertyLoad(property); |
| 1560 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); | 1564 PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG); |
| 1561 break; | 1565 break; |
| (...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3739 // of the key to detect a named property. | 3743 // of the key to detect a named property. |
| 3740 if (prop != NULL) { | 3744 if (prop != NULL) { |
| 3741 assign_type = | 3745 assign_type = |
| 3742 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; | 3746 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; |
| 3743 } | 3747 } |
| 3744 | 3748 |
| 3745 // Evaluate expression and get value. | 3749 // Evaluate expression and get value. |
| 3746 if (assign_type == VARIABLE) { | 3750 if (assign_type == VARIABLE) { |
| 3747 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); | 3751 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); |
| 3748 AccumulatorValueContext context(this); | 3752 AccumulatorValueContext context(this); |
| 3749 EmitVariableLoad(expr->expression()->AsVariableProxy()->var()); | 3753 EmitVariableLoad(expr->expression()->AsVariableProxy()); |
| 3750 } else { | 3754 } else { |
| 3751 // Reserve space for result of postfix operation. | 3755 // Reserve space for result of postfix operation. |
| 3752 if (expr->is_postfix() && !context()->IsEffect()) { | 3756 if (expr->is_postfix() && !context()->IsEffect()) { |
| 3753 __ Push(Smi::FromInt(0)); | 3757 __ Push(Smi::FromInt(0)); |
| 3754 } | 3758 } |
| 3755 if (assign_type == NAMED_PROPERTY) { | 3759 if (assign_type == NAMED_PROPERTY) { |
| 3756 VisitForAccumulatorValue(prop->obj()); | 3760 VisitForAccumulatorValue(prop->obj()); |
| 3757 __ push(rax); // Copy of receiver, needed for later store. | 3761 __ push(rax); // Copy of receiver, needed for later store. |
| 3758 EmitNamedPropertyLoad(prop); | 3762 EmitNamedPropertyLoad(prop); |
| 3759 } else { | 3763 } else { |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4229 __ jmp(rdx); | 4233 __ jmp(rdx); |
| 4230 } | 4234 } |
| 4231 | 4235 |
| 4232 | 4236 |
| 4233 #undef __ | 4237 #undef __ |
| 4234 | 4238 |
| 4235 | 4239 |
| 4236 } } // namespace v8::internal | 4240 } } // namespace v8::internal |
| 4237 | 4241 |
| 4238 #endif // V8_TARGET_ARCH_X64 | 4242 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |