OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 | 222 |
223 | 223 |
224 void KeyedStoreIC::RestoreInlinedVersion(Address address) { | 224 void KeyedStoreIC::RestoreInlinedVersion(Address address) { |
225 // Restore the fast-case elements map check so that the inlined | 225 // Restore the fast-case elements map check so that the inlined |
226 // version can be used again. | 226 // version can be used again. |
227 PatchInlinedStore(address, Heap::fixed_array_map()); | 227 PatchInlinedStore(address, Heap::fixed_array_map()); |
228 } | 228 } |
229 | 229 |
230 | 230 |
231 void KeyedLoadIC::Generate(MacroAssembler* masm, | 231 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { |
232 ExternalReference const& f) { | |
233 // ----------- S t a t e ------------- | 232 // ----------- S t a t e ------------- |
234 // -- rsp[0] : return address | 233 // -- rsp[0] : return address |
235 // -- rsp[8] : name | 234 // -- rsp[8] : name |
236 // -- rsp[16] : receiver | 235 // -- rsp[16] : receiver |
237 // ----------------------------------- | 236 // ----------------------------------- |
238 | 237 |
239 __ movq(rax, Operand(rsp, kPointerSize)); | |
240 __ movq(rcx, Operand(rsp, 2 * kPointerSize)); | |
241 __ pop(rbx); | 238 __ pop(rbx); |
242 __ push(rcx); // receiver | 239 __ push(Operand(rsp, 1 * kPointerSize)); // receiver |
243 __ push(rax); // name | 240 __ push(Operand(rsp, 1 * kPointerSize)); // name |
244 __ push(rbx); // return address | 241 __ push(rbx); // return address |
245 | 242 |
246 // Perform tail call to the entry. | 243 // Perform tail call to the entry. |
247 __ TailCallRuntime(f, 2, 1); | 244 __ TailCallRuntime(ExternalReference(IC_Utility(kKeyedLoadIC_Miss)), 2, 1); |
| 245 } |
| 246 |
| 247 |
| 248 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
| 249 // ----------- S t a t e ------------- |
| 250 // -- rsp[0] : return address |
| 251 // -- rsp[8] : name |
| 252 // -- rsp[16] : receiver |
| 253 // ----------------------------------- |
| 254 |
| 255 __ pop(rbx); |
| 256 __ push(Operand(rsp, 1 * kPointerSize)); // receiver |
| 257 __ push(Operand(rsp, 1 * kPointerSize)); // name |
| 258 __ push(rbx); // return address |
| 259 |
| 260 // Perform tail call to the entry. |
| 261 __ TailCallRuntime(ExternalReference(Runtime::kKeyedGetProperty), 2, 1); |
248 } | 262 } |
249 | 263 |
250 | 264 |
251 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { | 265 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { |
252 // ----------- S t a t e ------------- | 266 // ----------- S t a t e ------------- |
253 // -- rsp[0] : return address | 267 // -- rsp[0] : return address |
254 // -- rsp[8] : name | 268 // -- rsp[8] : name |
255 // -- rsp[16] : receiver | 269 // -- rsp[16] : receiver |
256 // ----------------------------------- | 270 // ----------------------------------- |
257 Label slow, check_string, index_int, index_string; | 271 Label slow, check_string, index_int, index_string; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 __ cmpl(rax, FieldOperand(rcx, PixelArray::kLengthOffset)); | 324 __ cmpl(rax, FieldOperand(rcx, PixelArray::kLengthOffset)); |
311 __ j(above_equal, &slow); | 325 __ j(above_equal, &slow); |
312 __ movq(rcx, FieldOperand(rcx, PixelArray::kExternalPointerOffset)); | 326 __ movq(rcx, FieldOperand(rcx, PixelArray::kExternalPointerOffset)); |
313 __ movzxbq(rax, Operand(rcx, rax, times_1, 0)); | 327 __ movzxbq(rax, Operand(rcx, rax, times_1, 0)); |
314 __ Integer32ToSmi(rax, rax); | 328 __ Integer32ToSmi(rax, rax); |
315 __ ret(0); | 329 __ ret(0); |
316 | 330 |
317 // Slow case: Load name and receiver from stack and jump to runtime. | 331 // Slow case: Load name and receiver from stack and jump to runtime. |
318 __ bind(&slow); | 332 __ bind(&slow); |
319 __ IncrementCounter(&Counters::keyed_load_generic_slow, 1); | 333 __ IncrementCounter(&Counters::keyed_load_generic_slow, 1); |
320 Generate(masm, ExternalReference(Runtime::kKeyedGetProperty)); | 334 GenerateRuntimeGetProperty(masm); |
321 __ bind(&check_string); | 335 __ bind(&check_string); |
322 // The key is not a smi. | 336 // The key is not a smi. |
323 // Is it a string? | 337 // Is it a string? |
324 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdx); | 338 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdx); |
325 __ j(above_equal, &slow); | 339 __ j(above_equal, &slow); |
326 // Is the string an array index, with cached numeric value? | 340 // Is the string an array index, with cached numeric value? |
327 __ movl(rbx, FieldOperand(rax, String::kHashFieldOffset)); | 341 __ movl(rbx, FieldOperand(rax, String::kHashFieldOffset)); |
328 __ testl(rbx, Immediate(String::kIsArrayIndexMask)); | 342 __ testl(rbx, Immediate(String::kIsArrayIndexMask)); |
329 | 343 |
330 // Is the string a symbol? | 344 // Is the string a symbol? |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 // If we fail allocation of the HeapNumber, we still have a value on | 562 // If we fail allocation of the HeapNumber, we still have a value on |
549 // top of the FPU stack. Remove it. | 563 // top of the FPU stack. Remove it. |
550 __ bind(&failed_allocation); | 564 __ bind(&failed_allocation); |
551 __ ffree(); | 565 __ ffree(); |
552 __ fincstp(); | 566 __ fincstp(); |
553 // Fall through to slow case. | 567 // Fall through to slow case. |
554 | 568 |
555 // Slow case: Load name and receiver from stack and jump to runtime. | 569 // Slow case: Load name and receiver from stack and jump to runtime. |
556 __ bind(&slow); | 570 __ bind(&slow); |
557 __ IncrementCounter(&Counters::keyed_load_external_array_slow, 1); | 571 __ IncrementCounter(&Counters::keyed_load_external_array_slow, 1); |
558 Generate(masm, ExternalReference(Runtime::kKeyedGetProperty)); | 572 GenerateRuntimeGetProperty(masm); |
559 } | 573 } |
560 | 574 |
561 | 575 |
562 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { | 576 void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { |
563 // ----------- S t a t e ------------- | 577 // ----------- S t a t e ------------- |
564 // -- rsp[0] : return address | 578 // -- rax : value |
565 // -- rsp[8] : name | 579 // -- rsp[0] : return address |
| 580 // -- rsp[8] : key |
566 // -- rsp[16] : receiver | 581 // -- rsp[16] : receiver |
567 // ----------------------------------- | 582 // ----------------------------------- |
568 Generate(masm, ExternalReference(IC_Utility(kKeyedLoadIC_Miss))); | 583 |
| 584 __ pop(rcx); |
| 585 __ push(Operand(rsp, 1 * kPointerSize)); // receiver |
| 586 __ push(Operand(rsp, 1 * kPointerSize)); // key |
| 587 __ push(rax); // value |
| 588 __ push(rcx); // return address |
| 589 |
| 590 // Do tail-call to runtime routine. |
| 591 __ TailCallRuntime(ExternalReference(IC_Utility(kKeyedStoreIC_Miss)), 3, 1); |
569 } | 592 } |
570 | 593 |
571 | 594 |
572 void KeyedStoreIC::Generate(MacroAssembler* masm, ExternalReference const& f) { | 595 void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm) { |
573 // ----------- S t a t e ------------- | 596 // ----------- S t a t e ------------- |
574 // -- rax : value | 597 // -- rax : value |
575 // -- rsp[0] : return address | 598 // -- rsp[0] : return address |
576 // -- rsp[8] : key | 599 // -- rsp[8] : key |
577 // -- rsp[16] : receiver | 600 // -- rsp[16] : receiver |
578 // ----------------------------------- | 601 // ----------------------------------- |
579 | 602 |
580 __ pop(rcx); | 603 __ pop(rcx); |
581 __ push(Operand(rsp, 1 * kPointerSize)); // receiver | 604 __ push(Operand(rsp, 1 * kPointerSize)); // receiver |
582 __ push(Operand(rsp, 1 * kPointerSize)); // key | 605 __ push(Operand(rsp, 1 * kPointerSize)); // key |
583 __ push(rax); // value | 606 __ push(rax); // value |
584 __ push(rcx); // return address | 607 __ push(rcx); // return address |
585 | 608 |
586 // Do tail-call to runtime routine. | 609 // Do tail-call to runtime routine. |
587 __ TailCallRuntime(f, 3, 1); | 610 __ TailCallRuntime(ExternalReference(Runtime::kSetProperty), 3, 1); |
588 } | 611 } |
589 | 612 |
590 | 613 |
591 void KeyedStoreIC::GenerateExtendStorage(MacroAssembler* masm) { | 614 void KeyedStoreIC::GenerateExtendStorage(MacroAssembler* masm) { |
592 // ----------- S t a t e ------------- | 615 // ----------- S t a t e ------------- |
593 // -- rax : value | 616 // -- rax : value |
594 // -- rcx : transition map | 617 // -- rcx : transition map |
595 // -- rsp[0] : return address | 618 // -- rsp[0] : return address |
596 // -- rsp[8] : key | 619 // -- rsp[8] : key |
597 // -- rsp[16] : receiver | 620 // -- rsp[16] : receiver |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 // Untag the key (for checking against untagged length in the fixed array). | 675 // Untag the key (for checking against untagged length in the fixed array). |
653 __ SmiToInteger32(rdx, rbx); | 676 __ SmiToInteger32(rdx, rbx); |
654 __ cmpl(rdx, FieldOperand(rcx, Array::kLengthOffset)); | 677 __ cmpl(rdx, FieldOperand(rcx, Array::kLengthOffset)); |
655 // rax: value | 678 // rax: value |
656 // rcx: FixedArray | 679 // rcx: FixedArray |
657 // rbx: index (as a smi) | 680 // rbx: index (as a smi) |
658 __ j(below, &fast); | 681 __ j(below, &fast); |
659 | 682 |
660 // Slow case: call runtime. | 683 // Slow case: call runtime. |
661 __ bind(&slow); | 684 __ bind(&slow); |
662 Generate(masm, ExternalReference(Runtime::kSetProperty)); | 685 GenerateRuntimeSetProperty(masm); |
663 | 686 |
664 // Check whether the elements is a pixel array. | 687 // Check whether the elements is a pixel array. |
665 // rax: value | 688 // rax: value |
666 // rcx: elements array | 689 // rcx: elements array |
667 // rbx: index (as a smi), zero-extended. | 690 // rbx: index (as a smi), zero-extended. |
668 __ bind(&check_pixel_array); | 691 __ bind(&check_pixel_array); |
669 __ CompareRoot(FieldOperand(rcx, HeapObject::kMapOffset), | 692 __ CompareRoot(FieldOperand(rcx, HeapObject::kMapOffset), |
670 Heap::kPixelArrayMapRootIndex); | 693 Heap::kPixelArrayMapRootIndex); |
671 __ j(not_equal, &slow); | 694 __ j(not_equal, &slow); |
672 // Check that the value is a smi. If a conversion is needed call into the | 695 // Check that the value is a smi. If a conversion is needed call into the |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 default: | 939 default: |
917 UNREACHABLE(); | 940 UNREACHABLE(); |
918 break; | 941 break; |
919 } | 942 } |
920 __ movq(rax, rdx); // Return the original value. | 943 __ movq(rax, rdx); // Return the original value. |
921 __ ret(0); | 944 __ ret(0); |
922 } | 945 } |
923 | 946 |
924 // Slow case: call runtime. | 947 // Slow case: call runtime. |
925 __ bind(&slow); | 948 __ bind(&slow); |
926 Generate(masm, ExternalReference(Runtime::kSetProperty)); | 949 GenerateRuntimeSetProperty(masm); |
927 } | 950 } |
928 | 951 |
929 | 952 |
930 void CallIC::GenerateMiss(MacroAssembler* masm, int argc) { | 953 void CallIC::GenerateMiss(MacroAssembler* masm, int argc) { |
931 // Get the receiver of the function from the stack; 1 ~ return address. | 954 // Get the receiver of the function from the stack; 1 ~ return address. |
932 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 955 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); |
933 // Get the name of the function to call from the stack. | 956 // Get the name of the function to call from the stack. |
934 // 2 ~ receiver, return address. | 957 // 2 ~ receiver, return address. |
935 __ movq(rbx, Operand(rsp, (argc + 2) * kPointerSize)); | 958 __ movq(rbx, Operand(rsp, (argc + 2) * kPointerSize)); |
936 | 959 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 | 1169 |
1147 | 1170 |
1148 void LoadIC::ClearInlinedVersion(Address address) { | 1171 void LoadIC::ClearInlinedVersion(Address address) { |
1149 // Reset the map check of the inlined inobject property load (if | 1172 // Reset the map check of the inlined inobject property load (if |
1150 // present) to guarantee failure by holding an invalid map (the null | 1173 // present) to guarantee failure by holding an invalid map (the null |
1151 // value). The offset can be patched to anything. | 1174 // value). The offset can be patched to anything. |
1152 PatchInlinedLoad(address, Heap::null_value(), kMaxInt); | 1175 PatchInlinedLoad(address, Heap::null_value(), kMaxInt); |
1153 } | 1176 } |
1154 | 1177 |
1155 | 1178 |
1156 void LoadIC::Generate(MacroAssembler* masm, ExternalReference const& f) { | 1179 void LoadIC::GenerateMiss(MacroAssembler* masm) { |
1157 // ----------- S t a t e ------------- | 1180 // ----------- S t a t e ------------- |
1158 // -- rcx : name | 1181 // -- rcx : name |
1159 // -- rsp[0] : return address | 1182 // -- rsp[0] : return address |
1160 // -- rsp[8] : receiver | 1183 // -- rsp[8] : receiver |
1161 // ----------------------------------- | 1184 // ----------------------------------- |
1162 | 1185 |
1163 __ movq(rax, Operand(rsp, kPointerSize)); | |
1164 | |
1165 __ pop(rbx); | 1186 __ pop(rbx); |
1166 __ push(rax); // receiver | 1187 __ push(Operand(rsp, 0)); // receiver |
1167 __ push(rcx); // name | 1188 __ push(rcx); // name |
1168 __ push(rbx); // return address | 1189 __ push(rbx); // return address |
1169 | 1190 |
1170 // Perform tail call to the entry. | 1191 // Perform tail call to the entry. |
1171 __ TailCallRuntime(f, 2, 1); | 1192 __ TailCallRuntime(ExternalReference(IC_Utility(kLoadIC_Miss)), 2, 1); |
1172 } | 1193 } |
1173 | 1194 |
1174 | 1195 |
1175 void LoadIC::GenerateArrayLength(MacroAssembler* masm) { | 1196 void LoadIC::GenerateArrayLength(MacroAssembler* masm) { |
1176 // ----------- S t a t e ------------- | 1197 // ----------- S t a t e ------------- |
1177 // -- rcx : name | 1198 // -- rcx : name |
1178 // -- rsp[0] : return address | 1199 // -- rsp[0] : return address |
1179 // -- rsp[8] : receiver | 1200 // -- rsp[8] : receiver |
1180 // ----------------------------------- | 1201 // ----------------------------------- |
1181 Label miss; | 1202 Label miss; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, | 1238 Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, |
1218 NOT_IN_LOOP, | 1239 NOT_IN_LOOP, |
1219 MONOMORPHIC); | 1240 MONOMORPHIC); |
1220 StubCache::GenerateProbe(masm, flags, rax, rcx, rbx, rdx); | 1241 StubCache::GenerateProbe(masm, flags, rax, rcx, rbx, rdx); |
1221 | 1242 |
1222 // Cache miss: Jump to runtime. | 1243 // Cache miss: Jump to runtime. |
1223 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); | 1244 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); |
1224 } | 1245 } |
1225 | 1246 |
1226 | 1247 |
1227 void LoadIC::GenerateMiss(MacroAssembler* masm) { | |
1228 // ----------- S t a t e ------------- | |
1229 // -- rcx : name | |
1230 // -- rsp[0] : return address | |
1231 // -- rsp[8] : receiver | |
1232 // ----------------------------------- | |
1233 | |
1234 Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss))); | |
1235 } | |
1236 | |
1237 | |
1238 void LoadIC::GenerateNormal(MacroAssembler* masm) { | 1248 void LoadIC::GenerateNormal(MacroAssembler* masm) { |
1239 // ----------- S t a t e ------------- | 1249 // ----------- S t a t e ------------- |
1240 // -- rcx : name | 1250 // -- rcx : name |
1241 // -- rsp[0] : return address | 1251 // -- rsp[0] : return address |
1242 // -- rsp[8] : receiver | 1252 // -- rsp[8] : receiver |
1243 // ----------------------------------- | 1253 // ----------------------------------- |
1244 Label miss, probe, global; | 1254 Label miss, probe, global; |
1245 | 1255 |
1246 __ movq(rax, Operand(rsp, kPointerSize)); | 1256 __ movq(rax, Operand(rsp, kPointerSize)); |
1247 | 1257 |
(...skipping 23 matching lines...) Expand all Loading... |
1271 __ ret(0); | 1281 __ ret(0); |
1272 | 1282 |
1273 // Global object access: Check access rights. | 1283 // Global object access: Check access rights. |
1274 __ bind(&global); | 1284 __ bind(&global); |
1275 __ CheckAccessGlobalProxy(rax, rdx, &miss); | 1285 __ CheckAccessGlobalProxy(rax, rdx, &miss); |
1276 __ jmp(&probe); | 1286 __ jmp(&probe); |
1277 | 1287 |
1278 // Cache miss: Restore receiver from stack and jump to runtime. | 1288 // Cache miss: Restore receiver from stack and jump to runtime. |
1279 __ bind(&miss); | 1289 __ bind(&miss); |
1280 __ movq(rax, Operand(rsp, 1 * kPointerSize)); | 1290 __ movq(rax, Operand(rsp, 1 * kPointerSize)); |
1281 Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss))); | 1291 GenerateMiss(masm); |
1282 } | 1292 } |
1283 | 1293 |
1284 | 1294 |
1285 void LoadIC::GenerateStringLength(MacroAssembler* masm) { | 1295 void LoadIC::GenerateStringLength(MacroAssembler* masm) { |
1286 // ----------- S t a t e ------------- | 1296 // ----------- S t a t e ------------- |
1287 // -- rcx : name | 1297 // -- rcx : name |
1288 // -- rsp[0] : return address | 1298 // -- rsp[0] : return address |
1289 // -- rsp[8] : receiver | 1299 // -- rsp[8] : receiver |
1290 // ----------------------------------- | 1300 // ----------------------------------- |
1291 Label miss; | 1301 Label miss; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 | 1389 |
1380 // Cache miss: Jump to runtime. | 1390 // Cache miss: Jump to runtime. |
1381 GenerateMiss(masm); | 1391 GenerateMiss(masm); |
1382 } | 1392 } |
1383 | 1393 |
1384 | 1394 |
1385 #undef __ | 1395 #undef __ |
1386 | 1396 |
1387 | 1397 |
1388 } } // namespace v8::internal | 1398 } } // namespace v8::internal |
OLD | NEW |