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/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 3126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3137 | 3137 |
3138 EmitReturn(instr, false); | 3138 EmitReturn(instr, false); |
3139 if (no_frame_start != -1) { | 3139 if (no_frame_start != -1) { |
3140 info()->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 3140 info()->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
3141 } | 3141 } |
3142 } | 3142 } |
3143 | 3143 |
3144 | 3144 |
3145 template <class T> | 3145 template <class T> |
3146 void LCodeGen::EmitVectorLoadICRegisters(T* instr) { | 3146 void LCodeGen::EmitVectorLoadICRegisters(T* instr) { |
3147 DCHECK(FLAG_vector_ics); | |
3148 Register vector_register = ToRegister(instr->temp_vector()); | 3147 Register vector_register = ToRegister(instr->temp_vector()); |
3149 Register slot_register = VectorLoadICDescriptor::SlotRegister(); | 3148 Register slot_register = VectorLoadICDescriptor::SlotRegister(); |
3150 DCHECK(vector_register.is(VectorLoadICDescriptor::VectorRegister())); | 3149 DCHECK(vector_register.is(VectorLoadICDescriptor::VectorRegister())); |
3151 DCHECK(slot_register.is(eax)); | 3150 DCHECK(slot_register.is(eax)); |
3152 | 3151 |
3153 AllowDeferredHandleDereference vector_structure_check; | 3152 AllowDeferredHandleDereference vector_structure_check; |
3154 Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); | 3153 Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); |
3155 __ mov(vector_register, vector); | 3154 __ mov(vector_register, vector); |
3156 // No need to allocate this register. | 3155 // No need to allocate this register. |
3157 FeedbackVectorICSlot slot = instr->hydrogen()->slot(); | 3156 FeedbackVectorICSlot slot = instr->hydrogen()->slot(); |
3158 int index = vector->GetIndex(slot); | 3157 int index = vector->GetIndex(slot); |
3159 __ mov(slot_register, Immediate(Smi::FromInt(index))); | 3158 __ mov(slot_register, Immediate(Smi::FromInt(index))); |
3160 } | 3159 } |
3161 | 3160 |
3162 | 3161 |
3163 void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { | 3162 void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { |
3164 DCHECK(ToRegister(instr->context()).is(esi)); | 3163 DCHECK(ToRegister(instr->context()).is(esi)); |
3165 DCHECK(ToRegister(instr->global_object()) | 3164 DCHECK(ToRegister(instr->global_object()) |
3166 .is(LoadDescriptor::ReceiverRegister())); | 3165 .is(LoadDescriptor::ReceiverRegister())); |
3167 DCHECK(ToRegister(instr->result()).is(eax)); | 3166 DCHECK(ToRegister(instr->result()).is(eax)); |
3168 | 3167 |
3169 __ mov(LoadDescriptor::NameRegister(), instr->name()); | 3168 __ mov(LoadDescriptor::NameRegister(), instr->name()); |
3170 if (FLAG_vector_ics) { | 3169 EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr); |
3171 EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr); | |
3172 } | |
3173 ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; | 3170 ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; |
3174 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode(isolate(), mode, | 3171 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode(isolate(), mode, |
3175 PREMONOMORPHIC).code(); | 3172 PREMONOMORPHIC).code(); |
3176 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3173 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
3177 } | 3174 } |
3178 | 3175 |
3179 | 3176 |
3180 void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) { | 3177 void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) { |
3181 Register context = ToRegister(instr->context()); | 3178 Register context = ToRegister(instr->context()); |
3182 Register result = ToRegister(instr->result()); | 3179 Register result = ToRegister(instr->result()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3273 } | 3270 } |
3274 } | 3271 } |
3275 | 3272 |
3276 | 3273 |
3277 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { | 3274 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { |
3278 DCHECK(ToRegister(instr->context()).is(esi)); | 3275 DCHECK(ToRegister(instr->context()).is(esi)); |
3279 DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister())); | 3276 DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister())); |
3280 DCHECK(ToRegister(instr->result()).is(eax)); | 3277 DCHECK(ToRegister(instr->result()).is(eax)); |
3281 | 3278 |
3282 __ mov(LoadDescriptor::NameRegister(), instr->name()); | 3279 __ mov(LoadDescriptor::NameRegister(), instr->name()); |
3283 if (FLAG_vector_ics) { | 3280 EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr); |
3284 EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr); | |
3285 } | |
3286 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode( | 3281 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode( |
3287 isolate(), NOT_CONTEXTUAL, | 3282 isolate(), NOT_CONTEXTUAL, |
3288 instr->hydrogen()->initialization_state()).code(); | 3283 instr->hydrogen()->initialization_state()).code(); |
3289 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3284 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
3290 } | 3285 } |
3291 | 3286 |
3292 | 3287 |
3293 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) { | 3288 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) { |
3294 Register function = ToRegister(instr->function()); | 3289 Register function = ToRegister(instr->function()); |
3295 Register temp = ToRegister(instr->temp()); | 3290 Register temp = ToRegister(instr->temp()); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3744 LPointerMap* pointers = instr->pointer_map(); | 3739 LPointerMap* pointers = instr->pointer_map(); |
3745 SafepointGenerator generator( | 3740 SafepointGenerator generator( |
3746 this, pointers, Safepoint::kLazyDeopt); | 3741 this, pointers, Safepoint::kLazyDeopt); |
3747 ParameterCount count(arity); | 3742 ParameterCount count(arity); |
3748 ParameterCount expected(formal_parameter_count); | 3743 ParameterCount expected(formal_parameter_count); |
3749 __ InvokeFunction(function_reg, expected, count, CALL_FUNCTION, generator); | 3744 __ InvokeFunction(function_reg, expected, count, CALL_FUNCTION, generator); |
3750 } | 3745 } |
3751 } | 3746 } |
3752 | 3747 |
3753 | 3748 |
3754 void LCodeGen::DoTailCallThroughMegamorphicCache( | |
3755 LTailCallThroughMegamorphicCache* instr) { | |
3756 Register receiver = ToRegister(instr->receiver()); | |
3757 Register name = ToRegister(instr->name()); | |
3758 DCHECK(receiver.is(LoadDescriptor::ReceiverRegister())); | |
3759 DCHECK(name.is(LoadDescriptor::NameRegister())); | |
3760 Register scratch = ebx; | |
3761 Register extra = edi; | |
3762 DCHECK(!scratch.is(receiver) && !scratch.is(name)); | |
3763 DCHECK(!extra.is(receiver) && !extra.is(name)); | |
3764 | |
3765 // The probe will tail call to a handler if found. | |
3766 // If --vector-ics is on, then it knows to pop the two args first. | |
3767 isolate()->stub_cache()->GenerateProbe(masm(), Code::LOAD_IC, | |
3768 instr->hydrogen()->flags(), false, | |
3769 receiver, name, scratch, extra); | |
3770 | |
3771 LoadIC::GenerateMiss(masm()); | |
3772 } | |
3773 | |
3774 | |
3775 void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) { | 3749 void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) { |
3776 DCHECK(ToRegister(instr->result()).is(eax)); | 3750 DCHECK(ToRegister(instr->result()).is(eax)); |
3777 | 3751 |
3778 if (instr->hydrogen()->IsTailCall()) { | 3752 if (instr->hydrogen()->IsTailCall()) { |
3779 if (NeedsEagerFrame()) __ leave(); | 3753 if (NeedsEagerFrame()) __ leave(); |
3780 | 3754 |
3781 if (instr->target()->IsConstantOperand()) { | 3755 if (instr->target()->IsConstantOperand()) { |
3782 LConstantOperand* target = LConstantOperand::cast(instr->target()); | 3756 LConstantOperand* target = LConstantOperand::cast(instr->target()); |
3783 Handle<Code> code = Handle<Code>::cast(ToHandle(target)); | 3757 Handle<Code> code = Handle<Code>::cast(ToHandle(target)); |
3784 __ jmp(code, RelocInfo::CODE_TARGET); | 3758 __ jmp(code, RelocInfo::CODE_TARGET); |
(...skipping 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6474 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6448 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6475 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6449 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6476 } | 6450 } |
6477 | 6451 |
6478 | 6452 |
6479 #undef __ | 6453 #undef __ |
6480 | 6454 |
6481 } } // namespace v8::internal | 6455 } } // namespace v8::internal |
6482 | 6456 |
6483 #endif // V8_TARGET_ARCH_X87 | 6457 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |