OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 SetSourcePosition(prop->position()); | 2280 SetSourcePosition(prop->position()); |
2281 Literal* key = prop->key()->AsLiteral(); | 2281 Literal* key = prop->key()->AsLiteral(); |
2282 DCHECK(!key->value()->IsSmi()); | 2282 DCHECK(!key->value()->IsSmi()); |
2283 DCHECK(prop->IsSuperAccess()); | 2283 DCHECK(prop->IsSuperAccess()); |
2284 | 2284 |
2285 __ push(Immediate(key->value())); | 2285 __ push(Immediate(key->value())); |
2286 __ CallRuntime(Runtime::kLoadFromSuper, 3); | 2286 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
2287 } | 2287 } |
2288 | 2288 |
2289 | 2289 |
| 2290 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
| 2291 // Stack: receiver, home_object, key. |
| 2292 SetSourcePosition(prop->position()); |
| 2293 |
| 2294 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
| 2295 } |
| 2296 |
| 2297 |
2290 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2298 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2291 SetSourcePosition(prop->position()); | 2299 SetSourcePosition(prop->position()); |
2292 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2300 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2293 if (FLAG_vector_ics) { | 2301 if (FLAG_vector_ics) { |
2294 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2302 __ mov(VectorLoadICDescriptor::SlotRegister(), |
2295 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2303 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
2296 CallIC(ic); | 2304 CallIC(ic); |
2297 } else { | 2305 } else { |
2298 CallIC(ic, prop->PropertyFeedbackId()); | 2306 CallIC(ic, prop->PropertyFeedbackId()); |
2299 } | 2307 } |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2598 EmitNamedPropertyLoad(expr); | 2606 EmitNamedPropertyLoad(expr); |
2599 } else { | 2607 } else { |
2600 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); | 2608 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); |
2601 EmitLoadHomeObject(expr->obj()->AsSuperReference()); | 2609 EmitLoadHomeObject(expr->obj()->AsSuperReference()); |
2602 __ push(result_register()); | 2610 __ push(result_register()); |
2603 EmitNamedSuperPropertyLoad(expr); | 2611 EmitNamedSuperPropertyLoad(expr); |
2604 } | 2612 } |
2605 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2613 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
2606 context()->Plug(eax); | 2614 context()->Plug(eax); |
2607 } else { | 2615 } else { |
2608 VisitForStackValue(expr->obj()); | 2616 if (!expr->IsSuperAccess()) { |
2609 VisitForAccumulatorValue(expr->key()); | 2617 VisitForStackValue(expr->obj()); |
2610 __ pop(LoadDescriptor::ReceiverRegister()); // Object. | 2618 VisitForAccumulatorValue(expr->key()); |
2611 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key. | 2619 __ pop(LoadDescriptor::ReceiverRegister()); // Object. |
2612 EmitKeyedPropertyLoad(expr); | 2620 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key. |
| 2621 EmitKeyedPropertyLoad(expr); |
| 2622 } else { |
| 2623 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); |
| 2624 EmitLoadHomeObject(expr->obj()->AsSuperReference()); |
| 2625 __ push(result_register()); |
| 2626 VisitForStackValue(expr->key()); |
| 2627 EmitKeyedSuperPropertyLoad(expr); |
| 2628 } |
2613 context()->Plug(eax); | 2629 context()->Plug(eax); |
2614 } | 2630 } |
2615 } | 2631 } |
2616 | 2632 |
2617 | 2633 |
2618 void FullCodeGenerator::CallIC(Handle<Code> code, | 2634 void FullCodeGenerator::CallIC(Handle<Code> code, |
2619 TypeFeedbackId ast_id) { | 2635 TypeFeedbackId ast_id) { |
2620 ic_total_count_++; | 2636 ic_total_count_++; |
2621 __ call(code, RelocInfo::CODE_TARGET, ast_id); | 2637 __ call(code, RelocInfo::CODE_TARGET, ast_id); |
2622 } | 2638 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2705 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2721 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
2706 | 2722 |
2707 // Push the target function under the receiver. | 2723 // Push the target function under the receiver. |
2708 __ push(Operand(esp, 0)); | 2724 __ push(Operand(esp, 0)); |
2709 __ mov(Operand(esp, kPointerSize), eax); | 2725 __ mov(Operand(esp, kPointerSize), eax); |
2710 | 2726 |
2711 EmitCall(expr, CallICState::METHOD); | 2727 EmitCall(expr, CallICState::METHOD); |
2712 } | 2728 } |
2713 | 2729 |
2714 | 2730 |
| 2731 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
| 2732 Expression* callee = expr->expression(); |
| 2733 DCHECK(callee->IsProperty()); |
| 2734 Property* prop = callee->AsProperty(); |
| 2735 DCHECK(prop->IsSuperAccess()); |
| 2736 |
| 2737 SetSourcePosition(prop->position()); |
| 2738 // Load the function from the receiver. |
| 2739 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); |
| 2740 EmitLoadHomeObject(super_ref); |
| 2741 __ push(eax); |
| 2742 VisitForAccumulatorValue(super_ref->this_var()); |
| 2743 __ push(eax); |
| 2744 __ push(eax); |
| 2745 __ push(Operand(esp, kPointerSize * 2)); |
| 2746 VisitForStackValue(prop->key()); |
| 2747 // Stack here: |
| 2748 // - home_object |
| 2749 // - this (receiver) |
| 2750 // - this (receiver) <-- LoadFromSuper will pop here and below. |
| 2751 // - home_object |
| 2752 // - key |
| 2753 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
| 2754 |
| 2755 // Replace home_object with target function. |
| 2756 __ mov(Operand(esp, kPointerSize), eax); |
| 2757 |
| 2758 // Stack here: |
| 2759 // - target function |
| 2760 // - this (receiver) |
| 2761 EmitCall(expr, CallICState::METHOD); |
| 2762 } |
| 2763 |
| 2764 |
2715 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { | 2765 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { |
2716 // Load the arguments. | 2766 // Load the arguments. |
2717 ZoneList<Expression*>* args = expr->arguments(); | 2767 ZoneList<Expression*>* args = expr->arguments(); |
2718 int arg_count = args->length(); | 2768 int arg_count = args->length(); |
2719 { PreservePositionScope scope(masm()->positions_recorder()); | 2769 { PreservePositionScope scope(masm()->positions_recorder()); |
2720 for (int i = 0; i < arg_count; i++) { | 2770 for (int i = 0; i < arg_count; i++) { |
2721 VisitForStackValue(args->at(i)); | 2771 VisitForStackValue(args->at(i)); |
2722 } | 2772 } |
2723 } | 2773 } |
2724 | 2774 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2846 __ bind(&call); | 2896 __ bind(&call); |
2847 } | 2897 } |
2848 | 2898 |
2849 // The receiver is either the global receiver or an object found by | 2899 // The receiver is either the global receiver or an object found by |
2850 // LoadContextSlot. | 2900 // LoadContextSlot. |
2851 EmitCall(expr); | 2901 EmitCall(expr); |
2852 | 2902 |
2853 } else if (call_type == Call::PROPERTY_CALL) { | 2903 } else if (call_type == Call::PROPERTY_CALL) { |
2854 Property* property = callee->AsProperty(); | 2904 Property* property = callee->AsProperty(); |
2855 bool is_named_call = property->key()->IsPropertyName(); | 2905 bool is_named_call = property->key()->IsPropertyName(); |
2856 // super.x() is handled in EmitCallWithLoadIC. | 2906 if (property->IsSuperAccess()) { |
2857 if (property->IsSuperAccess() && is_named_call) { | 2907 if (is_named_call) { |
2858 EmitSuperCallWithLoadIC(expr); | 2908 EmitSuperCallWithLoadIC(expr); |
| 2909 } else { |
| 2910 EmitKeyedSuperCallWithLoadIC(expr); |
| 2911 } |
2859 } else { | 2912 } else { |
2860 { | 2913 { |
2861 PreservePositionScope scope(masm()->positions_recorder()); | 2914 PreservePositionScope scope(masm()->positions_recorder()); |
2862 VisitForStackValue(property->obj()); | 2915 VisitForStackValue(property->obj()); |
2863 } | 2916 } |
2864 if (is_named_call) { | 2917 if (is_named_call) { |
2865 EmitCallWithLoadIC(expr); | 2918 EmitCallWithLoadIC(expr); |
2866 } else { | 2919 } else { |
2867 EmitKeyedCallWithLoadIC(expr, property->key()); | 2920 EmitKeyedCallWithLoadIC(expr, property->key()); |
2868 } | 2921 } |
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4979 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5032 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4980 Assembler::target_address_at(call_target_address, | 5033 Assembler::target_address_at(call_target_address, |
4981 unoptimized_code)); | 5034 unoptimized_code)); |
4982 return OSR_AFTER_STACK_CHECK; | 5035 return OSR_AFTER_STACK_CHECK; |
4983 } | 5036 } |
4984 | 5037 |
4985 | 5038 |
4986 } } // namespace v8::internal | 5039 } } // namespace v8::internal |
4987 | 5040 |
4988 #endif // V8_TARGET_ARCH_IA32 | 5041 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |