| 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 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 } else { | 1106 } else { |
| 1107 // Get the elements array of the object. | 1107 // Get the elements array of the object. |
| 1108 __ movq(rbx, FieldOperand(rdx, JSArray::kElementsOffset)); | 1108 __ movq(rbx, FieldOperand(rdx, JSArray::kElementsOffset)); |
| 1109 | 1109 |
| 1110 // Check that the elements are in fast mode (not dictionary). | 1110 // Check that the elements are in fast mode (not dictionary). |
| 1111 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset), | 1111 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset), |
| 1112 Factory::fixed_array_map()); | 1112 Factory::fixed_array_map()); |
| 1113 __ j(not_equal, &miss); | 1113 __ j(not_equal, &miss); |
| 1114 | 1114 |
| 1115 if (argc == 1) { // Otherwise fall through to call builtin. | 1115 if (argc == 1) { // Otherwise fall through to call builtin. |
| 1116 Label call_builtin, exit, with_rset_update, attempt_to_grow_elements; | 1116 Label call_builtin, exit, with_write_barrier, attempt_to_grow_elements; |
| 1117 | 1117 |
| 1118 // Get the array's length into rax and calculate new length. | 1118 // Get the array's length into rax and calculate new length. |
| 1119 __ movq(rax, FieldOperand(rdx, JSArray::kLengthOffset)); | 1119 __ movq(rax, FieldOperand(rdx, JSArray::kLengthOffset)); |
| 1120 STATIC_ASSERT(FixedArray::kMaxLength < Smi::kMaxValue); | 1120 STATIC_ASSERT(FixedArray::kMaxLength < Smi::kMaxValue); |
| 1121 __ SmiAddConstant(rax, rax, Smi::FromInt(argc)); | 1121 __ SmiAddConstant(rax, rax, Smi::FromInt(argc)); |
| 1122 | 1122 |
| 1123 // Get the element's length into rcx. | 1123 // Get the element's length into rcx. |
| 1124 __ movl(rcx, FieldOperand(rbx, FixedArray::kLengthOffset)); | 1124 __ movq(rcx, FieldOperand(rbx, FixedArray::kLengthOffset)); |
| 1125 __ Integer32ToSmi(rcx, rcx); | |
| 1126 | 1125 |
| 1127 // Check if we could survive without allocation. | 1126 // Check if we could survive without allocation. |
| 1128 __ SmiCompare(rax, rcx); | 1127 __ SmiCompare(rax, rcx); |
| 1129 __ j(greater, &attempt_to_grow_elements); | 1128 __ j(greater, &attempt_to_grow_elements); |
| 1130 | 1129 |
| 1131 // Save new length. | 1130 // Save new length. |
| 1132 __ movq(FieldOperand(rdx, JSArray::kLengthOffset), rax); | 1131 __ movq(FieldOperand(rdx, JSArray::kLengthOffset), rax); |
| 1133 | 1132 |
| 1134 // Push the element. | 1133 // Push the element. |
| 1135 __ movq(rcx, Operand(rsp, argc * kPointerSize)); | 1134 __ movq(rcx, Operand(rsp, argc * kPointerSize)); |
| 1136 SmiIndex index = | 1135 SmiIndex index = |
| 1137 masm()->SmiToIndex(kScratchRegister, rax, times_pointer_size); | 1136 masm()->SmiToIndex(kScratchRegister, rax, times_pointer_size); |
| 1138 __ lea(rdx, FieldOperand(rbx, | 1137 __ lea(rdx, FieldOperand(rbx, |
| 1139 index.reg, index.scale, | 1138 index.reg, index.scale, |
| 1140 FixedArray::kHeaderSize - argc * kPointerSize)); | 1139 FixedArray::kHeaderSize - argc * kPointerSize)); |
| 1141 __ movq(Operand(rdx, 0), rcx); | 1140 __ movq(Operand(rdx, 0), rcx); |
| 1142 | 1141 |
| 1143 // Check if value is a smi. | 1142 // Check if value is a smi. |
| 1144 __ JumpIfNotSmi(rcx, &with_rset_update); | 1143 __ JumpIfNotSmi(rcx, &with_write_barrier); |
| 1145 | 1144 |
| 1146 __ bind(&exit); | 1145 __ bind(&exit); |
| 1147 __ ret((argc + 1) * kPointerSize); | 1146 __ ret((argc + 1) * kPointerSize); |
| 1148 | 1147 |
| 1149 __ bind(&with_rset_update); | 1148 __ bind(&with_write_barrier); |
| 1150 | 1149 |
| 1151 __ InNewSpace(rbx, rcx, equal, &exit); | 1150 __ InNewSpace(rbx, rcx, equal, &exit); |
| 1152 | 1151 |
| 1153 RecordWriteStub stub(rbx, rdx, rcx); | 1152 RecordWriteStub stub(rbx, rdx, rcx); |
| 1154 __ CallStub(&stub); | 1153 __ CallStub(&stub); |
| 1155 __ ret((argc + 1) * kPointerSize); | 1154 __ ret((argc + 1) * kPointerSize); |
| 1156 | 1155 |
| 1157 __ bind(&attempt_to_grow_elements); | 1156 __ bind(&attempt_to_grow_elements); |
| 1158 ExternalReference new_space_allocation_top = | 1157 ExternalReference new_space_allocation_top = |
| 1159 ExternalReference::new_space_allocation_top_address(); | 1158 ExternalReference::new_space_allocation_top_address(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1187 // ... and fill the rest with holes. | 1186 // ... and fill the rest with holes. |
| 1188 __ Move(kScratchRegister, Factory::the_hole_value()); | 1187 __ Move(kScratchRegister, Factory::the_hole_value()); |
| 1189 for (int i = 1; i < kAllocationDelta; i++) { | 1188 for (int i = 1; i < kAllocationDelta; i++) { |
| 1190 __ movq(Operand(rdx, i * kPointerSize), kScratchRegister); | 1189 __ movq(Operand(rdx, i * kPointerSize), kScratchRegister); |
| 1191 } | 1190 } |
| 1192 | 1191 |
| 1193 // Restore receiver to rdx as finish sequence assumes it's here. | 1192 // Restore receiver to rdx as finish sequence assumes it's here. |
| 1194 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 1193 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); |
| 1195 | 1194 |
| 1196 // Increment element's and array's sizes. | 1195 // Increment element's and array's sizes. |
| 1197 __ addl(FieldOperand(rbx, FixedArray::kLengthOffset), | 1196 __ SmiAddConstant(FieldOperand(rbx, FixedArray::kLengthOffset), |
| 1198 Immediate(kAllocationDelta)); | 1197 Smi::FromInt(kAllocationDelta)); |
| 1199 __ movq(FieldOperand(rdx, JSArray::kLengthOffset), rax); | 1198 __ movq(FieldOperand(rdx, JSArray::kLengthOffset), rax); |
| 1200 | 1199 |
| 1201 // Elements are in new space, so no remembered set updates are necessary. | 1200 // Elements are in new space, so write barrier is not required. |
| 1202 __ ret((argc + 1) * kPointerSize); | 1201 __ ret((argc + 1) * kPointerSize); |
| 1203 | 1202 |
| 1204 __ bind(&call_builtin); | 1203 __ bind(&call_builtin); |
| 1205 } | 1204 } |
| 1206 | 1205 |
| 1207 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush), | 1206 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush), |
| 1208 argc + 1, | 1207 argc + 1, |
| 1209 1); | 1208 1); |
| 1210 } | 1209 } |
| 1211 | 1210 |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2360 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | 2359 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 2361 | 2360 |
| 2362 // Return the generated code. | 2361 // Return the generated code. |
| 2363 return GetCode(); | 2362 return GetCode(); |
| 2364 } | 2363 } |
| 2365 | 2364 |
| 2366 | 2365 |
| 2367 #undef __ | 2366 #undef __ |
| 2368 | 2367 |
| 2369 } } // namespace v8::internal | 2368 } } // namespace v8::internal |
| OLD | NEW |