OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 2871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2882 __ jmp(return_addr_reg); | 2882 __ jmp(return_addr_reg); |
2883 } | 2883 } |
2884 if (no_frame_start != -1) { | 2884 if (no_frame_start != -1) { |
2885 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 2885 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
2886 } | 2886 } |
2887 } | 2887 } |
2888 | 2888 |
2889 | 2889 |
2890 template <class T> | 2890 template <class T> |
2891 void LCodeGen::EmitVectorLoadICRegisters(T* instr) { | 2891 void LCodeGen::EmitVectorLoadICRegisters(T* instr) { |
2892 DCHECK(FLAG_vector_ics); | |
2893 Register vector_register = ToRegister(instr->temp_vector()); | 2892 Register vector_register = ToRegister(instr->temp_vector()); |
2894 Register slot_register = VectorLoadICDescriptor::SlotRegister(); | 2893 Register slot_register = VectorLoadICDescriptor::SlotRegister(); |
2895 DCHECK(vector_register.is(VectorLoadICDescriptor::VectorRegister())); | 2894 DCHECK(vector_register.is(VectorLoadICDescriptor::VectorRegister())); |
2896 DCHECK(slot_register.is(rax)); | 2895 DCHECK(slot_register.is(rax)); |
2897 | 2896 |
2898 AllowDeferredHandleDereference vector_structure_check; | 2897 AllowDeferredHandleDereference vector_structure_check; |
2899 Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); | 2898 Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); |
2900 __ Move(vector_register, vector); | 2899 __ Move(vector_register, vector); |
2901 // No need to allocate this register. | 2900 // No need to allocate this register. |
2902 FeedbackVectorICSlot slot = instr->hydrogen()->slot(); | 2901 FeedbackVectorICSlot slot = instr->hydrogen()->slot(); |
2903 int index = vector->GetIndex(slot); | 2902 int index = vector->GetIndex(slot); |
2904 __ Move(slot_register, Smi::FromInt(index)); | 2903 __ Move(slot_register, Smi::FromInt(index)); |
2905 } | 2904 } |
2906 | 2905 |
2907 | 2906 |
2908 void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { | 2907 void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { |
2909 DCHECK(ToRegister(instr->context()).is(rsi)); | 2908 DCHECK(ToRegister(instr->context()).is(rsi)); |
2910 DCHECK(ToRegister(instr->global_object()) | 2909 DCHECK(ToRegister(instr->global_object()) |
2911 .is(LoadDescriptor::ReceiverRegister())); | 2910 .is(LoadDescriptor::ReceiverRegister())); |
2912 DCHECK(ToRegister(instr->result()).is(rax)); | 2911 DCHECK(ToRegister(instr->result()).is(rax)); |
2913 | 2912 |
2914 __ Move(LoadDescriptor::NameRegister(), instr->name()); | 2913 __ Move(LoadDescriptor::NameRegister(), instr->name()); |
2915 if (FLAG_vector_ics) { | 2914 EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr); |
2916 EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr); | |
2917 } | |
2918 ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; | 2915 ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; |
2919 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode(isolate(), mode, | 2916 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode(isolate(), mode, |
2920 PREMONOMORPHIC).code(); | 2917 PREMONOMORPHIC).code(); |
2921 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2918 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2922 } | 2919 } |
2923 | 2920 |
2924 | 2921 |
2925 void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) { | 2922 void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) { |
2926 Register context = ToRegister(instr->context()); | 2923 Register context = ToRegister(instr->context()); |
2927 Register result = ToRegister(instr->result()); | 2924 Register result = ToRegister(instr->result()); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3024 __ Load(result, FieldOperand(object, offset), representation); | 3021 __ Load(result, FieldOperand(object, offset), representation); |
3025 } | 3022 } |
3026 | 3023 |
3027 | 3024 |
3028 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { | 3025 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { |
3029 DCHECK(ToRegister(instr->context()).is(rsi)); | 3026 DCHECK(ToRegister(instr->context()).is(rsi)); |
3030 DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister())); | 3027 DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister())); |
3031 DCHECK(ToRegister(instr->result()).is(rax)); | 3028 DCHECK(ToRegister(instr->result()).is(rax)); |
3032 | 3029 |
3033 __ Move(LoadDescriptor::NameRegister(), instr->name()); | 3030 __ Move(LoadDescriptor::NameRegister(), instr->name()); |
3034 if (FLAG_vector_ics) { | 3031 EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr); |
3035 EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr); | |
3036 } | |
3037 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode( | 3032 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode( |
3038 isolate(), NOT_CONTEXTUAL, | 3033 isolate(), NOT_CONTEXTUAL, |
3039 instr->hydrogen()->initialization_state()).code(); | 3034 instr->hydrogen()->initialization_state()).code(); |
3040 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3035 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
3041 } | 3036 } |
3042 | 3037 |
3043 | 3038 |
3044 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) { | 3039 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) { |
3045 Register function = ToRegister(instr->function()); | 3040 Register function = ToRegister(instr->function()); |
3046 Register result = ToRegister(instr->result()); | 3041 Register result = ToRegister(instr->result()); |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3556 // We need to adapt arguments. | 3551 // We need to adapt arguments. |
3557 SafepointGenerator generator( | 3552 SafepointGenerator generator( |
3558 this, pointers, Safepoint::kLazyDeopt); | 3553 this, pointers, Safepoint::kLazyDeopt); |
3559 ParameterCount count(arity); | 3554 ParameterCount count(arity); |
3560 ParameterCount expected(formal_parameter_count); | 3555 ParameterCount expected(formal_parameter_count); |
3561 __ InvokeFunction(function_reg, expected, count, CALL_FUNCTION, generator); | 3556 __ InvokeFunction(function_reg, expected, count, CALL_FUNCTION, generator); |
3562 } | 3557 } |
3563 } | 3558 } |
3564 | 3559 |
3565 | 3560 |
3566 void LCodeGen::DoTailCallThroughMegamorphicCache( | |
3567 LTailCallThroughMegamorphicCache* instr) { | |
3568 Register receiver = ToRegister(instr->receiver()); | |
3569 Register name = ToRegister(instr->name()); | |
3570 DCHECK(receiver.is(LoadDescriptor::ReceiverRegister())); | |
3571 DCHECK(name.is(LoadDescriptor::NameRegister())); | |
3572 Register scratch = rdi; | |
3573 DCHECK(!scratch.is(receiver) && !scratch.is(name)); | |
3574 | |
3575 // The probe will tail call to a handler if found. | |
3576 isolate()->stub_cache()->GenerateProbe(masm(), Code::LOAD_IC, | |
3577 instr->hydrogen()->flags(), false, | |
3578 receiver, name, scratch, no_reg); | |
3579 | |
3580 LoadIC::GenerateMiss(masm()); | |
3581 } | |
3582 | |
3583 | |
3584 void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) { | 3561 void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) { |
3585 DCHECK(ToRegister(instr->result()).is(rax)); | 3562 DCHECK(ToRegister(instr->result()).is(rax)); |
3586 | 3563 |
3587 if (instr->hydrogen()->IsTailCall()) { | 3564 if (instr->hydrogen()->IsTailCall()) { |
3588 if (NeedsEagerFrame()) __ leave(); | 3565 if (NeedsEagerFrame()) __ leave(); |
3589 | 3566 |
3590 if (instr->target()->IsConstantOperand()) { | 3567 if (instr->target()->IsConstantOperand()) { |
3591 LConstantOperand* target = LConstantOperand::cast(instr->target()); | 3568 LConstantOperand* target = LConstantOperand::cast(instr->target()); |
3592 Handle<Code> code = Handle<Code>::cast(ToHandle(target)); | 3569 Handle<Code> code = Handle<Code>::cast(ToHandle(target)); |
3593 __ jmp(code, RelocInfo::CODE_TARGET); | 3570 __ jmp(code, RelocInfo::CODE_TARGET); |
(...skipping 2462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6056 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6033 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6057 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6034 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6058 } | 6035 } |
6059 | 6036 |
6060 | 6037 |
6061 #undef __ | 6038 #undef __ |
6062 | 6039 |
6063 } } // namespace v8::internal | 6040 } } // namespace v8::internal |
6064 | 6041 |
6065 #endif // V8_TARGET_ARCH_X64 | 6042 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |