| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 } else { | 1199 } else { |
| 1200 // Get the elements array of the object. | 1200 // Get the elements array of the object. |
| 1201 __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset)); | 1201 __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset)); |
| 1202 | 1202 |
| 1203 // Check that the elements are in fast mode (not dictionary). | 1203 // Check that the elements are in fast mode (not dictionary). |
| 1204 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), | 1204 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), |
| 1205 Immediate(Factory::fixed_array_map())); | 1205 Immediate(Factory::fixed_array_map())); |
| 1206 __ j(not_equal, &miss); | 1206 __ j(not_equal, &miss); |
| 1207 | 1207 |
| 1208 if (argc == 1) { // Otherwise fall through to call builtin. | 1208 if (argc == 1) { // Otherwise fall through to call builtin. |
| 1209 Label call_builtin, exit, with_write_barrier, attempt_to_grow_elements; | 1209 Label call_builtin, exit, with_rset_update, attempt_to_grow_elements; |
| 1210 | 1210 |
| 1211 // Get the array's length into eax and calculate new length. | 1211 // Get the array's length into eax and calculate new length. |
| 1212 __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset)); | 1212 __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset)); |
| 1213 STATIC_ASSERT(kSmiTagSize == 1); | 1213 STATIC_ASSERT(kSmiTagSize == 1); |
| 1214 STATIC_ASSERT(kSmiTag == 0); | 1214 STATIC_ASSERT(kSmiTag == 0); |
| 1215 __ add(Operand(eax), Immediate(Smi::FromInt(argc))); | 1215 __ add(Operand(eax), Immediate(Smi::FromInt(argc))); |
| 1216 | 1216 |
| 1217 // Get the element's length into ecx. | 1217 // Get the element's length into ecx. |
| 1218 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); | 1218 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); |
| 1219 __ SmiTag(ecx); |
| 1219 | 1220 |
| 1220 // Check if we could survive without allocation. | 1221 // Check if we could survive without allocation. |
| 1221 __ cmp(eax, Operand(ecx)); | 1222 __ cmp(eax, Operand(ecx)); |
| 1222 __ j(greater, &attempt_to_grow_elements); | 1223 __ j(greater, &attempt_to_grow_elements); |
| 1223 | 1224 |
| 1224 // Save new length. | 1225 // Save new length. |
| 1225 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); | 1226 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); |
| 1226 | 1227 |
| 1227 // Push the element. | 1228 // Push the element. |
| 1228 __ lea(edx, FieldOperand(ebx, | 1229 __ lea(edx, FieldOperand(ebx, |
| 1229 eax, times_half_pointer_size, | 1230 eax, times_half_pointer_size, |
| 1230 FixedArray::kHeaderSize - argc * kPointerSize)); | 1231 FixedArray::kHeaderSize - argc * kPointerSize)); |
| 1231 __ mov(ecx, Operand(esp, argc * kPointerSize)); | 1232 __ mov(ecx, Operand(esp, argc * kPointerSize)); |
| 1232 __ mov(Operand(edx, 0), ecx); | 1233 __ mov(Operand(edx, 0), ecx); |
| 1233 | 1234 |
| 1234 // Check if value is a smi. | 1235 // Check if value is a smi. |
| 1235 __ test(ecx, Immediate(kSmiTagMask)); | 1236 __ test(ecx, Immediate(kSmiTagMask)); |
| 1236 __ j(not_zero, &with_write_barrier); | 1237 __ j(not_zero, &with_rset_update); |
| 1237 | 1238 |
| 1238 __ bind(&exit); | 1239 __ bind(&exit); |
| 1239 __ ret((argc + 1) * kPointerSize); | 1240 __ ret((argc + 1) * kPointerSize); |
| 1240 | 1241 |
| 1241 __ bind(&with_write_barrier); | 1242 __ bind(&with_rset_update); |
| 1242 | 1243 |
| 1243 __ InNewSpace(ebx, ecx, equal, &exit); | 1244 __ InNewSpace(ebx, ecx, equal, &exit); |
| 1244 | 1245 |
| 1245 __ RecordWriteHelper(ebx, edx, ecx); | 1246 RecordWriteStub stub(ebx, edx, ecx); |
| 1247 __ CallStub(&stub); |
| 1246 __ ret((argc + 1) * kPointerSize); | 1248 __ ret((argc + 1) * kPointerSize); |
| 1247 | 1249 |
| 1248 __ bind(&attempt_to_grow_elements); | 1250 __ bind(&attempt_to_grow_elements); |
| 1249 ExternalReference new_space_allocation_top = | 1251 ExternalReference new_space_allocation_top = |
| 1250 ExternalReference::new_space_allocation_top_address(); | 1252 ExternalReference::new_space_allocation_top_address(); |
| 1251 ExternalReference new_space_allocation_limit = | 1253 ExternalReference new_space_allocation_limit = |
| 1252 ExternalReference::new_space_allocation_limit_address(); | 1254 ExternalReference::new_space_allocation_limit_address(); |
| 1253 | 1255 |
| 1254 const int kAllocationDelta = 4; | 1256 const int kAllocationDelta = 4; |
| 1255 // Load top. | 1257 // Load top. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1275 for (int i = 1; i < kAllocationDelta; i++) { | 1277 for (int i = 1; i < kAllocationDelta; i++) { |
| 1276 __ mov(Operand(edx, i * kPointerSize), | 1278 __ mov(Operand(edx, i * kPointerSize), |
| 1277 Immediate(Factory::the_hole_value())); | 1279 Immediate(Factory::the_hole_value())); |
| 1278 } | 1280 } |
| 1279 | 1281 |
| 1280 // Restore receiver to edx as finish sequence assumes it's here. | 1282 // Restore receiver to edx as finish sequence assumes it's here. |
| 1281 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | 1283 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 1282 | 1284 |
| 1283 // Increment element's and array's sizes. | 1285 // Increment element's and array's sizes. |
| 1284 __ add(FieldOperand(ebx, FixedArray::kLengthOffset), | 1286 __ add(FieldOperand(ebx, FixedArray::kLengthOffset), |
| 1285 Immediate(Smi::FromInt(kAllocationDelta))); | 1287 Immediate(kAllocationDelta)); |
| 1286 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); | 1288 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); |
| 1287 | 1289 |
| 1288 // Elements are in new space, so write barrier is not required. | 1290 // Elements are in new space, so no remembered set updates are necessary. |
| 1289 __ ret((argc + 1) * kPointerSize); | 1291 __ ret((argc + 1) * kPointerSize); |
| 1290 | 1292 |
| 1291 __ bind(&call_builtin); | 1293 __ bind(&call_builtin); |
| 1292 } | 1294 } |
| 1293 | 1295 |
| 1294 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush), | 1296 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush), |
| 1295 argc + 1, | 1297 argc + 1, |
| 1296 1); | 1298 1); |
| 1297 } | 1299 } |
| 1298 | 1300 |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2415 // Return the generated code. | 2417 // Return the generated code. |
| 2416 return GetCode(); | 2418 return GetCode(); |
| 2417 } | 2419 } |
| 2418 | 2420 |
| 2419 | 2421 |
| 2420 #undef __ | 2422 #undef __ |
| 2421 | 2423 |
| 2422 } } // namespace v8::internal | 2424 } } // namespace v8::internal |
| 2423 | 2425 |
| 2424 #endif // V8_TARGET_ARCH_IA32 | 2426 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |