OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 __ bind(&with_write_barrier); | 1427 __ bind(&with_write_barrier); |
1428 | 1428 |
1429 __ movq(rbx, FieldOperand(rdx, HeapObject::kMapOffset)); | 1429 __ movq(rbx, FieldOperand(rdx, HeapObject::kMapOffset)); |
1430 | 1430 |
1431 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { | 1431 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { |
1432 Label fast_object, not_fast_object; | 1432 Label fast_object, not_fast_object; |
1433 __ CheckFastObjectElements(rbx, ¬_fast_object, Label::kNear); | 1433 __ CheckFastObjectElements(rbx, ¬_fast_object, Label::kNear); |
1434 __ jmp(&fast_object); | 1434 __ jmp(&fast_object); |
1435 // In case of fast smi-only, convert to fast object, otherwise bail out. | 1435 // In case of fast smi-only, convert to fast object, otherwise bail out. |
1436 __ bind(¬_fast_object); | 1436 __ bind(¬_fast_object); |
1437 __ CheckFastSmiElements(rbx, &call_builtin); | 1437 __ CheckFastSmiOnlyElements(rbx, &call_builtin); |
1438 // rdx: receiver | 1438 // rdx: receiver |
1439 // rbx: map | 1439 // rbx: map |
1440 | 1440 __ movq(r9, rdi); // Backup rdi as it is going to be trashed. |
1441 Label try_holey_map; | 1441 __ LoadTransitionedArrayMapConditional(FAST_SMI_ONLY_ELEMENTS, |
1442 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, | |
1443 FAST_ELEMENTS, | 1442 FAST_ELEMENTS, |
1444 rbx, | 1443 rbx, |
1445 rdi, | 1444 rdi, |
1446 &try_holey_map); | |
1447 | |
1448 ElementsTransitionGenerator:: | |
1449 GenerateMapChangeElementsTransition(masm()); | |
1450 // Restore edi. | |
1451 __ movq(rdi, FieldOperand(rdx, JSArray::kElementsOffset)); | |
1452 __ jmp(&fast_object); | |
1453 | |
1454 __ bind(&try_holey_map); | |
1455 __ LoadTransitionedArrayMapConditional(FAST_HOLEY_SMI_ELEMENTS, | |
1456 FAST_HOLEY_ELEMENTS, | |
1457 rbx, | |
1458 rdi, | |
1459 &call_builtin); | 1445 &call_builtin); |
1460 ElementsTransitionGenerator:: | 1446 ElementsTransitionGenerator::GenerateSmiOnlyToObject(masm()); |
1461 GenerateMapChangeElementsTransition(masm()); | 1447 __ movq(rdi, r9); |
1462 __ movq(rdi, FieldOperand(rdx, JSArray::kElementsOffset)); | |
1463 __ bind(&fast_object); | 1448 __ bind(&fast_object); |
1464 } else { | 1449 } else { |
1465 __ CheckFastObjectElements(rbx, &call_builtin); | 1450 __ CheckFastObjectElements(rbx, &call_builtin); |
1466 } | 1451 } |
1467 | 1452 |
1468 // Save new length. | 1453 // Save new length. |
1469 __ Integer32ToSmiField(FieldOperand(rdx, JSArray::kLengthOffset), rax); | 1454 __ Integer32ToSmiField(FieldOperand(rdx, JSArray::kLengthOffset), rax); |
1470 | 1455 |
1471 // Store the value. | 1456 // Store the value. |
1472 __ lea(rdx, FieldOperand(rdi, | 1457 __ lea(rdx, FieldOperand(rdi, |
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3377 // Need to perform int-to-float conversion. | 3362 // Need to perform int-to-float conversion. |
3378 __ cvtlsi2ss(xmm0, rdx); | 3363 __ cvtlsi2ss(xmm0, rdx); |
3379 __ movss(Operand(rbx, rdi, times_4, 0), xmm0); | 3364 __ movss(Operand(rbx, rdi, times_4, 0), xmm0); |
3380 break; | 3365 break; |
3381 case EXTERNAL_DOUBLE_ELEMENTS: | 3366 case EXTERNAL_DOUBLE_ELEMENTS: |
3382 // Need to perform int-to-float conversion. | 3367 // Need to perform int-to-float conversion. |
3383 __ cvtlsi2sd(xmm0, rdx); | 3368 __ cvtlsi2sd(xmm0, rdx); |
3384 __ movsd(Operand(rbx, rdi, times_8, 0), xmm0); | 3369 __ movsd(Operand(rbx, rdi, times_8, 0), xmm0); |
3385 break; | 3370 break; |
3386 case FAST_ELEMENTS: | 3371 case FAST_ELEMENTS: |
3387 case FAST_SMI_ELEMENTS: | 3372 case FAST_SMI_ONLY_ELEMENTS: |
3388 case FAST_DOUBLE_ELEMENTS: | 3373 case FAST_DOUBLE_ELEMENTS: |
3389 case FAST_HOLEY_ELEMENTS: | |
3390 case FAST_HOLEY_SMI_ELEMENTS: | |
3391 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
3392 case DICTIONARY_ELEMENTS: | 3374 case DICTIONARY_ELEMENTS: |
3393 case NON_STRICT_ARGUMENTS_ELEMENTS: | 3375 case NON_STRICT_ARGUMENTS_ELEMENTS: |
3394 UNREACHABLE(); | 3376 UNREACHABLE(); |
3395 break; | 3377 break; |
3396 } | 3378 } |
3397 __ ret(0); | 3379 __ ret(0); |
3398 | 3380 |
3399 // TODO(danno): handle heap number -> pixel array conversion | 3381 // TODO(danno): handle heap number -> pixel array conversion |
3400 if (elements_kind != EXTERNAL_PIXEL_ELEMENTS) { | 3382 if (elements_kind != EXTERNAL_PIXEL_ELEMENTS) { |
3401 __ bind(&check_heap_number); | 3383 __ bind(&check_heap_number); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3446 __ movw(Operand(rbx, rdi, times_2, 0), r8); | 3428 __ movw(Operand(rbx, rdi, times_2, 0), r8); |
3447 break; | 3429 break; |
3448 case EXTERNAL_INT_ELEMENTS: | 3430 case EXTERNAL_INT_ELEMENTS: |
3449 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3431 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
3450 __ movl(Operand(rbx, rdi, times_4, 0), r8); | 3432 __ movl(Operand(rbx, rdi, times_4, 0), r8); |
3451 break; | 3433 break; |
3452 case EXTERNAL_PIXEL_ELEMENTS: | 3434 case EXTERNAL_PIXEL_ELEMENTS: |
3453 case EXTERNAL_FLOAT_ELEMENTS: | 3435 case EXTERNAL_FLOAT_ELEMENTS: |
3454 case EXTERNAL_DOUBLE_ELEMENTS: | 3436 case EXTERNAL_DOUBLE_ELEMENTS: |
3455 case FAST_ELEMENTS: | 3437 case FAST_ELEMENTS: |
3456 case FAST_SMI_ELEMENTS: | 3438 case FAST_SMI_ONLY_ELEMENTS: |
3457 case FAST_DOUBLE_ELEMENTS: | 3439 case FAST_DOUBLE_ELEMENTS: |
3458 case FAST_HOLEY_ELEMENTS: | |
3459 case FAST_HOLEY_SMI_ELEMENTS: | |
3460 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
3461 case DICTIONARY_ELEMENTS: | 3440 case DICTIONARY_ELEMENTS: |
3462 case NON_STRICT_ARGUMENTS_ELEMENTS: | 3441 case NON_STRICT_ARGUMENTS_ELEMENTS: |
3463 UNREACHABLE(); | 3442 UNREACHABLE(); |
3464 break; | 3443 break; |
3465 } | 3444 } |
3466 __ ret(0); | 3445 __ ret(0); |
3467 } | 3446 } |
3468 } | 3447 } |
3469 | 3448 |
3470 // Slow case: call runtime. | 3449 // Slow case: call runtime. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3601 // ----------------------------------- | 3580 // ----------------------------------- |
3602 Label miss_force_generic, transition_elements_kind, finish_store, grow; | 3581 Label miss_force_generic, transition_elements_kind, finish_store, grow; |
3603 Label check_capacity, slow; | 3582 Label check_capacity, slow; |
3604 | 3583 |
3605 // This stub is meant to be tail-jumped to, the receiver must already | 3584 // This stub is meant to be tail-jumped to, the receiver must already |
3606 // have been verified by the caller to not be a smi. | 3585 // have been verified by the caller to not be a smi. |
3607 | 3586 |
3608 // Check that the key is a smi or a heap number convertible to a smi. | 3587 // Check that the key is a smi or a heap number convertible to a smi. |
3609 GenerateSmiKeyCheck(masm, rcx, rbx, xmm0, xmm1, &miss_force_generic); | 3588 GenerateSmiKeyCheck(masm, rcx, rbx, xmm0, xmm1, &miss_force_generic); |
3610 | 3589 |
3611 if (IsFastSmiElementsKind(elements_kind)) { | 3590 if (elements_kind == FAST_SMI_ONLY_ELEMENTS) { |
3612 __ JumpIfNotSmi(rax, &transition_elements_kind); | 3591 __ JumpIfNotSmi(rax, &transition_elements_kind); |
3613 } | 3592 } |
3614 | 3593 |
3615 // Get the elements array and make sure it is a fast element array, not 'cow'. | 3594 // Get the elements array and make sure it is a fast element array, not 'cow'. |
3616 __ movq(rdi, FieldOperand(rdx, JSObject::kElementsOffset)); | 3595 __ movq(rdi, FieldOperand(rdx, JSObject::kElementsOffset)); |
3617 // Check that the key is within bounds. | 3596 // Check that the key is within bounds. |
3618 if (is_js_array) { | 3597 if (is_js_array) { |
3619 __ SmiCompare(rcx, FieldOperand(rdx, JSArray::kLengthOffset)); | 3598 __ SmiCompare(rcx, FieldOperand(rdx, JSArray::kLengthOffset)); |
3620 if (grow_mode == ALLOW_JSARRAY_GROWTH) { | 3599 if (grow_mode == ALLOW_JSARRAY_GROWTH) { |
3621 __ j(above_equal, &grow); | 3600 __ j(above_equal, &grow); |
3622 } else { | 3601 } else { |
3623 __ j(above_equal, &miss_force_generic); | 3602 __ j(above_equal, &miss_force_generic); |
3624 } | 3603 } |
3625 } else { | 3604 } else { |
3626 __ SmiCompare(rcx, FieldOperand(rdi, FixedArray::kLengthOffset)); | 3605 __ SmiCompare(rcx, FieldOperand(rdi, FixedArray::kLengthOffset)); |
3627 __ j(above_equal, &miss_force_generic); | 3606 __ j(above_equal, &miss_force_generic); |
3628 } | 3607 } |
3629 | 3608 |
3630 __ CompareRoot(FieldOperand(rdi, HeapObject::kMapOffset), | 3609 __ CompareRoot(FieldOperand(rdi, HeapObject::kMapOffset), |
3631 Heap::kFixedArrayMapRootIndex); | 3610 Heap::kFixedArrayMapRootIndex); |
3632 __ j(not_equal, &miss_force_generic); | 3611 __ j(not_equal, &miss_force_generic); |
3633 | 3612 |
3634 __ bind(&finish_store); | 3613 __ bind(&finish_store); |
3635 if (IsFastSmiElementsKind(elements_kind)) { | 3614 if (elements_kind == FAST_SMI_ONLY_ELEMENTS) { |
3636 __ SmiToInteger32(rcx, rcx); | 3615 __ SmiToInteger32(rcx, rcx); |
3637 __ movq(FieldOperand(rdi, rcx, times_pointer_size, FixedArray::kHeaderSize), | 3616 __ movq(FieldOperand(rdi, rcx, times_pointer_size, FixedArray::kHeaderSize), |
3638 rax); | 3617 rax); |
3639 } else { | 3618 } else { |
3640 // Do the store and update the write barrier. | 3619 // Do the store and update the write barrier. |
3641 ASSERT(IsFastObjectElementsKind(elements_kind)); | 3620 ASSERT(elements_kind == FAST_ELEMENTS); |
3642 __ SmiToInteger32(rcx, rcx); | 3621 __ SmiToInteger32(rcx, rcx); |
3643 __ lea(rcx, | 3622 __ lea(rcx, |
3644 FieldOperand(rdi, rcx, times_pointer_size, FixedArray::kHeaderSize)); | 3623 FieldOperand(rdi, rcx, times_pointer_size, FixedArray::kHeaderSize)); |
3645 __ movq(Operand(rcx, 0), rax); | 3624 __ movq(Operand(rcx, 0), rax); |
3646 // Make sure to preserve the value in register rax. | 3625 // Make sure to preserve the value in register rax. |
3647 __ movq(rbx, rax); | 3626 __ movq(rbx, rax); |
3648 __ RecordWrite(rdi, rcx, rbx, kDontSaveFPRegs); | 3627 __ RecordWrite(rdi, rcx, rbx, kDontSaveFPRegs); |
3649 } | 3628 } |
3650 | 3629 |
3651 // Done. | 3630 // Done. |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3852 __ jmp(ic_slow, RelocInfo::CODE_TARGET); | 3831 __ jmp(ic_slow, RelocInfo::CODE_TARGET); |
3853 } | 3832 } |
3854 } | 3833 } |
3855 | 3834 |
3856 | 3835 |
3857 #undef __ | 3836 #undef __ |
3858 | 3837 |
3859 } } // namespace v8::internal | 3838 } } // namespace v8::internal |
3860 | 3839 |
3861 #endif // V8_TARGET_ARCH_X64 | 3840 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |