OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 __ movq(rdx, rax); | 806 __ movq(rdx, rax); |
807 __ RecordWriteNonSmi(rbx, 0, rdx, rcx); | 807 __ RecordWriteNonSmi(rbx, 0, rdx, rcx); |
808 __ ret(0); | 808 __ ret(0); |
809 } | 809 } |
810 | 810 |
811 | 811 |
812 // The generated code does not accept smi keys. | 812 // The generated code does not accept smi keys. |
813 // The generated code falls through if both probes miss. | 813 // The generated code falls through if both probes miss. |
814 static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, | 814 static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, |
815 int argc, | 815 int argc, |
816 Code::Kind kind) { | 816 Code::Kind kind, |
| 817 Code::ExtraICState extra_ic_state) { |
817 // ----------- S t a t e ------------- | 818 // ----------- S t a t e ------------- |
818 // rcx : function name | 819 // rcx : function name |
819 // rdx : receiver | 820 // rdx : receiver |
820 // ----------------------------------- | 821 // ----------------------------------- |
821 Label number, non_number, non_string, boolean, probe, miss; | 822 Label number, non_number, non_string, boolean, probe, miss; |
822 | 823 |
823 // Probe the stub cache. | 824 // Probe the stub cache. |
824 Code::Flags flags = Code::ComputeFlags(kind, | 825 Code::Flags flags = Code::ComputeFlags(kind, |
825 NOT_IN_LOOP, | 826 NOT_IN_LOOP, |
826 MONOMORPHIC, | 827 MONOMORPHIC, |
827 Code::kNoExtraICState, | 828 extra_ic_state, |
828 NORMAL, | 829 NORMAL, |
829 argc); | 830 argc); |
830 Isolate::Current()->stub_cache()->GenerateProbe(masm, flags, rdx, rcx, rbx, | 831 Isolate::Current()->stub_cache()->GenerateProbe(masm, flags, rdx, rcx, rbx, |
831 rax); | 832 rax); |
832 | 833 |
833 // If the stub cache probing failed, the receiver might be a value. | 834 // If the stub cache probing failed, the receiver might be a value. |
834 // For value objects, we use the map of the prototype objects for | 835 // For value objects, we use the map of the prototype objects for |
835 // the corresponding JSValue for the cache and that is what we need | 836 // the corresponding JSValue for the cache and that is what we need |
836 // to probe. | 837 // to probe. |
837 // | 838 // |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 // rax: elements | 917 // rax: elements |
917 // Search the dictionary placing the result in rdi. | 918 // Search the dictionary placing the result in rdi. |
918 GenerateDictionaryLoad(masm, &miss, rax, rcx, rbx, rdi, rdi); | 919 GenerateDictionaryLoad(masm, &miss, rax, rcx, rbx, rdi, rdi); |
919 | 920 |
920 GenerateFunctionTailCall(masm, argc, &miss); | 921 GenerateFunctionTailCall(masm, argc, &miss); |
921 | 922 |
922 __ bind(&miss); | 923 __ bind(&miss); |
923 } | 924 } |
924 | 925 |
925 | 926 |
926 static void GenerateCallMiss(MacroAssembler* masm, int argc, IC::UtilityId id) { | 927 static void GenerateCallMiss(MacroAssembler* masm, |
| 928 int argc, |
| 929 IC::UtilityId id, |
| 930 Code::ExtraICState extra_ic_state) { |
927 // ----------- S t a t e ------------- | 931 // ----------- S t a t e ------------- |
928 // rcx : function name | 932 // rcx : function name |
929 // rsp[0] : return address | 933 // rsp[0] : return address |
930 // rsp[8] : argument argc | 934 // rsp[8] : argument argc |
931 // rsp[16] : argument argc - 1 | 935 // rsp[16] : argument argc - 1 |
932 // ... | 936 // ... |
933 // rsp[argc * 8] : argument 1 | 937 // rsp[argc * 8] : argument 1 |
934 // rsp[(argc + 1) * 8] : argument 0 = receiver | 938 // rsp[(argc + 1) * 8] : argument 0 = receiver |
935 // ----------------------------------- | 939 // ----------------------------------- |
936 | 940 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 __ j(not_equal, &invoke); | 977 __ j(not_equal, &invoke); |
974 | 978 |
975 // Patch the receiver on the stack. | 979 // Patch the receiver on the stack. |
976 __ bind(&global); | 980 __ bind(&global); |
977 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); | 981 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); |
978 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); | 982 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); |
979 __ bind(&invoke); | 983 __ bind(&invoke); |
980 } | 984 } |
981 | 985 |
982 // Invoke the function. | 986 // Invoke the function. |
| 987 CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state) |
| 988 ? CALL_AS_FUNCTION |
| 989 : CALL_AS_METHOD; |
983 ParameterCount actual(argc); | 990 ParameterCount actual(argc); |
984 __ InvokeFunction(rdi, actual, JUMP_FUNCTION); | 991 __ InvokeFunction(rdi, |
| 992 actual, |
| 993 JUMP_FUNCTION, |
| 994 NullCallWrapper(), |
| 995 call_kind); |
985 } | 996 } |
986 | 997 |
987 | 998 |
988 void CallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { | 999 void CallIC::GenerateMegamorphic(MacroAssembler* masm, |
| 1000 int argc, |
| 1001 Code::ExtraICState extra_ic_state) { |
989 // ----------- S t a t e ------------- | 1002 // ----------- S t a t e ------------- |
990 // rcx : function name | 1003 // rcx : function name |
991 // rsp[0] : return address | 1004 // rsp[0] : return address |
992 // rsp[8] : argument argc | 1005 // rsp[8] : argument argc |
993 // rsp[16] : argument argc - 1 | 1006 // rsp[16] : argument argc - 1 |
994 // ... | 1007 // ... |
995 // rsp[argc * 8] : argument 1 | 1008 // rsp[argc * 8] : argument 1 |
996 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1009 // rsp[(argc + 1) * 8] : argument 0 = receiver |
997 // ----------------------------------- | 1010 // ----------------------------------- |
998 | 1011 |
999 // Get the receiver of the function from the stack; 1 ~ return address. | 1012 // Get the receiver of the function from the stack; 1 ~ return address. |
1000 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 1013 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); |
1001 GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC); | 1014 GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, extra_ic_state); |
1002 GenerateMiss(masm, argc); | 1015 GenerateMiss(masm, argc, extra_ic_state); |
1003 } | 1016 } |
1004 | 1017 |
1005 | 1018 |
1006 void CallIC::GenerateNormal(MacroAssembler* masm, int argc) { | 1019 void CallIC::GenerateNormal(MacroAssembler* masm, int argc) { |
1007 // ----------- S t a t e ------------- | 1020 // ----------- S t a t e ------------- |
1008 // rcx : function name | 1021 // rcx : function name |
1009 // rsp[0] : return address | 1022 // rsp[0] : return address |
1010 // rsp[8] : argument argc | 1023 // rsp[8] : argument argc |
1011 // rsp[16] : argument argc - 1 | 1024 // rsp[16] : argument argc - 1 |
1012 // ... | 1025 // ... |
1013 // rsp[argc * 8] : argument 1 | 1026 // rsp[argc * 8] : argument 1 |
1014 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1027 // rsp[(argc + 1) * 8] : argument 0 = receiver |
1015 // ----------------------------------- | 1028 // ----------------------------------- |
1016 | 1029 |
1017 GenerateCallNormal(masm, argc); | 1030 GenerateCallNormal(masm, argc); |
1018 GenerateMiss(masm, argc); | 1031 GenerateMiss(masm, argc, Code::kNoExtraICState); |
1019 } | 1032 } |
1020 | 1033 |
1021 | 1034 |
1022 void CallIC::GenerateMiss(MacroAssembler* masm, int argc) { | 1035 void CallIC::GenerateMiss(MacroAssembler* masm, |
| 1036 int argc, |
| 1037 Code::ExtraICState extra_ic_state) { |
1023 // ----------- S t a t e ------------- | 1038 // ----------- S t a t e ------------- |
1024 // rcx : function name | 1039 // rcx : function name |
1025 // rsp[0] : return address | 1040 // rsp[0] : return address |
1026 // rsp[8] : argument argc | 1041 // rsp[8] : argument argc |
1027 // rsp[16] : argument argc - 1 | 1042 // rsp[16] : argument argc - 1 |
1028 // ... | 1043 // ... |
1029 // rsp[argc * 8] : argument 1 | 1044 // rsp[argc * 8] : argument 1 |
1030 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1045 // rsp[(argc + 1) * 8] : argument 0 = receiver |
1031 // ----------------------------------- | 1046 // ----------------------------------- |
1032 | 1047 |
1033 GenerateCallMiss(masm, argc, IC::kCallIC_Miss); | 1048 GenerateCallMiss(masm, argc, IC::kCallIC_Miss, extra_ic_state); |
1034 } | 1049 } |
1035 | 1050 |
1036 | 1051 |
1037 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { | 1052 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { |
1038 // ----------- S t a t e ------------- | 1053 // ----------- S t a t e ------------- |
1039 // rcx : function name | 1054 // rcx : function name |
1040 // rsp[0] : return address | 1055 // rsp[0] : return address |
1041 // rsp[8] : argument argc | 1056 // rsp[8] : argument argc |
1042 // rsp[16] : argument argc - 1 | 1057 // rsp[16] : argument argc - 1 |
1043 // ... | 1058 // ... |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), | 1129 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), |
1115 Heap::kHashTableMapRootIndex); | 1130 Heap::kHashTableMapRootIndex); |
1116 __ j(not_equal, &lookup_monomorphic_cache); | 1131 __ j(not_equal, &lookup_monomorphic_cache); |
1117 | 1132 |
1118 GenerateDictionaryLoad(masm, &slow_load, rbx, rcx, rax, rdi, rdi); | 1133 GenerateDictionaryLoad(masm, &slow_load, rbx, rcx, rax, rdi, rdi); |
1119 __ IncrementCounter(counters->keyed_call_generic_lookup_dict(), 1); | 1134 __ IncrementCounter(counters->keyed_call_generic_lookup_dict(), 1); |
1120 __ jmp(&do_call); | 1135 __ jmp(&do_call); |
1121 | 1136 |
1122 __ bind(&lookup_monomorphic_cache); | 1137 __ bind(&lookup_monomorphic_cache); |
1123 __ IncrementCounter(counters->keyed_call_generic_lookup_cache(), 1); | 1138 __ IncrementCounter(counters->keyed_call_generic_lookup_cache(), 1); |
1124 GenerateMonomorphicCacheProbe(masm, argc, Code::KEYED_CALL_IC); | 1139 GenerateMonomorphicCacheProbe(masm, |
| 1140 argc, |
| 1141 Code::KEYED_CALL_IC, |
| 1142 Code::kNoExtraICState); |
1125 // Fall through on miss. | 1143 // Fall through on miss. |
1126 | 1144 |
1127 __ bind(&slow_call); | 1145 __ bind(&slow_call); |
1128 // This branch is taken if: | 1146 // This branch is taken if: |
1129 // - the receiver requires boxing or access check, | 1147 // - the receiver requires boxing or access check, |
1130 // - the key is neither smi nor symbol, | 1148 // - the key is neither smi nor symbol, |
1131 // - the value loaded is not a function, | 1149 // - the value loaded is not a function, |
1132 // - there is hope that the runtime will create a monomorphic call stub | 1150 // - there is hope that the runtime will create a monomorphic call stub |
1133 // that will get fetched next time. | 1151 // that will get fetched next time. |
1134 __ IncrementCounter(counters->keyed_call_generic_slow(), 1); | 1152 __ IncrementCounter(counters->keyed_call_generic_slow(), 1); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 // ----------- S t a t e ------------- | 1185 // ----------- S t a t e ------------- |
1168 // rcx : function name | 1186 // rcx : function name |
1169 // rsp[0] : return address | 1187 // rsp[0] : return address |
1170 // rsp[8] : argument argc | 1188 // rsp[8] : argument argc |
1171 // rsp[16] : argument argc - 1 | 1189 // rsp[16] : argument argc - 1 |
1172 // ... | 1190 // ... |
1173 // rsp[argc * 8] : argument 1 | 1191 // rsp[argc * 8] : argument 1 |
1174 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1192 // rsp[(argc + 1) * 8] : argument 0 = receiver |
1175 // ----------------------------------- | 1193 // ----------------------------------- |
1176 | 1194 |
1177 GenerateCallMiss(masm, argc, IC::kKeyedCallIC_Miss); | 1195 GenerateCallMiss(masm, argc, IC::kKeyedCallIC_Miss, Code::kNoExtraICState); |
1178 } | 1196 } |
1179 | 1197 |
1180 | 1198 |
1181 void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { | 1199 void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { |
1182 // ----------- S t a t e ------------- | 1200 // ----------- S t a t e ------------- |
1183 // -- rax : receiver | 1201 // -- rax : receiver |
1184 // -- rcx : name | 1202 // -- rcx : name |
1185 // -- rsp[0] : return address | 1203 // -- rsp[0] : return address |
1186 // ----------------------------------- | 1204 // ----------------------------------- |
1187 | 1205 |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 Condition cc = *jmp_address == Assembler::kJncShortOpcode | 1599 Condition cc = *jmp_address == Assembler::kJncShortOpcode |
1582 ? not_zero | 1600 ? not_zero |
1583 : zero; | 1601 : zero; |
1584 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1602 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
1585 } | 1603 } |
1586 | 1604 |
1587 | 1605 |
1588 } } // namespace v8::internal | 1606 } } // namespace v8::internal |
1589 | 1607 |
1590 #endif // V8_TARGET_ARCH_X64 | 1608 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |