Chromium Code Reviews| 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 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1449 STATIC_ASSERT(kSmiTag == 0); | 1449 STATIC_ASSERT(kSmiTag == 0); |
| 1450 __ add(Operand(eax), Immediate(Smi::FromInt(argc))); | 1450 __ add(Operand(eax), Immediate(Smi::FromInt(argc))); |
| 1451 | 1451 |
| 1452 // Get the element's length into ecx. | 1452 // Get the element's length into ecx. |
| 1453 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); | 1453 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); |
| 1454 | 1454 |
| 1455 // Check if we could survive without allocation. | 1455 // Check if we could survive without allocation. |
| 1456 __ cmp(eax, Operand(ecx)); | 1456 __ cmp(eax, Operand(ecx)); |
| 1457 __ j(greater, &attempt_to_grow_elements); | 1457 __ j(greater, &attempt_to_grow_elements); |
| 1458 | 1458 |
| 1459 // Check if value is a smi. | |
| 1460 __ mov(ecx, Operand(esp, argc * kPointerSize)); | |
| 1461 __ JumpIfNotSmi(ecx, &with_write_barrier); | |
| 1462 | |
| 1459 // Save new length. | 1463 // Save new length. |
| 1460 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); | 1464 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); |
| 1461 | 1465 |
| 1462 // Push the element. | 1466 // Push the element. |
| 1463 __ lea(edx, FieldOperand(ebx, | 1467 __ lea(edx, FieldOperand(ebx, |
| 1464 eax, times_half_pointer_size, | 1468 eax, times_half_pointer_size, |
| 1465 FixedArray::kHeaderSize - argc * kPointerSize)); | 1469 FixedArray::kHeaderSize - argc * kPointerSize)); |
| 1466 __ mov(ecx, Operand(esp, argc * kPointerSize)); | |
| 1467 __ mov(Operand(edx, 0), ecx); | 1470 __ mov(Operand(edx, 0), ecx); |
| 1468 | 1471 |
| 1469 // Check if value is a smi. | |
| 1470 __ JumpIfNotSmi(ecx, &with_write_barrier); | |
| 1471 | |
| 1472 __ bind(&exit); | 1472 __ bind(&exit); |
| 1473 __ ret((argc + 1) * kPointerSize); | 1473 __ ret((argc + 1) * kPointerSize); |
| 1474 | 1474 |
| 1475 __ bind(&with_write_barrier); | 1475 __ bind(&with_write_barrier); |
| 1476 | 1476 |
| 1477 if (FLAG_smi_only_arrays) { | |
| 1478 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); | |
| 1479 __ CheckFastObjectElements(edi, &call_builtin, Label::kFar); | |
| 1480 } | |
| 1481 | |
| 1482 // Save new length. | |
| 1483 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); | |
| 1484 | |
| 1485 // Push the element. | |
| 1486 __ lea(edx, FieldOperand(ebx, | |
| 1487 eax, times_half_pointer_size, | |
| 1488 FixedArray::kHeaderSize - argc * kPointerSize)); | |
| 1489 __ mov(Operand(edx, 0), ecx); | |
| 1490 | |
| 1477 __ InNewSpace(ebx, ecx, equal, &exit); | 1491 __ InNewSpace(ebx, ecx, equal, &exit); |
| 1478 | 1492 |
| 1479 __ RecordWriteHelper(ebx, edx, ecx); | 1493 __ RecordWriteHelper(ebx, edx, ecx); |
| 1480 __ ret((argc + 1) * kPointerSize); | 1494 __ ret((argc + 1) * kPointerSize); |
| 1481 | 1495 |
| 1482 __ bind(&attempt_to_grow_elements); | 1496 __ bind(&attempt_to_grow_elements); |
| 1483 if (!FLAG_inline_new) { | 1497 if (!FLAG_inline_new) { |
| 1484 __ jmp(&call_builtin); | 1498 __ jmp(&call_builtin); |
| 1485 } | 1499 } |
| 1486 | 1500 |
| 1501 __ mov(edi, Operand(esp, argc * kPointerSize)); | |
| 1502 | |
| 1503 if (FLAG_smi_only_arrays) { | |
| 1504 Label no_fast_elements_check; | |
| 1505 __ JumpIfSmi(edi, &no_fast_elements_check); | |
| 1506 __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); | |
| 1507 __ CheckFastObjectElements(ebx, &call_builtin, Label::kNear); | |
| 1508 __ bind(&no_fast_elements_check); | |
| 1509 } | |
| 1510 | |
| 1487 ExternalReference new_space_allocation_top = | 1511 ExternalReference new_space_allocation_top = |
| 1488 ExternalReference::new_space_allocation_top_address(isolate()); | 1512 ExternalReference::new_space_allocation_top_address(isolate()); |
| 1489 ExternalReference new_space_allocation_limit = | 1513 ExternalReference new_space_allocation_limit = |
| 1490 ExternalReference::new_space_allocation_limit_address(isolate()); | 1514 ExternalReference::new_space_allocation_limit_address(isolate()); |
| 1491 | 1515 |
| 1492 const int kAllocationDelta = 4; | 1516 const int kAllocationDelta = 4; |
| 1493 // Load top. | 1517 // Load top. |
| 1494 __ mov(ecx, Operand::StaticVariable(new_space_allocation_top)); | 1518 __ mov(ecx, Operand::StaticVariable(new_space_allocation_top)); |
| 1495 | 1519 |
| 1496 // Check if it's the end of elements. | 1520 // Check if it's the end of elements. |
| 1497 __ lea(edx, FieldOperand(ebx, | 1521 __ lea(edx, FieldOperand(ebx, |
| 1498 eax, times_half_pointer_size, | 1522 eax, times_half_pointer_size, |
| 1499 FixedArray::kHeaderSize - argc * kPointerSize)); | 1523 FixedArray::kHeaderSize - argc * kPointerSize)); |
| 1500 __ cmp(edx, Operand(ecx)); | 1524 __ cmp(edx, Operand(ecx)); |
| 1501 __ j(not_equal, &call_builtin); | 1525 __ j(not_equal, &call_builtin); |
| 1502 __ add(Operand(ecx), Immediate(kAllocationDelta * kPointerSize)); | 1526 __ add(Operand(ecx), Immediate(kAllocationDelta * kPointerSize)); |
| 1503 __ cmp(ecx, Operand::StaticVariable(new_space_allocation_limit)); | 1527 __ cmp(ecx, Operand::StaticVariable(new_space_allocation_limit)); |
| 1504 __ j(above, &call_builtin); | 1528 __ j(above, &call_builtin); |
| 1505 | 1529 |
| 1506 // We fit and could grow elements. | 1530 // We fit and could grow elements. |
| 1507 __ mov(Operand::StaticVariable(new_space_allocation_top), ecx); | 1531 __ mov(Operand::StaticVariable(new_space_allocation_top), ecx); |
| 1508 __ mov(ecx, Operand(esp, argc * kPointerSize)); | |
| 1509 | 1532 |
| 1510 // Push the argument... | 1533 // Push the argument... |
| 1511 __ mov(Operand(edx, 0), ecx); | 1534 __ mov(Operand(edx, 0), edi); |
| 1512 // ... and fill the rest with holes. | 1535 // ... and fill the rest with holes. |
| 1513 for (int i = 1; i < kAllocationDelta; i++) { | 1536 for (int i = 1; i < kAllocationDelta; i++) { |
| 1514 __ mov(Operand(edx, i * kPointerSize), | 1537 __ mov(Operand(edx, i * kPointerSize), |
| 1515 Immediate(factory()->the_hole_value())); | 1538 Immediate(factory()->the_hole_value())); |
| 1516 } | 1539 } |
| 1517 | 1540 |
| 1518 // Restore receiver to edx as finish sequence assumes it's here. | 1541 // Restore receiver to edx as finish sequence assumes it's here. |
| 1519 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | 1542 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 1520 | 1543 |
| 1521 // Increment element's and array's sizes. | 1544 // Increment element's and array's sizes. |
| (...skipping 2309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3831 masm->isolate()->builtins()->KeyedLoadIC_Slow(); | 3854 masm->isolate()->builtins()->KeyedLoadIC_Slow(); |
| 3832 __ jmp(slow_ic, RelocInfo::CODE_TARGET); | 3855 __ jmp(slow_ic, RelocInfo::CODE_TARGET); |
| 3833 | 3856 |
| 3834 __ bind(&miss_force_generic); | 3857 __ bind(&miss_force_generic); |
| 3835 Handle<Code> miss_ic = | 3858 Handle<Code> miss_ic = |
| 3836 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); | 3859 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); |
| 3837 __ jmp(miss_ic, RelocInfo::CODE_TARGET); | 3860 __ jmp(miss_ic, RelocInfo::CODE_TARGET); |
| 3838 } | 3861 } |
| 3839 | 3862 |
| 3840 | 3863 |
| 3841 void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, | 3864 void KeyedStoreStubCompiler::GenerateStoreFastElement( |
| 3842 bool is_js_array) { | 3865 MacroAssembler* masm, |
| 3866 bool is_js_array, | |
| 3867 StoreObjectAction store_objet_action) { | |
|
Jakob Kummerow
2011/09/16 16:30:34
Here's the missing 'c' again
danno
2011/09/21 14:32:04
Done.
| |
| 3843 // ----------- S t a t e ------------- | 3868 // ----------- S t a t e ------------- |
| 3844 // -- eax : value | 3869 // -- eax : value |
| 3845 // -- ecx : key | 3870 // -- ecx : key |
| 3846 // -- edx : receiver | 3871 // -- edx : receiver |
| 3847 // -- esp[0] : return address | 3872 // -- esp[0] : return address |
| 3848 // ----------------------------------- | 3873 // ----------------------------------- |
| 3849 Label miss_force_generic; | 3874 Label miss_force_generic; |
| 3850 | 3875 |
| 3851 // This stub is meant to be tail-jumped to, the receiver must already | 3876 // This stub is meant to be tail-jumped to, the receiver must already |
| 3852 // have been verified by the caller to not be a smi. | 3877 // have been verified by the caller to not be a smi. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 3863 if (is_js_array) { | 3888 if (is_js_array) { |
| 3864 // Check that the key is within bounds. | 3889 // Check that the key is within bounds. |
| 3865 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis. | 3890 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis. |
| 3866 __ j(above_equal, &miss_force_generic); | 3891 __ j(above_equal, &miss_force_generic); |
| 3867 } else { | 3892 } else { |
| 3868 // Check that the key is within bounds. | 3893 // Check that the key is within bounds. |
| 3869 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis. | 3894 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis. |
| 3870 __ j(above_equal, &miss_force_generic); | 3895 __ j(above_equal, &miss_force_generic); |
| 3871 } | 3896 } |
| 3872 | 3897 |
| 3873 // Do the store and update the write barrier. Make sure to preserve | 3898 // Do the store and update the write barrier. Make sure to preserve |
|
Jakob Kummerow
2011/09/16 16:30:34
This comment belongs in the 'else' block below.
danno
2011/09/21 14:32:04
Done.
| |
| 3874 // the value in register eax. | 3899 // the value in register eax. |
| 3875 __ mov(edx, Operand(eax)); | 3900 if (store_objet_action == kObjectStoreForcesGeneric) { |
|
Jakob Kummerow
2011/09/16 16:30:34
And here +='c' too.
danno
2011/09/21 14:32:04
Done.
| |
| 3876 __ mov(FieldOperand(edi, ecx, times_2, FixedArray::kHeaderSize), eax); | 3901 __ JumpIfNotSmi(eax, &miss_force_generic); |
| 3877 __ RecordWrite(edi, 0, edx, ecx); | 3902 __ mov(FieldOperand(edi, ecx, times_2, FixedArray::kHeaderSize), eax); |
| 3903 } else { | |
| 3904 ASSERT(store_objet_action == kObjectStoreCausesWriteBarrier); | |
|
Jakob Kummerow
2011/09/16 16:30:34
And once more.
danno
2011/09/21 14:32:04
Done.
| |
| 3905 __ mov(edx, Operand(eax)); | |
| 3906 __ mov(FieldOperand(edi, ecx, times_2, FixedArray::kHeaderSize), eax); | |
| 3907 __ RecordWrite(edi, 0, edx, ecx); | |
| 3908 } | |
| 3878 | 3909 |
| 3879 // Done. | 3910 // Done. |
| 3880 __ ret(0); | 3911 __ ret(0); |
| 3881 | 3912 |
| 3882 // Handle store cache miss, replacing the ic with the generic stub. | 3913 // Handle store cache miss, replacing the ic with the generic stub. |
| 3883 __ bind(&miss_force_generic); | 3914 __ bind(&miss_force_generic); |
| 3884 Handle<Code> ic_force_generic = | 3915 Handle<Code> ic_force_generic = |
| 3885 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); | 3916 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); |
| 3886 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); | 3917 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); |
| 3887 } | 3918 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3979 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); | 4010 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); |
| 3980 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); | 4011 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); |
| 3981 } | 4012 } |
| 3982 | 4013 |
| 3983 | 4014 |
| 3984 #undef __ | 4015 #undef __ |
| 3985 | 4016 |
| 3986 } } // namespace v8::internal | 4017 } } // namespace v8::internal |
| 3987 | 4018 |
| 3988 #endif // V8_TARGET_ARCH_IA32 | 4019 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |