| 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 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 | 1442 |
| 1443 // Get the elements array of the object. | 1443 // Get the elements array of the object. |
| 1444 __ movq(rbx, FieldOperand(rdx, JSArray::kElementsOffset)); | 1444 __ movq(rbx, FieldOperand(rdx, JSArray::kElementsOffset)); |
| 1445 | 1445 |
| 1446 // Check that the elements are in fast mode and writable. | 1446 // Check that the elements are in fast mode and writable. |
| 1447 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset), | 1447 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset), |
| 1448 Factory::fixed_array_map()); | 1448 Factory::fixed_array_map()); |
| 1449 __ j(not_equal, &call_builtin); | 1449 __ j(not_equal, &call_builtin); |
| 1450 | 1450 |
| 1451 if (argc == 1) { // Otherwise fall through to call builtin. | 1451 if (argc == 1) { // Otherwise fall through to call builtin. |
| 1452 Label exit, attempt_to_grow_elements; | 1452 Label exit, attempt_to_grow_elements, with_write_barrier; |
| 1453 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | |
| 1454 Label with_write_barrier; | |
| 1455 #endif | |
| 1456 | 1453 |
| 1457 // Get the array's length into rax and calculate new length. | 1454 // Get the array's length into rax and calculate new length. |
| 1458 __ SmiToInteger32(rax, FieldOperand(rdx, JSArray::kLengthOffset)); | 1455 __ SmiToInteger32(rax, FieldOperand(rdx, JSArray::kLengthOffset)); |
| 1459 STATIC_ASSERT(FixedArray::kMaxLength < Smi::kMaxValue); | 1456 STATIC_ASSERT(FixedArray::kMaxLength < Smi::kMaxValue); |
| 1460 __ addl(rax, Immediate(argc)); | 1457 __ addl(rax, Immediate(argc)); |
| 1461 | 1458 |
| 1462 // Get the element's length into rcx. | 1459 // Get the element's length into rcx. |
| 1463 __ SmiToInteger32(rcx, FieldOperand(rbx, FixedArray::kLengthOffset)); | 1460 __ SmiToInteger32(rcx, FieldOperand(rbx, FixedArray::kLengthOffset)); |
| 1464 | 1461 |
| 1465 // Check if we could survive without allocation. | 1462 // Check if we could survive without allocation. |
| 1466 __ cmpl(rax, rcx); | 1463 __ cmpl(rax, rcx); |
| 1467 __ j(greater, &attempt_to_grow_elements); | 1464 __ j(greater, &attempt_to_grow_elements); |
| 1468 | 1465 |
| 1469 // Save new length. | 1466 // Save new length. |
| 1470 __ Integer32ToSmiField(FieldOperand(rdx, JSArray::kLengthOffset), rax); | 1467 __ Integer32ToSmiField(FieldOperand(rdx, JSArray::kLengthOffset), rax); |
| 1471 | 1468 |
| 1472 // Push the element. | 1469 // Push the element. |
| 1473 __ movq(rcx, Operand(rsp, argc * kPointerSize)); | 1470 __ movq(rcx, Operand(rsp, argc * kPointerSize)); |
| 1474 __ lea(rdx, FieldOperand(rbx, | 1471 __ lea(rdx, FieldOperand(rbx, |
| 1475 rax, times_pointer_size, | 1472 rax, times_pointer_size, |
| 1476 FixedArray::kHeaderSize - argc * kPointerSize)); | 1473 FixedArray::kHeaderSize - argc * kPointerSize)); |
| 1477 __ movq(Operand(rdx, 0), rcx); | 1474 __ movq(Operand(rdx, 0), rcx); |
| 1478 | 1475 |
| 1479 // Check if value is a smi. | 1476 // Check if value is a smi. |
| 1480 __ Integer32ToSmi(rax, rax); // Return new length as smi. | 1477 __ Integer32ToSmi(rax, rax); // Return new length as smi. |
| 1481 | 1478 |
| 1482 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | |
| 1483 __ JumpIfNotSmi(rcx, &with_write_barrier); | 1479 __ JumpIfNotSmi(rcx, &with_write_barrier); |
| 1484 #endif | |
| 1485 | 1480 |
| 1486 __ bind(&exit); | 1481 __ bind(&exit); |
| 1487 __ ret((argc + 1) * kPointerSize); | 1482 __ ret((argc + 1) * kPointerSize); |
| 1488 | 1483 |
| 1489 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER | |
| 1490 __ bind(&with_write_barrier); | 1484 __ bind(&with_write_barrier); |
| 1491 | 1485 |
| 1492 __ InNewSpace(rbx, rcx, equal, &exit); | 1486 __ InNewSpace(rbx, rcx, equal, &exit); |
| 1493 | 1487 |
| 1494 __ RecordWriteHelper(rbx, rdx, rcx); | 1488 __ RecordWriteHelper(rbx, rdx, rcx, kDontSaveFPRegs); |
| 1495 | 1489 |
| 1496 __ ret((argc + 1) * kPointerSize); | 1490 __ ret((argc + 1) * kPointerSize); |
| 1497 #endif | |
| 1498 | 1491 |
| 1499 __ bind(&attempt_to_grow_elements); | 1492 __ bind(&attempt_to_grow_elements); |
| 1500 if (!FLAG_inline_new) { | 1493 if (!FLAG_inline_new) { |
| 1501 __ jmp(&call_builtin); | 1494 __ jmp(&call_builtin); |
| 1502 } | 1495 } |
| 1503 | 1496 |
| 1504 ExternalReference new_space_allocation_top = | 1497 ExternalReference new_space_allocation_top = |
| 1505 ExternalReference::new_space_allocation_top_address(); | 1498 ExternalReference::new_space_allocation_top_address(); |
| 1506 ExternalReference new_space_allocation_limit = | 1499 ExternalReference new_space_allocation_limit = |
| 1507 ExternalReference::new_space_allocation_limit_address(); | 1500 ExternalReference::new_space_allocation_limit_address(); |
| (...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3126 // Return the generated code. | 3119 // Return the generated code. |
| 3127 return GetCode(); | 3120 return GetCode(); |
| 3128 } | 3121 } |
| 3129 | 3122 |
| 3130 | 3123 |
| 3131 #undef __ | 3124 #undef __ |
| 3132 | 3125 |
| 3133 } } // namespace v8::internal | 3126 } } // namespace v8::internal |
| 3134 | 3127 |
| 3135 #endif // V8_TARGET_ARCH_X64 | 3128 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |