| 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_X87 | 7 #if V8_TARGET_ARCH_X87 |
| 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 if (FLAG_vector_ics) { | 2280 if (FLAG_vector_ics) { |
| 2281 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2281 __ mov(VectorLoadICDescriptor::SlotRegister(), |
| 2282 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2282 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
| 2283 CallIC(ic); | 2283 CallIC(ic); |
| 2284 } else { | 2284 } else { |
| 2285 CallIC(ic, prop->PropertyFeedbackId()); | 2285 CallIC(ic, prop->PropertyFeedbackId()); |
| 2286 } | 2286 } |
| 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::EmitInlineSmiBinaryOp(BinaryOperation* expr, | 2298 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, |
| 2291 Token::Value op, | 2299 Token::Value op, |
| 2292 OverwriteMode mode, | 2300 OverwriteMode mode, |
| 2293 Expression* left, | 2301 Expression* left, |
| 2294 Expression* right) { | 2302 Expression* right) { |
| 2295 // Do combined smi check of the operands. Left operand is on the | 2303 // Do combined smi check of the operands. Left operand is on the |
| 2296 // stack. Right operand is in eax. | 2304 // stack. Right operand is in eax. |
| 2297 Label smi_case, done, stub_call; | 2305 Label smi_case, done, stub_call; |
| 2298 __ pop(edx); | 2306 __ pop(edx); |
| 2299 __ mov(ecx, eax); | 2307 __ mov(ecx, eax); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 EmitNamedPropertyLoad(expr); | 2593 EmitNamedPropertyLoad(expr); |
| 2586 } else { | 2594 } else { |
| 2587 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); | 2595 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); |
| 2588 EmitLoadHomeObject(expr->obj()->AsSuperReference()); | 2596 EmitLoadHomeObject(expr->obj()->AsSuperReference()); |
| 2589 __ push(result_register()); | 2597 __ push(result_register()); |
| 2590 EmitNamedSuperPropertyLoad(expr); | 2598 EmitNamedSuperPropertyLoad(expr); |
| 2591 } | 2599 } |
| 2592 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2600 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
| 2593 context()->Plug(eax); | 2601 context()->Plug(eax); |
| 2594 } else { | 2602 } else { |
| 2595 VisitForStackValue(expr->obj()); | 2603 if (!expr->IsSuperAccess()) { |
| 2596 VisitForAccumulatorValue(expr->key()); | 2604 VisitForStackValue(expr->obj()); |
| 2597 __ pop(LoadDescriptor::ReceiverRegister()); // Object. | 2605 VisitForAccumulatorValue(expr->key()); |
| 2598 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key. | 2606 __ pop(LoadDescriptor::ReceiverRegister()); // Object. |
| 2599 EmitKeyedPropertyLoad(expr); | 2607 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key. |
| 2608 EmitKeyedPropertyLoad(expr); |
| 2609 } else { |
| 2610 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); |
| 2611 EmitLoadHomeObject(expr->obj()->AsSuperReference()); |
| 2612 __ push(result_register()); |
| 2613 VisitForStackValue(expr->key()); |
| 2614 EmitKeyedSuperPropertyLoad(expr); |
| 2615 } |
| 2600 context()->Plug(eax); | 2616 context()->Plug(eax); |
| 2601 } | 2617 } |
| 2602 } | 2618 } |
| 2603 | 2619 |
| 2604 | 2620 |
| 2605 void FullCodeGenerator::CallIC(Handle<Code> code, | 2621 void FullCodeGenerator::CallIC(Handle<Code> code, |
| 2606 TypeFeedbackId ast_id) { | 2622 TypeFeedbackId ast_id) { |
| 2607 ic_total_count_++; | 2623 ic_total_count_++; |
| 2608 __ call(code, RelocInfo::CODE_TARGET, ast_id); | 2624 __ call(code, RelocInfo::CODE_TARGET, ast_id); |
| 2609 } | 2625 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2692 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2708 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
| 2693 | 2709 |
| 2694 // Push the target function under the receiver. | 2710 // Push the target function under the receiver. |
| 2695 __ push(Operand(esp, 0)); | 2711 __ push(Operand(esp, 0)); |
| 2696 __ mov(Operand(esp, kPointerSize), eax); | 2712 __ mov(Operand(esp, kPointerSize), eax); |
| 2697 | 2713 |
| 2698 EmitCall(expr, CallICState::METHOD); | 2714 EmitCall(expr, CallICState::METHOD); |
| 2699 } | 2715 } |
| 2700 | 2716 |
| 2701 | 2717 |
| 2718 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
| 2719 Expression* callee = expr->expression(); |
| 2720 DCHECK(callee->IsProperty()); |
| 2721 Property* prop = callee->AsProperty(); |
| 2722 DCHECK(prop->IsSuperAccess()); |
| 2723 |
| 2724 SetSourcePosition(prop->position()); |
| 2725 // Load the function from the receiver. |
| 2726 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); |
| 2727 EmitLoadHomeObject(super_ref); |
| 2728 __ push(eax); |
| 2729 VisitForAccumulatorValue(super_ref->this_var()); |
| 2730 __ push(eax); |
| 2731 __ push(eax); |
| 2732 __ push(Operand(esp, kPointerSize * 2)); |
| 2733 VisitForStackValue(prop->key()); |
| 2734 // Stack here: |
| 2735 // - home_object |
| 2736 // - this (receiver) |
| 2737 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. |
| 2738 // - home_object |
| 2739 // - key |
| 2740 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
| 2741 |
| 2742 // Replace home_object with target function. |
| 2743 __ mov(Operand(esp, kPointerSize), eax); |
| 2744 |
| 2745 // Stack here: |
| 2746 // - target function |
| 2747 // - this (receiver) |
| 2748 EmitCall(expr, CallICState::METHOD); |
| 2749 } |
| 2750 |
| 2751 |
| 2702 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { | 2752 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { |
| 2703 // Load the arguments. | 2753 // Load the arguments. |
| 2704 ZoneList<Expression*>* args = expr->arguments(); | 2754 ZoneList<Expression*>* args = expr->arguments(); |
| 2705 int arg_count = args->length(); | 2755 int arg_count = args->length(); |
| 2706 { PreservePositionScope scope(masm()->positions_recorder()); | 2756 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2707 for (int i = 0; i < arg_count; i++) { | 2757 for (int i = 0; i < arg_count; i++) { |
| 2708 VisitForStackValue(args->at(i)); | 2758 VisitForStackValue(args->at(i)); |
| 2709 } | 2759 } |
| 2710 } | 2760 } |
| 2711 | 2761 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2833 __ bind(&call); | 2883 __ bind(&call); |
| 2834 } | 2884 } |
| 2835 | 2885 |
| 2836 // The receiver is either the global receiver or an object found by | 2886 // The receiver is either the global receiver or an object found by |
| 2837 // LoadContextSlot. | 2887 // LoadContextSlot. |
| 2838 EmitCall(expr); | 2888 EmitCall(expr); |
| 2839 | 2889 |
| 2840 } else if (call_type == Call::PROPERTY_CALL) { | 2890 } else if (call_type == Call::PROPERTY_CALL) { |
| 2841 Property* property = callee->AsProperty(); | 2891 Property* property = callee->AsProperty(); |
| 2842 bool is_named_call = property->key()->IsPropertyName(); | 2892 bool is_named_call = property->key()->IsPropertyName(); |
| 2843 // super.x() is handled in EmitCallWithLoadIC. | 2893 if (property->IsSuperAccess()) { |
| 2844 if (property->IsSuperAccess() && is_named_call) { | 2894 if (is_named_call) { |
| 2845 EmitSuperCallWithLoadIC(expr); | 2895 EmitSuperCallWithLoadIC(expr); |
| 2896 } else { |
| 2897 EmitKeyedSuperCallWithLoadIC(expr); |
| 2898 } |
| 2846 } else { | 2899 } else { |
| 2847 { | 2900 { |
| 2848 PreservePositionScope scope(masm()->positions_recorder()); | 2901 PreservePositionScope scope(masm()->positions_recorder()); |
| 2849 VisitForStackValue(property->obj()); | 2902 VisitForStackValue(property->obj()); |
| 2850 } | 2903 } |
| 2851 if (is_named_call) { | 2904 if (is_named_call) { |
| 2852 EmitCallWithLoadIC(expr); | 2905 EmitCallWithLoadIC(expr); |
| 2853 } else { | 2906 } else { |
| 2854 EmitKeyedCallWithLoadIC(expr, property->key()); | 2907 EmitKeyedCallWithLoadIC(expr, property->key()); |
| 2855 } | 2908 } |
| (...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4965 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5018 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4966 Assembler::target_address_at(call_target_address, | 5019 Assembler::target_address_at(call_target_address, |
| 4967 unoptimized_code)); | 5020 unoptimized_code)); |
| 4968 return OSR_AFTER_STACK_CHECK; | 5021 return OSR_AFTER_STACK_CHECK; |
| 4969 } | 5022 } |
| 4970 | 5023 |
| 4971 | 5024 |
| 4972 } } // namespace v8::internal | 5025 } } // namespace v8::internal |
| 4973 | 5026 |
| 4974 #endif // V8_TARGET_ARCH_X87 | 5027 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |