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/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/ic/ic.h" | 10 #include "src/ic/ic.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 &slow); | 326 &slow); |
327 | 327 |
328 // If the receiver is a fast-case object, check the stub cache. Otherwise | 328 // If the receiver is a fast-case object, check the stub cache. Otherwise |
329 // probe the dictionary. | 329 // probe the dictionary. |
330 __ movp(rbx, FieldOperand(receiver, JSObject::kPropertiesOffset)); | 330 __ movp(rbx, FieldOperand(receiver, JSObject::kPropertiesOffset)); |
331 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), | 331 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), |
332 Heap::kHashTableMapRootIndex); | 332 Heap::kHashTableMapRootIndex); |
333 __ j(equal, &probe_dictionary); | 333 __ j(equal, &probe_dictionary); |
334 | 334 |
335 Register megamorphic_scratch = rdi; | 335 Register megamorphic_scratch = rdi; |
336 if (FLAG_vector_ics) { | 336 // The handlers in the stub cache expect a vector and slot. Since we won't |
337 // When vector ics are in use, the handlers in the stub cache expect a | 337 // change the IC from any downstream misses, a dummy vector can be used. |
338 // vector and slot. Since we won't change the IC from any downstream | 338 Register vector = VectorLoadICDescriptor::VectorRegister(); |
339 // misses, a dummy vector can be used. | 339 Register slot = VectorLoadICDescriptor::SlotRegister(); |
340 Register vector = VectorLoadICDescriptor::VectorRegister(); | 340 DCHECK(!AreAliased(megamorphic_scratch, vector, slot)); |
341 Register slot = VectorLoadICDescriptor::SlotRegister(); | 341 Handle<TypeFeedbackVector> dummy_vector = Handle<TypeFeedbackVector>::cast( |
342 DCHECK(!AreAliased(megamorphic_scratch, vector, slot)); | 342 masm->isolate()->factory()->keyed_load_dummy_vector()); |
343 Handle<TypeFeedbackVector> dummy_vector = Handle<TypeFeedbackVector>::cast( | 343 int int_slot = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); |
344 masm->isolate()->factory()->keyed_load_dummy_vector()); | 344 __ Move(vector, dummy_vector); |
345 int int_slot = dummy_vector->GetIndex(FeedbackVectorICSlot(0)); | 345 __ Move(slot, Smi::FromInt(int_slot)); |
346 __ Move(vector, dummy_vector); | |
347 __ Move(slot, Smi::FromInt(int_slot)); | |
348 } | |
349 | 346 |
350 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( | 347 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( |
351 Code::ComputeHandlerFlags(Code::LOAD_IC)); | 348 Code::ComputeHandlerFlags(Code::LOAD_IC)); |
352 masm->isolate()->stub_cache()->GenerateProbe(masm, Code::KEYED_LOAD_IC, flags, | 349 masm->isolate()->stub_cache()->GenerateProbe(masm, Code::KEYED_LOAD_IC, flags, |
353 false, receiver, key, | 350 false, receiver, key, |
354 megamorphic_scratch, no_reg); | 351 megamorphic_scratch, no_reg); |
355 // Cache miss. | 352 // Cache miss. |
356 GenerateMiss(masm); | 353 GenerateMiss(masm); |
357 | 354 |
358 // Do a quick inline probe of the receiver's dictionary, if it | 355 // Do a quick inline probe of the receiver's dictionary, if it |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 | 727 |
731 // Dictionary load failed, go slow (but don't miss). | 728 // Dictionary load failed, go slow (but don't miss). |
732 __ bind(&slow); | 729 __ bind(&slow); |
733 GenerateRuntimeGetProperty(masm); | 730 GenerateRuntimeGetProperty(masm); |
734 } | 731 } |
735 | 732 |
736 | 733 |
737 static void LoadIC_PushArgs(MacroAssembler* masm) { | 734 static void LoadIC_PushArgs(MacroAssembler* masm) { |
738 Register receiver = LoadDescriptor::ReceiverRegister(); | 735 Register receiver = LoadDescriptor::ReceiverRegister(); |
739 Register name = LoadDescriptor::NameRegister(); | 736 Register name = LoadDescriptor::NameRegister(); |
740 if (FLAG_vector_ics) { | 737 Register slot = VectorLoadICDescriptor::SlotRegister(); |
741 Register slot = VectorLoadICDescriptor::SlotRegister(); | 738 Register vector = VectorLoadICDescriptor::VectorRegister(); |
742 Register vector = VectorLoadICDescriptor::VectorRegister(); | 739 DCHECK(!rdi.is(receiver) && !rdi.is(name) && !rdi.is(slot) && |
743 DCHECK(!rdi.is(receiver) && !rdi.is(name) && !rdi.is(slot) && | 740 !rdi.is(vector)); |
744 !rdi.is(vector)); | |
745 | 741 |
746 __ PopReturnAddressTo(rdi); | 742 __ PopReturnAddressTo(rdi); |
747 __ Push(receiver); | 743 __ Push(receiver); |
748 __ Push(name); | 744 __ Push(name); |
749 __ Push(slot); | 745 __ Push(slot); |
750 __ Push(vector); | 746 __ Push(vector); |
751 __ PushReturnAddressFrom(rdi); | 747 __ PushReturnAddressFrom(rdi); |
752 } else { | |
753 DCHECK(!rbx.is(receiver) && !rbx.is(name)); | |
754 | |
755 __ PopReturnAddressTo(rbx); | |
756 __ Push(receiver); | |
757 __ Push(name); | |
758 __ PushReturnAddressFrom(rbx); | |
759 } | |
760 } | 748 } |
761 | 749 |
762 | 750 |
763 void LoadIC::GenerateMiss(MacroAssembler* masm) { | 751 void LoadIC::GenerateMiss(MacroAssembler* masm) { |
764 // The return address is on the stack. | 752 // The return address is on the stack. |
765 | 753 |
766 Counters* counters = masm->isolate()->counters(); | 754 Counters* counters = masm->isolate()->counters(); |
767 __ IncrementCounter(counters->load_miss(), 1); | 755 __ IncrementCounter(counters->load_miss(), 1); |
768 | 756 |
769 LoadIC_PushArgs(masm); | 757 LoadIC_PushArgs(masm); |
770 | 758 |
771 // Perform tail call to the entry. | 759 // Perform tail call to the entry. |
772 ExternalReference ref = | 760 ExternalReference ref = |
773 ExternalReference(IC_Utility(kLoadIC_Miss), masm->isolate()); | 761 ExternalReference(IC_Utility(kLoadIC_Miss), masm->isolate()); |
774 int arg_count = FLAG_vector_ics ? 4 : 2; | 762 int arg_count = 4; |
775 __ TailCallExternalReference(ref, arg_count, 1); | 763 __ TailCallExternalReference(ref, arg_count, 1); |
776 } | 764 } |
777 | 765 |
778 | 766 |
779 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { | 767 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
780 // The return address is on the stack. | 768 // The return address is on the stack. |
781 Register receiver = LoadDescriptor::ReceiverRegister(); | 769 Register receiver = LoadDescriptor::ReceiverRegister(); |
782 Register name = LoadDescriptor::NameRegister(); | 770 Register name = LoadDescriptor::NameRegister(); |
783 DCHECK(!rbx.is(receiver) && !rbx.is(name)); | 771 DCHECK(!rbx.is(receiver) && !rbx.is(name)); |
784 | 772 |
(...skipping 10 matching lines...) Expand all Loading... |
795 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { | 783 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { |
796 // The return address is on the stack. | 784 // The return address is on the stack. |
797 Counters* counters = masm->isolate()->counters(); | 785 Counters* counters = masm->isolate()->counters(); |
798 __ IncrementCounter(counters->keyed_load_miss(), 1); | 786 __ IncrementCounter(counters->keyed_load_miss(), 1); |
799 | 787 |
800 LoadIC_PushArgs(masm); | 788 LoadIC_PushArgs(masm); |
801 | 789 |
802 // Perform tail call to the entry. | 790 // Perform tail call to the entry. |
803 ExternalReference ref = | 791 ExternalReference ref = |
804 ExternalReference(IC_Utility(kKeyedLoadIC_Miss), masm->isolate()); | 792 ExternalReference(IC_Utility(kKeyedLoadIC_Miss), masm->isolate()); |
805 int arg_count = FLAG_vector_ics ? 4 : 2; | 793 int arg_count = 4; |
806 __ TailCallExternalReference(ref, arg_count, 1); | 794 __ TailCallExternalReference(ref, arg_count, 1); |
807 } | 795 } |
808 | 796 |
809 | 797 |
810 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { | 798 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
811 // The return address is on the stack. | 799 // The return address is on the stack. |
812 Register receiver = LoadDescriptor::ReceiverRegister(); | 800 Register receiver = LoadDescriptor::ReceiverRegister(); |
813 Register name = LoadDescriptor::NameRegister(); | 801 Register name = LoadDescriptor::NameRegister(); |
814 DCHECK(!rbx.is(receiver) && !rbx.is(name)); | 802 DCHECK(!rbx.is(receiver) && !rbx.is(name)); |
815 | 803 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 Condition cc = | 950 Condition cc = |
963 (check == ENABLE_INLINED_SMI_CHECK) | 951 (check == ENABLE_INLINED_SMI_CHECK) |
964 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) | 952 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) |
965 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); | 953 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); |
966 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 954 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
967 } | 955 } |
968 } | 956 } |
969 } // namespace v8::internal | 957 } // namespace v8::internal |
970 | 958 |
971 #endif // V8_TARGET_ARCH_X64 | 959 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |