| 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_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 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 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2325 if (FLAG_vector_ics) { | 2325 if (FLAG_vector_ics) { |
| 2326 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2326 __ Move(VectorLoadICDescriptor::SlotRegister(), |
| 2327 Smi::FromInt(prop->PropertyFeedbackSlot())); | 2327 Smi::FromInt(prop->PropertyFeedbackSlot())); |
| 2328 CallIC(ic); | 2328 CallIC(ic); |
| 2329 } else { | 2329 } else { |
| 2330 CallIC(ic, prop->PropertyFeedbackId()); | 2330 CallIC(ic, prop->PropertyFeedbackId()); |
| 2331 } | 2331 } |
| 2332 } | 2332 } |
| 2333 | 2333 |
| 2334 | 2334 |
| 2335 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
| 2336 // Stack: receiver, home_object, key. |
| 2337 SetSourcePosition(prop->position()); |
| 2338 |
| 2339 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
| 2340 } |
| 2341 |
| 2342 |
| 2335 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, | 2343 void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, |
| 2336 Token::Value op, | 2344 Token::Value op, |
| 2337 OverwriteMode mode, | 2345 OverwriteMode mode, |
| 2338 Expression* left, | 2346 Expression* left, |
| 2339 Expression* right) { | 2347 Expression* right) { |
| 2340 // Do combined smi check of the operands. Left operand is on the | 2348 // Do combined smi check of the operands. Left operand is on the |
| 2341 // stack (popped into rdx). Right operand is in rax but moved into | 2349 // stack (popped into rdx). Right operand is in rax but moved into |
| 2342 // rcx to make the shifts easier. | 2350 // rcx to make the shifts easier. |
| 2343 Label done, stub_call, smi_case; | 2351 Label done, stub_call, smi_case; |
| 2344 __ Pop(rdx); | 2352 __ Pop(rdx); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2592 EmitNamedPropertyLoad(expr); | 2600 EmitNamedPropertyLoad(expr); |
| 2593 } else { | 2601 } else { |
| 2594 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); | 2602 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); |
| 2595 EmitLoadHomeObject(expr->obj()->AsSuperReference()); | 2603 EmitLoadHomeObject(expr->obj()->AsSuperReference()); |
| 2596 __ Push(result_register()); | 2604 __ Push(result_register()); |
| 2597 EmitNamedSuperPropertyLoad(expr); | 2605 EmitNamedSuperPropertyLoad(expr); |
| 2598 } | 2606 } |
| 2599 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2607 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
| 2600 context()->Plug(rax); | 2608 context()->Plug(rax); |
| 2601 } else { | 2609 } else { |
| 2602 VisitForStackValue(expr->obj()); | 2610 if (!expr->IsSuperAccess()) { |
| 2603 VisitForAccumulatorValue(expr->key()); | 2611 VisitForStackValue(expr->obj()); |
| 2604 __ Move(LoadDescriptor::NameRegister(), rax); | 2612 VisitForAccumulatorValue(expr->key()); |
| 2605 __ Pop(LoadDescriptor::ReceiverRegister()); | 2613 __ Move(LoadDescriptor::NameRegister(), rax); |
| 2606 EmitKeyedPropertyLoad(expr); | 2614 __ Pop(LoadDescriptor::ReceiverRegister()); |
| 2615 EmitKeyedPropertyLoad(expr); |
| 2616 } else { |
| 2617 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); |
| 2618 EmitLoadHomeObject(expr->obj()->AsSuperReference()); |
| 2619 __ Push(result_register()); |
| 2620 VisitForStackValue(expr->key()); |
| 2621 EmitKeyedSuperPropertyLoad(expr); |
| 2622 } |
| 2607 context()->Plug(rax); | 2623 context()->Plug(rax); |
| 2608 } | 2624 } |
| 2609 } | 2625 } |
| 2610 | 2626 |
| 2611 | 2627 |
| 2612 void FullCodeGenerator::CallIC(Handle<Code> code, | 2628 void FullCodeGenerator::CallIC(Handle<Code> code, |
| 2613 TypeFeedbackId ast_id) { | 2629 TypeFeedbackId ast_id) { |
| 2614 ic_total_count_++; | 2630 ic_total_count_++; |
| 2615 __ call(code, RelocInfo::CODE_TARGET, ast_id); | 2631 __ call(code, RelocInfo::CODE_TARGET, ast_id); |
| 2616 } | 2632 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2700 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2716 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
| 2701 | 2717 |
| 2702 // Push the target function under the receiver. | 2718 // Push the target function under the receiver. |
| 2703 __ Push(Operand(rsp, 0)); | 2719 __ Push(Operand(rsp, 0)); |
| 2704 __ movp(Operand(rsp, kPointerSize), rax); | 2720 __ movp(Operand(rsp, kPointerSize), rax); |
| 2705 | 2721 |
| 2706 EmitCall(expr, CallICState::METHOD); | 2722 EmitCall(expr, CallICState::METHOD); |
| 2707 } | 2723 } |
| 2708 | 2724 |
| 2709 | 2725 |
| 2726 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
| 2727 Expression* callee = expr->expression(); |
| 2728 DCHECK(callee->IsProperty()); |
| 2729 Property* prop = callee->AsProperty(); |
| 2730 DCHECK(prop->IsSuperAccess()); |
| 2731 |
| 2732 SetSourcePosition(prop->position()); |
| 2733 // Load the function from the receiver. |
| 2734 SuperReference* super_ref = prop->obj()->AsSuperReference(); |
| 2735 EmitLoadHomeObject(super_ref); |
| 2736 __ Push(rax); |
| 2737 VisitForAccumulatorValue(super_ref->this_var()); |
| 2738 __ Push(rax); |
| 2739 __ Push(rax); |
| 2740 __ Push(Operand(rsp, kPointerSize * 2)); |
| 2741 VisitForStackValue(prop->key()); |
| 2742 |
| 2743 // Stack here: |
| 2744 // - home_object |
| 2745 // - this (receiver) |
| 2746 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. |
| 2747 // - home_object |
| 2748 // - key |
| 2749 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
| 2750 |
| 2751 // Replace home_object with target function. |
| 2752 __ movp(Operand(rsp, kPointerSize), rax); |
| 2753 |
| 2754 // Stack here: |
| 2755 // - target function |
| 2756 // - this (receiver) |
| 2757 EmitCall(expr, CallICState::METHOD); |
| 2758 } |
| 2759 |
| 2760 |
| 2710 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { | 2761 void FullCodeGenerator::EmitCall(Call* expr, CallICState::CallType call_type) { |
| 2711 // Load the arguments. | 2762 // Load the arguments. |
| 2712 ZoneList<Expression*>* args = expr->arguments(); | 2763 ZoneList<Expression*>* args = expr->arguments(); |
| 2713 int arg_count = args->length(); | 2764 int arg_count = args->length(); |
| 2714 { PreservePositionScope scope(masm()->positions_recorder()); | 2765 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2715 for (int i = 0; i < arg_count; i++) { | 2766 for (int i = 0; i < arg_count; i++) { |
| 2716 VisitForStackValue(args->at(i)); | 2767 VisitForStackValue(args->at(i)); |
| 2717 } | 2768 } |
| 2718 } | 2769 } |
| 2719 | 2770 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2842 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2893 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 2843 __ bind(&call); | 2894 __ bind(&call); |
| 2844 } | 2895 } |
| 2845 | 2896 |
| 2846 // The receiver is either the global receiver or an object found by | 2897 // The receiver is either the global receiver or an object found by |
| 2847 // LoadContextSlot. | 2898 // LoadContextSlot. |
| 2848 EmitCall(expr); | 2899 EmitCall(expr); |
| 2849 } else if (call_type == Call::PROPERTY_CALL) { | 2900 } else if (call_type == Call::PROPERTY_CALL) { |
| 2850 Property* property = callee->AsProperty(); | 2901 Property* property = callee->AsProperty(); |
| 2851 bool is_named_call = property->key()->IsPropertyName(); | 2902 bool is_named_call = property->key()->IsPropertyName(); |
| 2852 // super.x() is handled in EmitCallWithLoadIC. | 2903 if (property->IsSuperAccess()) { |
| 2853 if (property->IsSuperAccess() && is_named_call) { | 2904 if (is_named_call) { |
| 2854 EmitSuperCallWithLoadIC(expr); | 2905 EmitSuperCallWithLoadIC(expr); |
| 2906 } else { |
| 2907 EmitKeyedSuperCallWithLoadIC(expr); |
| 2908 } |
| 2855 } else { | 2909 } else { |
| 2856 { | 2910 { |
| 2857 PreservePositionScope scope(masm()->positions_recorder()); | 2911 PreservePositionScope scope(masm()->positions_recorder()); |
| 2858 VisitForStackValue(property->obj()); | 2912 VisitForStackValue(property->obj()); |
| 2859 } | 2913 } |
| 2860 if (is_named_call) { | 2914 if (is_named_call) { |
| 2861 EmitCallWithLoadIC(expr); | 2915 EmitCallWithLoadIC(expr); |
| 2862 } else { | 2916 } else { |
| 2863 EmitKeyedCallWithLoadIC(expr, property->key()); | 2917 EmitKeyedCallWithLoadIC(expr, property->key()); |
| 2864 } | 2918 } |
| (...skipping 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4991 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5045 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4992 Assembler::target_address_at(call_target_address, | 5046 Assembler::target_address_at(call_target_address, |
| 4993 unoptimized_code)); | 5047 unoptimized_code)); |
| 4994 return OSR_AFTER_STACK_CHECK; | 5048 return OSR_AFTER_STACK_CHECK; |
| 4995 } | 5049 } |
| 4996 | 5050 |
| 4997 | 5051 |
| 4998 } } // namespace v8::internal | 5052 } } // namespace v8::internal |
| 4999 | 5053 |
| 5000 #endif // V8_TARGET_ARCH_X64 | 5054 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |