| 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 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2657 | 2661 |
| 2658 void FullCodeGenerator::EmitLog(ZoneList<Expression*>* args) { | 2662 void FullCodeGenerator::EmitLog(ZoneList<Expression*>* args) { |
| 2659 // Conditionally generate a log call. | 2663 // Conditionally generate a log call. |
| 2660 // Args: | 2664 // Args: |
| 2661 // 0 (literal string): The type of logging (corresponds to the flags). | 2665 // 0 (literal string): The type of logging (corresponds to the flags). |
| 2662 // This is used to determine whether or not to generate the log call. | 2666 // This is used to determine whether or not to generate the log call. |
| 2663 // 1 (string): Format string. Access the string at argument index 2 | 2667 // 1 (string): Format string. Access the string at argument index 2 |
| 2664 // with '%2s' (see Logger::LogRuntime for all the formats). | 2668 // with '%2s' (see Logger::LogRuntime for all the formats). |
| 2665 // 2 (array): Arguments to the format string. | 2669 // 2 (array): Arguments to the format string. |
| 2666 ASSERT_EQ(args->length(), 3); | 2670 ASSERT_EQ(args->length(), 3); |
| 2667 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 2668 if (CodeGenerator::ShouldGenerateLog(args->at(0))) { | 2671 if (CodeGenerator::ShouldGenerateLog(args->at(0))) { |
| 2669 VisitForStackValue(args->at(1)); | 2672 VisitForStackValue(args->at(1)); |
| 2670 VisitForStackValue(args->at(2)); | 2673 VisitForStackValue(args->at(2)); |
| 2671 __ CallRuntime(Runtime::kLog, 2); | 2674 __ CallRuntime(Runtime::kLog, 2); |
| 2672 } | 2675 } |
| 2673 #endif | |
| 2674 // Finally, we're expected to leave a value on the top of the stack. | 2676 // Finally, we're expected to leave a value on the top of the stack. |
| 2675 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | 2677 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
| 2676 context()->Plug(rax); | 2678 context()->Plug(rax); |
| 2677 } | 2679 } |
| 2678 | 2680 |
| 2679 | 2681 |
| 2680 void FullCodeGenerator::EmitRandomHeapNumber(ZoneList<Expression*>* args) { | 2682 void FullCodeGenerator::EmitRandomHeapNumber(ZoneList<Expression*>* args) { |
| 2681 ASSERT(args->length() == 0); | 2683 ASSERT(args->length() == 0); |
| 2682 | 2684 |
| 2683 Label slow_allocate_heapnumber; | 2685 Label slow_allocate_heapnumber; |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3739 // of the key to detect a named property. | 3741 // of the key to detect a named property. |
| 3740 if (prop != NULL) { | 3742 if (prop != NULL) { |
| 3741 assign_type = | 3743 assign_type = |
| 3742 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; | 3744 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; |
| 3743 } | 3745 } |
| 3744 | 3746 |
| 3745 // Evaluate expression and get value. | 3747 // Evaluate expression and get value. |
| 3746 if (assign_type == VARIABLE) { | 3748 if (assign_type == VARIABLE) { |
| 3747 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); | 3749 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); |
| 3748 AccumulatorValueContext context(this); | 3750 AccumulatorValueContext context(this); |
| 3749 EmitVariableLoad(expr->expression()->AsVariableProxy()->var()); | 3751 EmitVariableLoad(expr->expression()->AsVariableProxy()); |
| 3750 } else { | 3752 } else { |
| 3751 // Reserve space for result of postfix operation. | 3753 // Reserve space for result of postfix operation. |
| 3752 if (expr->is_postfix() && !context()->IsEffect()) { | 3754 if (expr->is_postfix() && !context()->IsEffect()) { |
| 3753 __ Push(Smi::FromInt(0)); | 3755 __ Push(Smi::FromInt(0)); |
| 3754 } | 3756 } |
| 3755 if (assign_type == NAMED_PROPERTY) { | 3757 if (assign_type == NAMED_PROPERTY) { |
| 3756 VisitForAccumulatorValue(prop->obj()); | 3758 VisitForAccumulatorValue(prop->obj()); |
| 3757 __ push(rax); // Copy of receiver, needed for later store. | 3759 __ push(rax); // Copy of receiver, needed for later store. |
| 3758 EmitNamedPropertyLoad(prop); | 3760 EmitNamedPropertyLoad(prop); |
| 3759 } else { | 3761 } else { |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4229 __ jmp(rdx); | 4231 __ jmp(rdx); |
| 4230 } | 4232 } |
| 4231 | 4233 |
| 4232 | 4234 |
| 4233 #undef __ | 4235 #undef __ |
| 4234 | 4236 |
| 4235 | 4237 |
| 4236 } } // namespace v8::internal | 4238 } } // namespace v8::internal |
| 4237 | 4239 |
| 4238 #endif // V8_TARGET_ARCH_X64 | 4240 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |