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 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 name, &miss); | 1480 name, &miss); |
1481 | 1481 |
1482 if (argc == 0) { | 1482 if (argc == 0) { |
1483 // Noop, return the length. | 1483 // Noop, return the length. |
1484 __ movq(rax, FieldOperand(rdx, JSArray::kLengthOffset)); | 1484 __ movq(rax, FieldOperand(rdx, JSArray::kLengthOffset)); |
1485 __ ret((argc + 1) * kPointerSize); | 1485 __ ret((argc + 1) * kPointerSize); |
1486 } else { | 1486 } else { |
1487 Label call_builtin; | 1487 Label call_builtin; |
1488 | 1488 |
1489 if (argc == 1) { // Otherwise fall through to call builtin. | 1489 if (argc == 1) { // Otherwise fall through to call builtin. |
1490 Label attempt_to_grow_elements, with_write_barrier; | 1490 Label attempt_to_grow_elements, with_write_barrier, check_double; |
1491 | 1491 |
1492 // Get the elements array of the object. | 1492 // Get the elements array of the object. |
1493 __ movq(rdi, FieldOperand(rdx, JSArray::kElementsOffset)); | 1493 __ movq(rdi, FieldOperand(rdx, JSArray::kElementsOffset)); |
1494 | 1494 |
1495 // Check that the elements are in fast mode and writable. | 1495 // Check that the elements are in fast mode and writable. |
1496 __ Cmp(FieldOperand(rdi, HeapObject::kMapOffset), | 1496 __ Cmp(FieldOperand(rdi, HeapObject::kMapOffset), |
1497 factory()->fixed_array_map()); | 1497 factory()->fixed_array_map()); |
1498 __ j(not_equal, &call_builtin); | 1498 __ j(not_equal, &check_double); |
1499 | 1499 |
1500 // Get the array's length into rax and calculate new length. | 1500 // Get the array's length into rax and calculate new length. |
1501 __ SmiToInteger32(rax, FieldOperand(rdx, JSArray::kLengthOffset)); | 1501 __ SmiToInteger32(rax, FieldOperand(rdx, JSArray::kLengthOffset)); |
1502 STATIC_ASSERT(FixedArray::kMaxLength < Smi::kMaxValue); | 1502 STATIC_ASSERT(FixedArray::kMaxLength < Smi::kMaxValue); |
1503 __ addl(rax, Immediate(argc)); | 1503 __ addl(rax, Immediate(argc)); |
1504 | 1504 |
1505 // Get the elements' length into rcx. | 1505 // Get the elements' length into rcx. |
1506 __ SmiToInteger32(rcx, FieldOperand(rdi, FixedArray::kLengthOffset)); | 1506 __ SmiToInteger32(rcx, FieldOperand(rdi, FixedArray::kLengthOffset)); |
1507 | 1507 |
1508 // Check if we could survive without allocation. | 1508 // Check if we could survive without allocation. |
(...skipping 10 matching lines...) Expand all Loading... |
1519 // Store the value. | 1519 // Store the value. |
1520 __ movq(FieldOperand(rdi, | 1520 __ movq(FieldOperand(rdi, |
1521 rax, | 1521 rax, |
1522 times_pointer_size, | 1522 times_pointer_size, |
1523 FixedArray::kHeaderSize - argc * kPointerSize), | 1523 FixedArray::kHeaderSize - argc * kPointerSize), |
1524 rcx); | 1524 rcx); |
1525 | 1525 |
1526 __ Integer32ToSmi(rax, rax); // Return new length as smi. | 1526 __ Integer32ToSmi(rax, rax); // Return new length as smi. |
1527 __ ret((argc + 1) * kPointerSize); | 1527 __ ret((argc + 1) * kPointerSize); |
1528 | 1528 |
| 1529 __ bind(&check_double); |
| 1530 |
| 1531 // Check that the elements are in double mode. |
| 1532 __ Cmp(FieldOperand(rdi, HeapObject::kMapOffset), |
| 1533 factory()->fixed_double_array_map()); |
| 1534 __ j(not_equal, &call_builtin); |
| 1535 |
| 1536 // Get the array's length into rax and calculate new length. |
| 1537 __ SmiToInteger32(rax, FieldOperand(rdx, JSArray::kLengthOffset)); |
| 1538 STATIC_ASSERT(FixedArray::kMaxLength < Smi::kMaxValue); |
| 1539 __ addl(rax, Immediate(argc)); |
| 1540 |
| 1541 // Get the elements' length into rcx. |
| 1542 __ SmiToInteger32(rcx, FieldOperand(rdi, FixedArray::kLengthOffset)); |
| 1543 |
| 1544 // Check if we could survive without allocation. |
| 1545 __ cmpl(rax, rcx); |
| 1546 __ j(greater, &call_builtin); |
| 1547 |
| 1548 __ movq(rcx, Operand(rsp, argc * kPointerSize)); |
| 1549 __ StoreNumberToDoubleElements( |
| 1550 rcx, rdi, rax, xmm0, &call_builtin, argc * kDoubleSize); |
| 1551 |
| 1552 // Save new length. |
| 1553 __ Integer32ToSmiField(FieldOperand(rdx, JSArray::kLengthOffset), rax); |
| 1554 __ ret((argc + 1) * kPointerSize); |
| 1555 |
1529 __ bind(&with_write_barrier); | 1556 __ bind(&with_write_barrier); |
1530 | 1557 |
1531 __ movq(rbx, FieldOperand(rdx, HeapObject::kMapOffset)); | 1558 __ movq(rbx, FieldOperand(rdx, HeapObject::kMapOffset)); |
1532 | 1559 |
1533 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { | 1560 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { |
1534 Label fast_object, not_fast_object; | 1561 Label fast_object, not_fast_object; |
1535 __ CheckFastObjectElements(rbx, ¬_fast_object, Label::kNear); | 1562 __ CheckFastObjectElements(rbx, ¬_fast_object, Label::kNear); |
1536 __ jmp(&fast_object); | 1563 __ jmp(&fast_object); |
1537 // In case of fast smi-only, convert to fast object, otherwise bail out. | 1564 // In case of fast smi-only, convert to fast object, otherwise bail out. |
1538 __ bind(¬_fast_object); | 1565 __ bind(¬_fast_object); |
1539 __ CheckFastSmiElements(rbx, &call_builtin); | 1566 __ CheckFastSmiElements(rbx, &call_builtin); |
| 1567 __ Cmp(FieldOperand(rcx, HeapObject::kMapOffset), |
| 1568 factory()->heap_number_map()); |
| 1569 __ j(equal, &call_builtin); |
1540 // rdx: receiver | 1570 // rdx: receiver |
1541 // rbx: map | 1571 // rbx: map |
1542 | 1572 |
1543 Label try_holey_map; | 1573 Label try_holey_map; |
1544 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, | 1574 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, |
1545 FAST_ELEMENTS, | 1575 FAST_ELEMENTS, |
1546 rbx, | 1576 rbx, |
1547 rdi, | 1577 rdi, |
1548 &try_holey_map); | 1578 &try_holey_map); |
1549 | 1579 |
(...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4105 __ jmp(ic_slow, RelocInfo::CODE_TARGET); | 4135 __ jmp(ic_slow, RelocInfo::CODE_TARGET); |
4106 } | 4136 } |
4107 } | 4137 } |
4108 | 4138 |
4109 | 4139 |
4110 #undef __ | 4140 #undef __ |
4111 | 4141 |
4112 } } // namespace v8::internal | 4142 } } // namespace v8::internal |
4113 | 4143 |
4114 #endif // V8_TARGET_ARCH_X64 | 4144 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |