| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
| (...skipping 3029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3040 __ blr(); | 3040 __ blr(); |
| 3041 | 3041 |
| 3042 if (no_frame_start != -1) { | 3042 if (no_frame_start != -1) { |
| 3043 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 3043 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
| 3044 } | 3044 } |
| 3045 } | 3045 } |
| 3046 | 3046 |
| 3047 | 3047 |
| 3048 template <class T> | 3048 template <class T> |
| 3049 void LCodeGen::EmitVectorLoadICRegisters(T* instr) { | 3049 void LCodeGen::EmitVectorLoadICRegisters(T* instr) { |
| 3050 DCHECK(FLAG_vector_ics); | |
| 3051 Register vector_register = ToRegister(instr->temp_vector()); | 3050 Register vector_register = ToRegister(instr->temp_vector()); |
| 3052 Register slot_register = VectorLoadICDescriptor::SlotRegister(); | 3051 Register slot_register = VectorLoadICDescriptor::SlotRegister(); |
| 3053 DCHECK(vector_register.is(VectorLoadICDescriptor::VectorRegister())); | 3052 DCHECK(vector_register.is(VectorLoadICDescriptor::VectorRegister())); |
| 3054 DCHECK(slot_register.is(r3)); | 3053 DCHECK(slot_register.is(r3)); |
| 3055 | 3054 |
| 3056 AllowDeferredHandleDereference vector_structure_check; | 3055 AllowDeferredHandleDereference vector_structure_check; |
| 3057 Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); | 3056 Handle<TypeFeedbackVector> vector = instr->hydrogen()->feedback_vector(); |
| 3058 __ Move(vector_register, vector); | 3057 __ Move(vector_register, vector); |
| 3059 // No need to allocate this register. | 3058 // No need to allocate this register. |
| 3060 FeedbackVectorICSlot slot = instr->hydrogen()->slot(); | 3059 FeedbackVectorICSlot slot = instr->hydrogen()->slot(); |
| 3061 int index = vector->GetIndex(slot); | 3060 int index = vector->GetIndex(slot); |
| 3062 __ mov(slot_register, Operand(Smi::FromInt(index))); | 3061 __ mov(slot_register, Operand(Smi::FromInt(index))); |
| 3063 } | 3062 } |
| 3064 | 3063 |
| 3065 | 3064 |
| 3066 void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { | 3065 void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { |
| 3067 DCHECK(ToRegister(instr->context()).is(cp)); | 3066 DCHECK(ToRegister(instr->context()).is(cp)); |
| 3068 DCHECK(ToRegister(instr->global_object()) | 3067 DCHECK(ToRegister(instr->global_object()) |
| 3069 .is(LoadDescriptor::ReceiverRegister())); | 3068 .is(LoadDescriptor::ReceiverRegister())); |
| 3070 DCHECK(ToRegister(instr->result()).is(r3)); | 3069 DCHECK(ToRegister(instr->result()).is(r3)); |
| 3071 | 3070 |
| 3072 __ mov(LoadDescriptor::NameRegister(), Operand(instr->name())); | 3071 __ mov(LoadDescriptor::NameRegister(), Operand(instr->name())); |
| 3073 if (FLAG_vector_ics) { | 3072 EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr); |
| 3074 EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr); | |
| 3075 } | |
| 3076 ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; | 3073 ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; |
| 3077 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode(isolate(), mode, | 3074 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode(isolate(), mode, |
| 3078 PREMONOMORPHIC).code(); | 3075 PREMONOMORPHIC).code(); |
| 3079 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3076 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 3080 } | 3077 } |
| 3081 | 3078 |
| 3082 | 3079 |
| 3083 void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) { | 3080 void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) { |
| 3084 Register context = ToRegister(instr->context()); | 3081 Register context = ToRegister(instr->context()); |
| 3085 Register result = ToRegister(instr->result()); | 3082 Register result = ToRegister(instr->result()); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3182 } | 3179 } |
| 3183 | 3180 |
| 3184 | 3181 |
| 3185 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { | 3182 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { |
| 3186 DCHECK(ToRegister(instr->context()).is(cp)); | 3183 DCHECK(ToRegister(instr->context()).is(cp)); |
| 3187 DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister())); | 3184 DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister())); |
| 3188 DCHECK(ToRegister(instr->result()).is(r3)); | 3185 DCHECK(ToRegister(instr->result()).is(r3)); |
| 3189 | 3186 |
| 3190 // Name is always in r5. | 3187 // Name is always in r5. |
| 3191 __ mov(LoadDescriptor::NameRegister(), Operand(instr->name())); | 3188 __ mov(LoadDescriptor::NameRegister(), Operand(instr->name())); |
| 3192 if (FLAG_vector_ics) { | 3189 EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr); |
| 3193 EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr); | |
| 3194 } | |
| 3195 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode( | 3190 Handle<Code> ic = CodeFactory::LoadICInOptimizedCode( |
| 3196 isolate(), NOT_CONTEXTUAL, | 3191 isolate(), NOT_CONTEXTUAL, |
| 3197 instr->hydrogen()->initialization_state()).code(); | 3192 instr->hydrogen()->initialization_state()).code(); |
| 3198 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3193 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 3199 } | 3194 } |
| 3200 | 3195 |
| 3201 | 3196 |
| 3202 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) { | 3197 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) { |
| 3203 Register scratch = scratch0(); | 3198 Register scratch = scratch0(); |
| 3204 Register function = ToRegister(instr->function()); | 3199 Register function = ToRegister(instr->function()); |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4171 ParameterCount count(instr->arity()); | 4166 ParameterCount count(instr->arity()); |
| 4172 __ InvokeFunction(r4, count, CALL_FUNCTION, generator); | 4167 __ InvokeFunction(r4, count, CALL_FUNCTION, generator); |
| 4173 } else { | 4168 } else { |
| 4174 CallKnownFunction(known_function, | 4169 CallKnownFunction(known_function, |
| 4175 instr->hydrogen()->formal_parameter_count(), | 4170 instr->hydrogen()->formal_parameter_count(), |
| 4176 instr->arity(), instr); | 4171 instr->arity(), instr); |
| 4177 } | 4172 } |
| 4178 } | 4173 } |
| 4179 | 4174 |
| 4180 | 4175 |
| 4181 void LCodeGen::DoTailCallThroughMegamorphicCache( | |
| 4182 LTailCallThroughMegamorphicCache* instr) { | |
| 4183 Register receiver = ToRegister(instr->receiver()); | |
| 4184 Register name = ToRegister(instr->name()); | |
| 4185 DCHECK(receiver.is(LoadDescriptor::ReceiverRegister())); | |
| 4186 DCHECK(name.is(LoadDescriptor::NameRegister())); | |
| 4187 DCHECK(receiver.is(r4)); | |
| 4188 DCHECK(name.is(r5)); | |
| 4189 Register scratch = r7; | |
| 4190 Register extra = r8; | |
| 4191 Register extra2 = r9; | |
| 4192 Register extra3 = r10; | |
| 4193 | |
| 4194 // The probe will tail call to a handler if found. | |
| 4195 isolate()->stub_cache()->GenerateProbe( | |
| 4196 masm(), Code::LOAD_IC, instr->hydrogen()->flags(), false, receiver, name, | |
| 4197 scratch, extra, extra2, extra3); | |
| 4198 | |
| 4199 // Tail call to miss if we ended up here. | |
| 4200 LoadIC::GenerateMiss(masm()); | |
| 4201 } | |
| 4202 | |
| 4203 | |
| 4204 void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) { | 4176 void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) { |
| 4205 DCHECK(ToRegister(instr->result()).is(r3)); | 4177 DCHECK(ToRegister(instr->result()).is(r3)); |
| 4206 | 4178 |
| 4207 if (instr->hydrogen()->IsTailCall()) { | 4179 if (instr->hydrogen()->IsTailCall()) { |
| 4208 if (NeedsEagerFrame()) __ LeaveFrame(StackFrame::INTERNAL); | 4180 if (NeedsEagerFrame()) __ LeaveFrame(StackFrame::INTERNAL); |
| 4209 | 4181 |
| 4210 if (instr->target()->IsConstantOperand()) { | 4182 if (instr->target()->IsConstantOperand()) { |
| 4211 LConstantOperand* target = LConstantOperand::cast(instr->target()); | 4183 LConstantOperand* target = LConstantOperand::cast(instr->target()); |
| 4212 Handle<Code> code = Handle<Code>::cast(ToHandle(target)); | 4184 Handle<Code> code = Handle<Code>::cast(ToHandle(target)); |
| 4213 __ Jump(code, RelocInfo::CODE_TARGET); | 4185 __ Jump(code, RelocInfo::CODE_TARGET); |
| (...skipping 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6307 __ Push(scope_info); | 6279 __ Push(scope_info); |
| 6308 __ push(ToRegister(instr->function())); | 6280 __ push(ToRegister(instr->function())); |
| 6309 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6281 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 6310 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6282 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 6311 } | 6283 } |
| 6312 | 6284 |
| 6313 | 6285 |
| 6314 #undef __ | 6286 #undef __ |
| 6315 } | 6287 } |
| 6316 } // namespace v8::internal | 6288 } // namespace v8::internal |
| OLD | NEW |