OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
8 | 8 |
9 #include "src/arm64/assembler-arm64.h" | 9 #include "src/arm64/assembler-arm64.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 __ JumpIfRoot(result, Heap::kTheHoleValueRootIndex, &miss); | 495 __ JumpIfRoot(result, Heap::kTheHoleValueRootIndex, &miss); |
496 __ Ret(); | 496 __ Ret(); |
497 | 497 |
498 __ Bind(&miss); | 498 __ Bind(&miss); |
499 GenerateMiss(masm); | 499 GenerateMiss(masm); |
500 } | 500 } |
501 | 501 |
502 | 502 |
503 void KeyedStoreIC::GenerateSloppyArguments(MacroAssembler* masm) { | 503 void KeyedStoreIC::GenerateSloppyArguments(MacroAssembler* masm) { |
504 ASM_LOCATION("KeyedStoreIC::GenerateSloppyArguments"); | 504 ASM_LOCATION("KeyedStoreIC::GenerateSloppyArguments"); |
505 // ---------- S t a t e -------------- | |
506 // -- lr : return address | |
507 // -- x0 : value | |
508 // -- x1 : key | |
509 // -- x2 : receiver | |
510 // ----------------------------------- | |
511 Label slow, notin; | 505 Label slow, notin; |
| 506 Register value = ValueRegister(); |
| 507 Register key = NameRegister(); |
| 508 Register receiver = ReceiverRegister(); |
| 509 ASSERT(receiver.is(x2)); |
| 510 ASSERT(key.is(x1)); |
| 511 ASSERT(value.is(x0)); |
512 | 512 |
513 Register value = x0; | |
514 Register key = x1; | |
515 Register receiver = x2; | |
516 Register map = x3; | 513 Register map = x3; |
517 | 514 |
518 // These registers are used by GenerateMappedArgumentsLookup to build a | 515 // These registers are used by GenerateMappedArgumentsLookup to build a |
519 // MemOperand. They are live for as long as the MemOperand is live. | 516 // MemOperand. They are live for as long as the MemOperand is live. |
520 Register mapped1 = x4; | 517 Register mapped1 = x4; |
521 Register mapped2 = x5; | 518 Register mapped2 = x5; |
522 | 519 |
523 MemOperand mapped = | 520 MemOperand mapped = |
524 GenerateMappedArgumentsLookup(masm, receiver, key, map, | 521 GenerateMappedArgumentsLookup(masm, receiver, key, map, |
525 mapped1, mapped2, | 522 mapped1, mapped2, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 562 |
566 __ TailCallExternalReference(ref, 2, 1); | 563 __ TailCallExternalReference(ref, 2, 1); |
567 } | 564 } |
568 | 565 |
569 | 566 |
570 // IC register specifications | 567 // IC register specifications |
571 const Register LoadIC::ReceiverRegister() { return x1; } | 568 const Register LoadIC::ReceiverRegister() { return x1; } |
572 const Register LoadIC::NameRegister() { return x2; } | 569 const Register LoadIC::NameRegister() { return x2; } |
573 | 570 |
574 | 571 |
| 572 const Register StoreIC::ReceiverRegister() { return x1; } |
| 573 const Register StoreIC::NameRegister() { return x2; } |
| 574 const Register StoreIC::ValueRegister() { return x0; } |
| 575 |
| 576 |
| 577 const Register KeyedStoreIC::ReceiverRegister() { return x2; } |
| 578 const Register KeyedStoreIC::NameRegister() { return x1; } |
| 579 const Register KeyedStoreIC::ValueRegister() { return x0; } |
| 580 |
| 581 |
575 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { | 582 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
576 // The return address is in lr. | 583 // The return address is in lr. |
577 __ Push(ReceiverRegister(), NameRegister()); | 584 __ Push(ReceiverRegister(), NameRegister()); |
578 __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1); | 585 __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1); |
579 } | 586 } |
580 | 587 |
581 | 588 |
582 static void GenerateKeyedLoadWithSmiKey(MacroAssembler* masm, | 589 static void GenerateKeyedLoadWithSmiKey(MacroAssembler* masm, |
583 Register key, | 590 Register key, |
584 Register receiver, | 591 Register receiver, |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 2, | 847 2, |
841 1); | 848 1); |
842 | 849 |
843 __ Bind(&slow); | 850 __ Bind(&slow); |
844 GenerateMiss(masm); | 851 GenerateMiss(masm); |
845 } | 852 } |
846 | 853 |
847 | 854 |
848 void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { | 855 void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { |
849 ASM_LOCATION("KeyedStoreIC::GenerateMiss"); | 856 ASM_LOCATION("KeyedStoreIC::GenerateMiss"); |
850 // ---------- S t a t e -------------- | |
851 // -- x0 : value | |
852 // -- x1 : key | |
853 // -- x2 : receiver | |
854 // -- lr : return address | |
855 // ----------------------------------- | |
856 | 857 |
857 // Push receiver, key and value for runtime call. | 858 // Push receiver, key and value for runtime call. |
858 __ Push(x2, x1, x0); | 859 __ Push(ReceiverRegister(), NameRegister(), ValueRegister()); |
859 | 860 |
860 ExternalReference ref = | 861 ExternalReference ref = |
861 ExternalReference(IC_Utility(kKeyedStoreIC_Miss), masm->isolate()); | 862 ExternalReference(IC_Utility(kKeyedStoreIC_Miss), masm->isolate()); |
862 __ TailCallExternalReference(ref, 3, 1); | 863 __ TailCallExternalReference(ref, 3, 1); |
863 } | 864 } |
864 | 865 |
865 | 866 |
866 void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) { | 867 void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) { |
867 ASM_LOCATION("KeyedStoreIC::GenerateSlow"); | 868 ASM_LOCATION("KeyedStoreIC::GenerateSlow"); |
868 // ---------- S t a t e -------------- | |
869 // -- lr : return address | |
870 // -- x0 : value | |
871 // -- x1 : key | |
872 // -- x2 : receiver | |
873 // ----------------------------------- | |
874 | 869 |
875 // Push receiver, key and value for runtime call. | 870 // Push receiver, key and value for runtime call. |
876 __ Push(x2, x1, x0); | 871 __ Push(ReceiverRegister(), NameRegister(), ValueRegister()); |
877 | 872 |
878 // The slow case calls into the runtime to complete the store without causing | 873 // The slow case calls into the runtime to complete the store without causing |
879 // an IC miss that would otherwise cause a transition to the generic stub. | 874 // an IC miss that would otherwise cause a transition to the generic stub. |
880 ExternalReference ref = | 875 ExternalReference ref = |
881 ExternalReference(IC_Utility(kKeyedStoreIC_Slow), masm->isolate()); | 876 ExternalReference(IC_Utility(kKeyedStoreIC_Slow), masm->isolate()); |
882 __ TailCallExternalReference(ref, 3, 1); | 877 __ TailCallExternalReference(ref, 3, 1); |
883 } | 878 } |
884 | 879 |
885 | 880 |
886 void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, | 881 void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, |
887 StrictMode strict_mode) { | 882 StrictMode strict_mode) { |
888 ASM_LOCATION("KeyedStoreIC::GenerateRuntimeSetProperty"); | 883 ASM_LOCATION("KeyedStoreIC::GenerateRuntimeSetProperty"); |
889 // ---------- S t a t e -------------- | |
890 // -- x0 : value | |
891 // -- x1 : key | |
892 // -- x2 : receiver | |
893 // -- lr : return address | |
894 // ----------------------------------- | |
895 | 884 |
896 // Push receiver, key and value for runtime call. | 885 // Push receiver, key and value for runtime call. |
897 __ Push(x2, x1, x0); | 886 __ Push(ReceiverRegister(), NameRegister(), ValueRegister()); |
898 | 887 |
899 // Push strict_mode for runtime call. | 888 // Push strict_mode for runtime call. |
900 __ Mov(x10, Smi::FromInt(strict_mode)); | 889 __ Mov(x10, Smi::FromInt(strict_mode)); |
901 __ Push(x10); | 890 __ Push(x10); |
902 | 891 |
903 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); | 892 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); |
904 } | 893 } |
905 | 894 |
906 | 895 |
907 static void KeyedStoreGenerateGenericHelper( | 896 static void KeyedStoreGenerateGenericHelper( |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS); | 1049 mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS); |
1061 ElementsTransitionGenerator::GenerateDoubleToObject(masm, mode, slow); | 1050 ElementsTransitionGenerator::GenerateDoubleToObject(masm, mode, slow); |
1062 __ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); | 1051 __ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); |
1063 __ B(&finish_store); | 1052 __ B(&finish_store); |
1064 } | 1053 } |
1065 | 1054 |
1066 | 1055 |
1067 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, | 1056 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, |
1068 StrictMode strict_mode) { | 1057 StrictMode strict_mode) { |
1069 ASM_LOCATION("KeyedStoreIC::GenerateGeneric"); | 1058 ASM_LOCATION("KeyedStoreIC::GenerateGeneric"); |
1070 // ---------- S t a t e -------------- | |
1071 // -- x0 : value | |
1072 // -- x1 : key | |
1073 // -- x2 : receiver | |
1074 // -- lr : return address | |
1075 // ----------------------------------- | |
1076 Label slow; | 1059 Label slow; |
1077 Label array; | 1060 Label array; |
1078 Label fast_object; | 1061 Label fast_object; |
1079 Label extra; | 1062 Label extra; |
1080 Label fast_object_grow; | 1063 Label fast_object_grow; |
1081 Label fast_double_grow; | 1064 Label fast_double_grow; |
1082 Label fast_double; | 1065 Label fast_double; |
1083 | 1066 |
1084 Register value = x0; | 1067 Register value = ValueRegister(); |
1085 Register key = x1; | 1068 Register key = NameRegister(); |
1086 Register receiver = x2; | 1069 Register receiver = ReceiverRegister(); |
| 1070 ASSERT(receiver.is(x2)); |
| 1071 ASSERT(key.is(x1)); |
| 1072 ASSERT(value.is(x0)); |
| 1073 |
1087 Register receiver_map = x3; | 1074 Register receiver_map = x3; |
1088 Register elements = x4; | 1075 Register elements = x4; |
1089 Register elements_map = x5; | 1076 Register elements_map = x5; |
1090 | 1077 |
1091 __ JumpIfNotSmi(key, &slow); | 1078 __ JumpIfNotSmi(key, &slow); |
1092 __ JumpIfSmi(receiver, &slow); | 1079 __ JumpIfSmi(receiver, &slow); |
1093 __ Ldr(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 1080 __ Ldr(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
1094 | 1081 |
1095 // Check that the receiver does not require access checks and is not observed. | 1082 // Check that the receiver does not require access checks and is not observed. |
1096 // The generic stub does not perform map checks or handle observed objects. | 1083 // The generic stub does not perform map checks or handle observed objects. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 value, key, receiver, receiver_map, | 1148 value, key, receiver, receiver_map, |
1162 elements_map, elements); | 1149 elements_map, elements); |
1163 KeyedStoreGenerateGenericHelper(masm, &fast_object_grow, &fast_double_grow, | 1150 KeyedStoreGenerateGenericHelper(masm, &fast_object_grow, &fast_double_grow, |
1164 &slow, kDontCheckMap, kIncrementLength, | 1151 &slow, kDontCheckMap, kIncrementLength, |
1165 value, key, receiver, receiver_map, | 1152 value, key, receiver, receiver_map, |
1166 elements_map, elements); | 1153 elements_map, elements); |
1167 } | 1154 } |
1168 | 1155 |
1169 | 1156 |
1170 void StoreIC::GenerateMegamorphic(MacroAssembler* masm) { | 1157 void StoreIC::GenerateMegamorphic(MacroAssembler* masm) { |
1171 // ----------- S t a t e ------------- | 1158 Register receiver = ReceiverRegister(); |
1172 // -- x0 : value | 1159 Register name = NameRegister(); |
1173 // -- x1 : receiver | 1160 ASSERT(!AreAliased(receiver, name, ValueRegister(), x3, x4, x5, x6)); |
1174 // -- x2 : name | |
1175 // -- lr : return address | |
1176 // ----------------------------------- | |
1177 | 1161 |
1178 // Probe the stub cache. | 1162 // Probe the stub cache. |
1179 Code::Flags flags = Code::ComputeHandlerFlags(Code::STORE_IC); | 1163 Code::Flags flags = Code::ComputeHandlerFlags(Code::STORE_IC); |
1180 masm->isolate()->stub_cache()->GenerateProbe( | 1164 masm->isolate()->stub_cache()->GenerateProbe( |
1181 masm, flags, x1, x2, x3, x4, x5, x6); | 1165 masm, flags, receiver, name, x3, x4, x5, x6); |
1182 | 1166 |
1183 // Cache miss: Jump to runtime. | 1167 // Cache miss: Jump to runtime. |
1184 GenerateMiss(masm); | 1168 GenerateMiss(masm); |
1185 } | 1169 } |
1186 | 1170 |
1187 | 1171 |
1188 void StoreIC::GenerateMiss(MacroAssembler* masm) { | 1172 void StoreIC::GenerateMiss(MacroAssembler* masm) { |
1189 // ----------- S t a t e ------------- | 1173 __ Push(ReceiverRegister(), NameRegister(), ValueRegister()); |
1190 // -- x0 : value | |
1191 // -- x1 : receiver | |
1192 // -- x2 : name | |
1193 // -- lr : return address | |
1194 // ----------------------------------- | |
1195 | |
1196 __ Push(x1, x2, x0); | |
1197 | 1174 |
1198 // Tail call to the entry. | 1175 // Tail call to the entry. |
1199 ExternalReference ref = | 1176 ExternalReference ref = |
1200 ExternalReference(IC_Utility(kStoreIC_Miss), masm->isolate()); | 1177 ExternalReference(IC_Utility(kStoreIC_Miss), masm->isolate()); |
1201 __ TailCallExternalReference(ref, 3, 1); | 1178 __ TailCallExternalReference(ref, 3, 1); |
1202 } | 1179 } |
1203 | 1180 |
1204 | 1181 |
1205 void StoreIC::GenerateNormal(MacroAssembler* masm) { | 1182 void StoreIC::GenerateNormal(MacroAssembler* masm) { |
1206 // ----------- S t a t e ------------- | |
1207 // -- x0 : value | |
1208 // -- x1 : receiver | |
1209 // -- x2 : name | |
1210 // -- lr : return address | |
1211 // ----------------------------------- | |
1212 Label miss; | 1183 Label miss; |
1213 Register value = x0; | 1184 Register value = ValueRegister(); |
1214 Register receiver = x1; | 1185 Register receiver = ReceiverRegister(); |
1215 Register name = x2; | 1186 Register name = NameRegister(); |
1216 Register dictionary = x3; | 1187 Register dictionary = x3; |
| 1188 ASSERT(!AreAliased(value, receiver, name, x3, x4, x5)); |
1217 | 1189 |
1218 GenerateNameDictionaryReceiverCheck( | 1190 GenerateNameDictionaryReceiverCheck( |
1219 masm, receiver, dictionary, x4, x5, &miss); | 1191 masm, receiver, dictionary, x4, x5, &miss); |
1220 | 1192 |
1221 GenerateDictionaryStore(masm, &miss, dictionary, name, value, x4, x5); | 1193 GenerateDictionaryStore(masm, &miss, dictionary, name, value, x4, x5); |
1222 Counters* counters = masm->isolate()->counters(); | 1194 Counters* counters = masm->isolate()->counters(); |
1223 __ IncrementCounter(counters->store_normal_hit(), 1, x4, x5); | 1195 __ IncrementCounter(counters->store_normal_hit(), 1, x4, x5); |
1224 __ Ret(); | 1196 __ Ret(); |
1225 | 1197 |
1226 // Cache miss: Jump to runtime. | 1198 // Cache miss: Jump to runtime. |
1227 __ Bind(&miss); | 1199 __ Bind(&miss); |
1228 __ IncrementCounter(counters->store_normal_miss(), 1, x4, x5); | 1200 __ IncrementCounter(counters->store_normal_miss(), 1, x4, x5); |
1229 GenerateMiss(masm); | 1201 GenerateMiss(masm); |
1230 } | 1202 } |
1231 | 1203 |
1232 | 1204 |
1233 void StoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, | 1205 void StoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, |
1234 StrictMode strict_mode) { | 1206 StrictMode strict_mode) { |
1235 ASM_LOCATION("StoreIC::GenerateRuntimeSetProperty"); | 1207 ASM_LOCATION("StoreIC::GenerateRuntimeSetProperty"); |
1236 // ----------- S t a t e ------------- | |
1237 // -- x0 : value | |
1238 // -- x1 : receiver | |
1239 // -- x2 : name | |
1240 // -- lr : return address | |
1241 // ----------------------------------- | |
1242 | 1208 |
1243 __ Push(x1, x2, x0); | 1209 __ Push(ReceiverRegister(), NameRegister(), ValueRegister()); |
1244 | 1210 |
1245 __ Mov(x10, Smi::FromInt(strict_mode)); | 1211 __ Mov(x10, Smi::FromInt(strict_mode)); |
1246 __ Push(x10); | 1212 __ Push(x10); |
1247 | 1213 |
1248 // Do tail-call to runtime routine. | 1214 // Do tail-call to runtime routine. |
1249 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); | 1215 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); |
1250 } | 1216 } |
1251 | 1217 |
1252 | 1218 |
1253 void StoreIC::GenerateSlow(MacroAssembler* masm) { | 1219 void StoreIC::GenerateSlow(MacroAssembler* masm) { |
1254 // ---------- S t a t e -------------- | 1220 // ---------- S t a t e -------------- |
1255 // -- x0 : value | 1221 // -- x0 : value |
1256 // -- x1 : receiver | 1222 // -- x1 : receiver |
1257 // -- x2 : name | 1223 // -- x2 : name |
1258 // -- lr : return address | 1224 // -- lr : return address |
1259 // ----------------------------------- | 1225 // ----------------------------------- |
1260 | 1226 |
1261 // Push receiver, name and value for runtime call. | 1227 // Push receiver, name and value for runtime call. |
1262 __ Push(x1, x2, x0); | 1228 __ Push(ReceiverRegister(), NameRegister(), ValueRegister()); |
1263 | 1229 |
1264 // The slow case calls into the runtime to complete the store without causing | 1230 // The slow case calls into the runtime to complete the store without causing |
1265 // an IC miss that would otherwise cause a transition to the generic stub. | 1231 // an IC miss that would otherwise cause a transition to the generic stub. |
1266 ExternalReference ref = | 1232 ExternalReference ref = |
1267 ExternalReference(IC_Utility(kStoreIC_Slow), masm->isolate()); | 1233 ExternalReference(IC_Utility(kStoreIC_Slow), masm->isolate()); |
1268 __ TailCallExternalReference(ref, 3, 1); | 1234 __ TailCallExternalReference(ref, 3, 1); |
1269 } | 1235 } |
1270 | 1236 |
1271 | 1237 |
1272 Condition CompareIC::ComputeCondition(Token::Value op) { | 1238 Condition CompareIC::ComputeCondition(Token::Value op) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 ASSERT(to_patch->Mask(TestBranchMask) == TBNZ); | 1320 ASSERT(to_patch->Mask(TestBranchMask) == TBNZ); |
1355 // This is JumpIfSmi(smi_reg, branch_imm). | 1321 // This is JumpIfSmi(smi_reg, branch_imm). |
1356 patcher.tbz(smi_reg, 0, branch_imm); | 1322 patcher.tbz(smi_reg, 0, branch_imm); |
1357 } | 1323 } |
1358 } | 1324 } |
1359 | 1325 |
1360 | 1326 |
1361 } } // namespace v8::internal | 1327 } } // namespace v8::internal |
1362 | 1328 |
1363 #endif // V8_TARGET_ARCH_ARM64 | 1329 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |