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 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 } else { | 1191 } else { |
1192 // Get the elements array of the object. | 1192 // Get the elements array of the object. |
1193 __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset)); | 1193 __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset)); |
1194 | 1194 |
1195 // Check that the elements are in fast mode (not dictionary). | 1195 // Check that the elements are in fast mode (not dictionary). |
1196 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), | 1196 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), |
1197 Immediate(Factory::fixed_array_map())); | 1197 Immediate(Factory::fixed_array_map())); |
1198 __ j(not_equal, &miss); | 1198 __ j(not_equal, &miss); |
1199 | 1199 |
1200 if (argc == 1) { // Otherwise fall through to call builtin. | 1200 if (argc == 1) { // Otherwise fall through to call builtin. |
1201 Label call_builtin, exit, with_rset_update, attempt_to_grow_elements; | 1201 Label call_builtin, exit, with_write_barrier, attempt_to_grow_elements; |
1202 | 1202 |
1203 // Get the array's length into eax and calculate new length. | 1203 // Get the array's length into eax and calculate new length. |
1204 __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset)); | 1204 __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset)); |
1205 STATIC_ASSERT(kSmiTagSize == 1); | 1205 STATIC_ASSERT(kSmiTagSize == 1); |
1206 STATIC_ASSERT(kSmiTag == 0); | 1206 STATIC_ASSERT(kSmiTag == 0); |
1207 __ add(Operand(eax), Immediate(Smi::FromInt(argc))); | 1207 __ add(Operand(eax), Immediate(Smi::FromInt(argc))); |
1208 | 1208 |
1209 // Get the element's length into ecx. | 1209 // Get the element's length into ecx. |
1210 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); | 1210 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); |
1211 __ SmiTag(ecx); | |
1212 | 1211 |
1213 // Check if we could survive without allocation. | 1212 // Check if we could survive without allocation. |
1214 __ cmp(eax, Operand(ecx)); | 1213 __ cmp(eax, Operand(ecx)); |
1215 __ j(greater, &attempt_to_grow_elements); | 1214 __ j(greater, &attempt_to_grow_elements); |
1216 | 1215 |
1217 // Save new length. | 1216 // Save new length. |
1218 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); | 1217 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); |
1219 | 1218 |
1220 // Push the element. | 1219 // Push the element. |
1221 __ lea(edx, FieldOperand(ebx, | 1220 __ lea(edx, FieldOperand(ebx, |
1222 eax, times_half_pointer_size, | 1221 eax, times_half_pointer_size, |
1223 FixedArray::kHeaderSize - argc * kPointerSize)); | 1222 FixedArray::kHeaderSize - argc * kPointerSize)); |
1224 __ mov(ecx, Operand(esp, argc * kPointerSize)); | 1223 __ mov(ecx, Operand(esp, argc * kPointerSize)); |
1225 __ mov(Operand(edx, 0), ecx); | 1224 __ mov(Operand(edx, 0), ecx); |
1226 | 1225 |
1227 // Check if value is a smi. | 1226 // Check if value is a smi. |
1228 __ test(ecx, Immediate(kSmiTagMask)); | 1227 __ test(ecx, Immediate(kSmiTagMask)); |
1229 __ j(not_zero, &with_rset_update); | 1228 __ j(not_zero, &with_write_barrier); |
1230 | 1229 |
1231 __ bind(&exit); | 1230 __ bind(&exit); |
1232 __ ret((argc + 1) * kPointerSize); | 1231 __ ret((argc + 1) * kPointerSize); |
1233 | 1232 |
1234 __ bind(&with_rset_update); | 1233 __ bind(&with_write_barrier); |
1235 | 1234 |
1236 __ InNewSpace(ebx, ecx, equal, &exit); | 1235 __ InNewSpace(ebx, ecx, equal, &exit); |
1237 | 1236 |
1238 RecordWriteStub stub(ebx, edx, ecx); | 1237 __ RecordWriteHelper(ebx, edx, ecx); |
1239 __ CallStub(&stub); | |
1240 __ ret((argc + 1) * kPointerSize); | 1238 __ ret((argc + 1) * kPointerSize); |
1241 | 1239 |
1242 __ bind(&attempt_to_grow_elements); | 1240 __ bind(&attempt_to_grow_elements); |
1243 ExternalReference new_space_allocation_top = | 1241 ExternalReference new_space_allocation_top = |
1244 ExternalReference::new_space_allocation_top_address(); | 1242 ExternalReference::new_space_allocation_top_address(); |
1245 ExternalReference new_space_allocation_limit = | 1243 ExternalReference new_space_allocation_limit = |
1246 ExternalReference::new_space_allocation_limit_address(); | 1244 ExternalReference::new_space_allocation_limit_address(); |
1247 | 1245 |
1248 const int kAllocationDelta = 4; | 1246 const int kAllocationDelta = 4; |
1249 // Load top. | 1247 // Load top. |
(...skipping 19 matching lines...) Expand all Loading... |
1269 for (int i = 1; i < kAllocationDelta; i++) { | 1267 for (int i = 1; i < kAllocationDelta; i++) { |
1270 __ mov(Operand(edx, i * kPointerSize), | 1268 __ mov(Operand(edx, i * kPointerSize), |
1271 Immediate(Factory::the_hole_value())); | 1269 Immediate(Factory::the_hole_value())); |
1272 } | 1270 } |
1273 | 1271 |
1274 // Restore receiver to edx as finish sequence assumes it's here. | 1272 // Restore receiver to edx as finish sequence assumes it's here. |
1275 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | 1273 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
1276 | 1274 |
1277 // Increment element's and array's sizes. | 1275 // Increment element's and array's sizes. |
1278 __ add(FieldOperand(ebx, FixedArray::kLengthOffset), | 1276 __ add(FieldOperand(ebx, FixedArray::kLengthOffset), |
1279 Immediate(kAllocationDelta)); | 1277 Immediate(Smi::FromInt(kAllocationDelta))); |
1280 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); | 1278 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); |
1281 | 1279 |
1282 // Elements are in new space, so no remembered set updates are necessary. | 1280 // Elements are in new space, so write barrier is not required. |
1283 __ ret((argc + 1) * kPointerSize); | 1281 __ ret((argc + 1) * kPointerSize); |
1284 | 1282 |
1285 __ bind(&call_builtin); | 1283 __ bind(&call_builtin); |
1286 } | 1284 } |
1287 | 1285 |
1288 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush), | 1286 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush), |
1289 argc + 1, | 1287 argc + 1, |
1290 1); | 1288 1); |
1291 } | 1289 } |
1292 | 1290 |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2543 // Return the generated code. | 2541 // Return the generated code. |
2544 return GetCode(); | 2542 return GetCode(); |
2545 } | 2543 } |
2546 | 2544 |
2547 | 2545 |
2548 #undef __ | 2546 #undef __ |
2549 | 2547 |
2550 } } // namespace v8::internal | 2548 } } // namespace v8::internal |
2551 | 2549 |
2552 #endif // V8_TARGET_ARCH_IA32 | 2550 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |