| 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 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1447 | 1447 |
| 1448 // Get the elements array of the object. | 1448 // Get the elements array of the object. |
| 1449 __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset)); | 1449 __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset)); |
| 1450 | 1450 |
| 1451 // Check that the elements are in fast mode and writable. | 1451 // Check that the elements are in fast mode and writable. |
| 1452 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), | 1452 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), |
| 1453 Immediate(factory()->fixed_array_map())); | 1453 Immediate(factory()->fixed_array_map())); |
| 1454 __ j(not_equal, &call_builtin); | 1454 __ j(not_equal, &call_builtin); |
| 1455 | 1455 |
| 1456 if (argc == 1) { // Otherwise fall through to call builtin. | 1456 if (argc == 1) { // Otherwise fall through to call builtin. |
| 1457 Label exit, attempt_to_grow_elements, with_write_barrier; | 1457 Label attempt_to_grow_elements, with_write_barrier; |
| 1458 | 1458 |
| 1459 // Get the array's length into eax and calculate new length. | 1459 // Get the array's length into eax and calculate new length. |
| 1460 __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset)); | 1460 __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset)); |
| 1461 STATIC_ASSERT(kSmiTagSize == 1); | 1461 STATIC_ASSERT(kSmiTagSize == 1); |
| 1462 STATIC_ASSERT(kSmiTag == 0); | 1462 STATIC_ASSERT(kSmiTag == 0); |
| 1463 __ add(Operand(eax), Immediate(Smi::FromInt(argc))); | 1463 __ add(Operand(eax), Immediate(Smi::FromInt(argc))); |
| 1464 | 1464 |
| 1465 // Get the element's length into ecx. | 1465 // Get the element's length into ecx. |
| 1466 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); | 1466 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); |
| 1467 | 1467 |
| 1468 // Check if we could survive without allocation. | 1468 // Check if we could survive without allocation. |
| 1469 __ cmp(eax, Operand(ecx)); | 1469 __ cmp(eax, Operand(ecx)); |
| 1470 __ j(greater, &attempt_to_grow_elements); | 1470 __ j(greater, &attempt_to_grow_elements); |
| 1471 | 1471 |
| 1472 // Check if value is a smi. |
| 1473 __ mov(ecx, Operand(esp, argc * kPointerSize)); |
| 1474 __ JumpIfNotSmi(ecx, &with_write_barrier); |
| 1475 |
| 1472 // Save new length. | 1476 // Save new length. |
| 1473 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); | 1477 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); |
| 1474 | 1478 |
| 1475 // Push the element. | 1479 // Push the element. |
| 1476 __ lea(edx, FieldOperand(ebx, | 1480 __ lea(edx, FieldOperand(ebx, |
| 1477 eax, times_half_pointer_size, | 1481 eax, times_half_pointer_size, |
| 1478 FixedArray::kHeaderSize - argc * kPointerSize)); | 1482 FixedArray::kHeaderSize - argc * kPointerSize)); |
| 1479 __ mov(ecx, Operand(esp, argc * kPointerSize)); | |
| 1480 __ mov(Operand(edx, 0), ecx); | 1483 __ mov(Operand(edx, 0), ecx); |
| 1481 | 1484 |
| 1482 // Check if value is a smi. | |
| 1483 __ JumpIfNotSmi(ecx, &with_write_barrier); | |
| 1484 | |
| 1485 __ bind(&exit); | |
| 1486 __ ret((argc + 1) * kPointerSize); | 1485 __ ret((argc + 1) * kPointerSize); |
| 1487 | 1486 |
| 1488 __ bind(&with_write_barrier); | 1487 __ bind(&with_write_barrier); |
| 1489 | 1488 |
| 1489 if (FLAG_smi_only_arrays) { |
| 1490 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); |
| 1491 __ CheckFastObjectElements(edi, &call_builtin); |
| 1492 } |
| 1493 |
| 1494 // Save new length. |
| 1495 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); |
| 1496 |
| 1497 // Push the element. |
| 1498 __ lea(edx, FieldOperand(ebx, |
| 1499 eax, times_half_pointer_size, |
| 1500 FixedArray::kHeaderSize - argc * kPointerSize)); |
| 1501 __ mov(Operand(edx, 0), ecx); |
| 1502 |
| 1490 __ RecordWrite( | 1503 __ RecordWrite( |
| 1491 ebx, edx, ecx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 1504 ebx, edx, ecx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
| 1492 | 1505 |
| 1493 __ ret((argc + 1) * kPointerSize); | 1506 __ ret((argc + 1) * kPointerSize); |
| 1494 | 1507 |
| 1495 __ bind(&attempt_to_grow_elements); | 1508 __ bind(&attempt_to_grow_elements); |
| 1496 if (!FLAG_inline_new) { | 1509 if (!FLAG_inline_new) { |
| 1497 __ jmp(&call_builtin); | 1510 __ jmp(&call_builtin); |
| 1498 } | 1511 } |
| 1499 | 1512 |
| 1513 __ mov(edi, Operand(esp, argc * kPointerSize)); |
| 1514 if (FLAG_smi_only_arrays) { |
| 1515 // Growing elements that are SMI-only requires special handling in case |
| 1516 // the new element is non-Smi. For now, delegate to the builtin. |
| 1517 Label no_fast_elements_check; |
| 1518 __ JumpIfSmi(edi, &no_fast_elements_check); |
| 1519 __ mov(esi, FieldOperand(edx, HeapObject::kMapOffset)); |
| 1520 __ CheckFastObjectElements(esi, &call_builtin, Label::kFar); |
| 1521 __ bind(&no_fast_elements_check); |
| 1522 } |
| 1523 |
| 1500 // We could be lucky and the elements array could be at the top of | 1524 // We could be lucky and the elements array could be at the top of |
| 1501 // new-space. In this case we can just grow it in place by moving the | 1525 // new-space. In this case we can just grow it in place by moving the |
| 1502 // allocation pointer up. | 1526 // allocation pointer up. |
| 1503 | 1527 |
| 1504 ExternalReference new_space_allocation_top = | 1528 ExternalReference new_space_allocation_top = |
| 1505 ExternalReference::new_space_allocation_top_address(isolate()); | 1529 ExternalReference::new_space_allocation_top_address(isolate()); |
| 1506 ExternalReference new_space_allocation_limit = | 1530 ExternalReference new_space_allocation_limit = |
| 1507 ExternalReference::new_space_allocation_limit_address(isolate()); | 1531 ExternalReference::new_space_allocation_limit_address(isolate()); |
| 1508 | 1532 |
| 1509 const int kAllocationDelta = 4; | 1533 const int kAllocationDelta = 4; |
| 1510 // Load top. | 1534 // Load top. |
| 1511 __ mov(ecx, Operand::StaticVariable(new_space_allocation_top)); | 1535 __ mov(ecx, Operand::StaticVariable(new_space_allocation_top)); |
| 1512 | 1536 |
| 1513 // Check if it's the end of elements. | 1537 // Check if it's the end of elements. |
| 1514 __ lea(edx, FieldOperand(ebx, | 1538 __ lea(edx, FieldOperand(ebx, |
| 1515 eax, times_half_pointer_size, | 1539 eax, times_half_pointer_size, |
| 1516 FixedArray::kHeaderSize - argc * kPointerSize)); | 1540 FixedArray::kHeaderSize - argc * kPointerSize)); |
| 1517 __ cmp(edx, Operand(ecx)); | 1541 __ cmp(edx, Operand(ecx)); |
| 1518 __ j(not_equal, &call_builtin); | 1542 __ j(not_equal, &call_builtin); |
| 1519 __ add(Operand(ecx), Immediate(kAllocationDelta * kPointerSize)); | 1543 __ add(Operand(ecx), Immediate(kAllocationDelta * kPointerSize)); |
| 1520 __ cmp(ecx, Operand::StaticVariable(new_space_allocation_limit)); | 1544 __ cmp(ecx, Operand::StaticVariable(new_space_allocation_limit)); |
| 1521 __ j(above, &call_builtin); | 1545 __ j(above, &call_builtin); |
| 1522 | 1546 |
| 1523 // We fit and could grow elements. | 1547 // We fit and could grow elements. |
| 1524 __ mov(Operand::StaticVariable(new_space_allocation_top), ecx); | 1548 __ mov(Operand::StaticVariable(new_space_allocation_top), ecx); |
| 1525 __ mov(ecx, Operand(esp, argc * kPointerSize)); | |
| 1526 | 1549 |
| 1527 // Push the argument... | 1550 // Push the argument... |
| 1528 __ mov(Operand(edx, 0), ecx); | 1551 __ mov(Operand(edx, 0), edi); |
| 1529 // ... and fill the rest with holes. | 1552 // ... and fill the rest with holes. |
| 1530 for (int i = 1; i < kAllocationDelta; i++) { | 1553 for (int i = 1; i < kAllocationDelta; i++) { |
| 1531 __ mov(Operand(edx, i * kPointerSize), | 1554 __ mov(Operand(edx, i * kPointerSize), |
| 1532 Immediate(factory()->the_hole_value())); | 1555 Immediate(factory()->the_hole_value())); |
| 1533 } | 1556 } |
| 1534 | 1557 |
| 1535 // We know the elements array is in new space so we don't need the | 1558 // We know the elements array is in new space so we don't need the |
| 1536 // remembered set, but we just pushed a value onto it so we may have to | 1559 // remembered set, but we just pushed a value onto it so we may have to |
| 1537 // tell the incremental marker to rescan the object that we just grew. We | 1560 // tell the incremental marker to rescan the object that we just grew. We |
| 1538 // don't need to worry about the holes because they are in old space and | 1561 // don't need to worry about the holes because they are in old space and |
| 1539 // already marked black. | 1562 // already marked black. |
| 1540 __ RecordWrite(ebx, edx, ecx, kDontSaveFPRegs, OMIT_REMEMBERED_SET); | 1563 __ RecordWrite(ebx, edx, edi, kDontSaveFPRegs, OMIT_REMEMBERED_SET); |
| 1541 | 1564 |
| 1542 // Restore receiver to edx as finish sequence assumes it's here. | 1565 // Restore receiver to edx as finish sequence assumes it's here. |
| 1543 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | 1566 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 1544 | 1567 |
| 1545 // Increment element's and array's sizes. | 1568 // Increment element's and array's sizes. |
| 1546 __ add(FieldOperand(ebx, FixedArray::kLengthOffset), | 1569 __ add(FieldOperand(ebx, FixedArray::kLengthOffset), |
| 1547 Immediate(Smi::FromInt(kAllocationDelta))); | 1570 Immediate(Smi::FromInt(kAllocationDelta))); |
| 1548 | 1571 |
| 1549 // NOTE: This only happen in new-space, where we don't | 1572 // NOTE: This only happen in new-space, where we don't |
| 1550 // care about the black-byte-count on pages. Otherwise we should | 1573 // care about the black-byte-count on pages. Otherwise we should |
| (...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3870 masm->isolate()->builtins()->KeyedLoadIC_Slow(); | 3893 masm->isolate()->builtins()->KeyedLoadIC_Slow(); |
| 3871 __ jmp(slow_ic, RelocInfo::CODE_TARGET); | 3894 __ jmp(slow_ic, RelocInfo::CODE_TARGET); |
| 3872 | 3895 |
| 3873 __ bind(&miss_force_generic); | 3896 __ bind(&miss_force_generic); |
| 3874 Handle<Code> miss_ic = | 3897 Handle<Code> miss_ic = |
| 3875 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); | 3898 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); |
| 3876 __ jmp(miss_ic, RelocInfo::CODE_TARGET); | 3899 __ jmp(miss_ic, RelocInfo::CODE_TARGET); |
| 3877 } | 3900 } |
| 3878 | 3901 |
| 3879 | 3902 |
| 3880 void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, | 3903 void KeyedStoreStubCompiler::GenerateStoreFastElement( |
| 3881 bool is_js_array) { | 3904 MacroAssembler* masm, |
| 3905 bool is_js_array, |
| 3906 ElementsKind elements_kind) { |
| 3882 // ----------- S t a t e ------------- | 3907 // ----------- S t a t e ------------- |
| 3883 // -- eax : value | 3908 // -- eax : value |
| 3884 // -- ecx : key | 3909 // -- ecx : key |
| 3885 // -- edx : receiver | 3910 // -- edx : receiver |
| 3886 // -- esp[0] : return address | 3911 // -- esp[0] : return address |
| 3887 // ----------------------------------- | 3912 // ----------------------------------- |
| 3888 Label miss_force_generic; | 3913 Label miss_force_generic; |
| 3889 | 3914 |
| 3890 // This stub is meant to be tail-jumped to, the receiver must already | 3915 // This stub is meant to be tail-jumped to, the receiver must already |
| 3891 // have been verified by the caller to not be a smi. | 3916 // have been verified by the caller to not be a smi. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3902 if (is_js_array) { | 3927 if (is_js_array) { |
| 3903 // Check that the key is within bounds. | 3928 // Check that the key is within bounds. |
| 3904 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis. | 3929 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis. |
| 3905 __ j(above_equal, &miss_force_generic); | 3930 __ j(above_equal, &miss_force_generic); |
| 3906 } else { | 3931 } else { |
| 3907 // Check that the key is within bounds. | 3932 // Check that the key is within bounds. |
| 3908 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis. | 3933 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis. |
| 3909 __ j(above_equal, &miss_force_generic); | 3934 __ j(above_equal, &miss_force_generic); |
| 3910 } | 3935 } |
| 3911 | 3936 |
| 3912 // Do the store and update the write barrier. | 3937 if (elements_kind == FAST_SMI_ONLY_ELEMENTS) { |
| 3913 __ lea(ecx, FieldOperand(edi, ecx, times_2, FixedArray::kHeaderSize)); | 3938 __ JumpIfNotSmi(eax, &miss_force_generic); |
| 3914 __ mov(Operand(ecx, 0), eax); | 3939 // ecx is a smi, don't use times_half_pointer_size istead of |
| 3915 // Make sure to preserve the value in register eax. | 3940 // times_pointer_size |
| 3916 __ mov(edx, Operand(eax)); | 3941 __ mov(FieldOperand(edi, |
| 3917 __ RecordWrite(edi, ecx, edx, kDontSaveFPRegs); | 3942 ecx, |
| 3943 times_half_pointer_size, |
| 3944 FixedArray::kHeaderSize), eax); |
| 3945 } else { |
| 3946 ASSERT(elements_kind == FAST_ELEMENTS); |
| 3947 // Do the store and update the write barrier. |
| 3948 // ecx is a smi, don't use times_half_pointer_size istead of |
| 3949 // times_pointer_size |
| 3950 __ lea(ecx, FieldOperand(edi, |
| 3951 ecx, |
| 3952 times_half_pointer_size, |
| 3953 FixedArray::kHeaderSize)); |
| 3954 __ mov(Operand(ecx, 0), eax); |
| 3955 // Make sure to preserve the value in register eax. |
| 3956 __ mov(edx, Operand(eax)); |
| 3957 __ RecordWrite(edi, ecx, edx, kDontSaveFPRegs); |
| 3958 } |
| 3918 | 3959 |
| 3919 // Done. | 3960 // Done. |
| 3920 __ ret(0); | 3961 __ ret(0); |
| 3921 | 3962 |
| 3922 // Handle store cache miss, replacing the ic with the generic stub. | 3963 // Handle store cache miss, replacing the ic with the generic stub. |
| 3923 __ bind(&miss_force_generic); | 3964 __ bind(&miss_force_generic); |
| 3924 Handle<Code> ic_force_generic = | 3965 Handle<Code> ic_force_generic = |
| 3925 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); | 3966 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); |
| 3926 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); | 3967 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); |
| 3927 } | 3968 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4019 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); | 4060 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); |
| 4020 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); | 4061 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); |
| 4021 } | 4062 } |
| 4022 | 4063 |
| 4023 | 4064 |
| 4024 #undef __ | 4065 #undef __ |
| 4025 | 4066 |
| 4026 } } // namespace v8::internal | 4067 } } // namespace v8::internal |
| 4027 | 4068 |
| 4028 #endif // V8_TARGET_ARCH_IA32 | 4069 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |