OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2686 void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) { | 2686 void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) { |
2687 Register global = ToRegister(instr->global()); | 2687 Register global = ToRegister(instr->global()); |
2688 Register result = ToRegister(instr->result()); | 2688 Register result = ToRegister(instr->result()); |
2689 __ movq(result, FieldOperand(global, GlobalObject::kGlobalReceiverOffset)); | 2689 __ movq(result, FieldOperand(global, GlobalObject::kGlobalReceiverOffset)); |
2690 } | 2690 } |
2691 | 2691 |
2692 | 2692 |
2693 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, | 2693 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
2694 int arity, | 2694 int arity, |
2695 LInstruction* instr, | 2695 LInstruction* instr, |
2696 CallKind call_kind) { | 2696 CallKind call_kind, |
| 2697 RDIState rdi_state) { |
2697 bool can_invoke_directly = !function->NeedsArgumentsAdaption() || | 2698 bool can_invoke_directly = !function->NeedsArgumentsAdaption() || |
2698 function->shared()->formal_parameter_count() == arity; | 2699 function->shared()->formal_parameter_count() == arity; |
2699 | 2700 |
2700 LPointerMap* pointers = instr->pointer_map(); | 2701 LPointerMap* pointers = instr->pointer_map(); |
2701 RecordPosition(pointers->position()); | 2702 RecordPosition(pointers->position()); |
2702 | 2703 |
2703 if (can_invoke_directly) { | 2704 if (can_invoke_directly) { |
2704 __ LoadHeapObject(rdi, function); | 2705 if (rdi_state == RDI_UNINITIALIZED) { |
| 2706 __ LoadHeapObject(rdi, function); |
| 2707 } |
2705 | 2708 |
2706 // Change context if needed. | 2709 // Change context if needed. |
2707 bool change_context = | 2710 bool change_context = |
2708 (info()->closure()->context() != function->context()) || | 2711 (info()->closure()->context() != function->context()) || |
2709 scope()->contains_with() || | 2712 scope()->contains_with() || |
2710 (scope()->num_heap_slots() > 0); | 2713 (scope()->num_heap_slots() > 0); |
2711 if (change_context) { | 2714 if (change_context) { |
2712 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 2715 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
2713 } | 2716 } |
2714 | 2717 |
(...skipping 24 matching lines...) Expand all Loading... |
2739 // Restore context. | 2742 // Restore context. |
2740 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2743 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
2741 } | 2744 } |
2742 | 2745 |
2743 | 2746 |
2744 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { | 2747 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { |
2745 ASSERT(ToRegister(instr->result()).is(rax)); | 2748 ASSERT(ToRegister(instr->result()).is(rax)); |
2746 CallKnownFunction(instr->function(), | 2749 CallKnownFunction(instr->function(), |
2747 instr->arity(), | 2750 instr->arity(), |
2748 instr, | 2751 instr, |
2749 CALL_AS_METHOD); | 2752 CALL_AS_METHOD, |
| 2753 RDI_UNINITIALIZED); |
2750 } | 2754 } |
2751 | 2755 |
2752 | 2756 |
2753 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { | 2757 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { |
2754 Register input_reg = ToRegister(instr->InputAt(0)); | 2758 Register input_reg = ToRegister(instr->InputAt(0)); |
2755 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), | 2759 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), |
2756 Heap::kHeapNumberMapRootIndex); | 2760 Heap::kHeapNumberMapRootIndex); |
2757 DeoptimizeIf(not_equal, instr->environment()); | 2761 DeoptimizeIf(not_equal, instr->environment()); |
2758 | 2762 |
2759 Label done; | 2763 Label done; |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3177 default: | 3181 default: |
3178 UNREACHABLE(); | 3182 UNREACHABLE(); |
3179 } | 3183 } |
3180 } | 3184 } |
3181 | 3185 |
3182 | 3186 |
3183 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { | 3187 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { |
3184 ASSERT(ToRegister(instr->function()).is(rdi)); | 3188 ASSERT(ToRegister(instr->function()).is(rdi)); |
3185 ASSERT(instr->HasPointerMap()); | 3189 ASSERT(instr->HasPointerMap()); |
3186 ASSERT(instr->HasDeoptimizationEnvironment()); | 3190 ASSERT(instr->HasDeoptimizationEnvironment()); |
3187 LPointerMap* pointers = instr->pointer_map(); | 3191 |
3188 RecordPosition(pointers->position()); | 3192 if (instr->known_function().is_null()) { |
3189 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); | 3193 LPointerMap* pointers = instr->pointer_map(); |
3190 ParameterCount count(instr->arity()); | 3194 RecordPosition(pointers->position()); |
3191 __ InvokeFunction(rdi, count, CALL_FUNCTION, generator, CALL_AS_METHOD); | 3195 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
3192 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 3196 ParameterCount count(instr->arity()); |
| 3197 __ InvokeFunction(rdi, count, CALL_FUNCTION, generator, CALL_AS_METHOD); |
| 3198 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 3199 } else { |
| 3200 CallKnownFunction(instr->known_function(), |
| 3201 instr->arity(), |
| 3202 instr, |
| 3203 CALL_AS_METHOD, |
| 3204 RDI_CONTAINS_TARGET); |
| 3205 } |
3193 } | 3206 } |
3194 | 3207 |
3195 | 3208 |
3196 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { | 3209 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { |
3197 ASSERT(ToRegister(instr->key()).is(rcx)); | 3210 ASSERT(ToRegister(instr->key()).is(rcx)); |
3198 ASSERT(ToRegister(instr->result()).is(rax)); | 3211 ASSERT(ToRegister(instr->result()).is(rax)); |
3199 | 3212 |
3200 int arity = instr->arity(); | 3213 int arity = instr->arity(); |
3201 Handle<Code> ic = | 3214 Handle<Code> ic = |
3202 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity); | 3215 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3236 Handle<Code> ic = | 3249 Handle<Code> ic = |
3237 isolate()->stub_cache()->ComputeCallInitialize(arity, mode); | 3250 isolate()->stub_cache()->ComputeCallInitialize(arity, mode); |
3238 __ Move(rcx, instr->name()); | 3251 __ Move(rcx, instr->name()); |
3239 CallCode(ic, mode, instr); | 3252 CallCode(ic, mode, instr); |
3240 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 3253 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
3241 } | 3254 } |
3242 | 3255 |
3243 | 3256 |
3244 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { | 3257 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { |
3245 ASSERT(ToRegister(instr->result()).is(rax)); | 3258 ASSERT(ToRegister(instr->result()).is(rax)); |
3246 CallKnownFunction(instr->target(), instr->arity(), instr, CALL_AS_FUNCTION); | 3259 CallKnownFunction(instr->target(), |
| 3260 instr->arity(), |
| 3261 instr, |
| 3262 CALL_AS_FUNCTION, |
| 3263 RDI_UNINITIALIZED); |
3247 } | 3264 } |
3248 | 3265 |
3249 | 3266 |
3250 void LCodeGen::DoCallNew(LCallNew* instr) { | 3267 void LCodeGen::DoCallNew(LCallNew* instr) { |
3251 ASSERT(ToRegister(instr->InputAt(0)).is(rdi)); | 3268 ASSERT(ToRegister(instr->InputAt(0)).is(rdi)); |
3252 ASSERT(ToRegister(instr->result()).is(rax)); | 3269 ASSERT(ToRegister(instr->result()).is(rax)); |
3253 | 3270 |
3254 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); | 3271 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); |
3255 __ Set(rax, instr->arity()); | 3272 __ Set(rax, instr->arity()); |
3256 CallCode(stub.GetCode(), RelocInfo::CONSTRUCT_CALL, instr); | 3273 CallCode(stub.GetCode(), RelocInfo::CONSTRUCT_CALL, instr); |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4785 FixedArray::kHeaderSize - kPointerSize)); | 4802 FixedArray::kHeaderSize - kPointerSize)); |
4786 __ bind(&done); | 4803 __ bind(&done); |
4787 } | 4804 } |
4788 | 4805 |
4789 | 4806 |
4790 #undef __ | 4807 #undef __ |
4791 | 4808 |
4792 } } // namespace v8::internal | 4809 } } // namespace v8::internal |
4793 | 4810 |
4794 #endif // V8_TARGET_ARCH_X64 | 4811 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |