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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 } else { | 1164 } else { |
1165 // Get the elements array of the object. | 1165 // Get the elements array of the object. |
1166 __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset)); | 1166 __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset)); |
1167 | 1167 |
1168 // Check that the elements are in fast mode (not dictionary). | 1168 // Check that the elements are in fast mode (not dictionary). |
1169 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), | 1169 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), |
1170 Immediate(Factory::fixed_array_map())); | 1170 Immediate(Factory::fixed_array_map())); |
1171 __ j(not_equal, &miss); | 1171 __ j(not_equal, &miss); |
1172 | 1172 |
1173 if (argc == 1) { // Otherwise fall through to call builtin. | 1173 if (argc == 1) { // Otherwise fall through to call builtin. |
1174 Label call_builtin, exit, with_rset_update, attempt_to_grow_elements; | 1174 Label call_builtin, exit, with_write_barrier, attempt_to_grow_elements; |
1175 | 1175 |
1176 // Get the array's length into eax and calculate new length. | 1176 // Get the array's length into eax and calculate new length. |
1177 __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset)); | 1177 __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset)); |
1178 STATIC_ASSERT(kSmiTagSize == 1); | 1178 STATIC_ASSERT(kSmiTagSize == 1); |
1179 STATIC_ASSERT(kSmiTag == 0); | 1179 STATIC_ASSERT(kSmiTag == 0); |
1180 __ add(Operand(eax), Immediate(Smi::FromInt(argc))); | 1180 __ add(Operand(eax), Immediate(Smi::FromInt(argc))); |
1181 | 1181 |
1182 // Get the element's length into ecx. | 1182 // Get the element's length into ecx. |
1183 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); | 1183 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); |
1184 __ SmiTag(ecx); | |
1185 | 1184 |
1186 // Check if we could survive without allocation. | 1185 // Check if we could survive without allocation. |
1187 __ cmp(eax, Operand(ecx)); | 1186 __ cmp(eax, Operand(ecx)); |
1188 __ j(greater, &attempt_to_grow_elements); | 1187 __ j(greater, &attempt_to_grow_elements); |
1189 | 1188 |
1190 // Save new length. | 1189 // Save new length. |
1191 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); | 1190 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); |
1192 | 1191 |
1193 // Push the element. | 1192 // Push the element. |
1194 __ lea(edx, FieldOperand(ebx, | 1193 __ lea(edx, FieldOperand(ebx, |
1195 eax, times_half_pointer_size, | 1194 eax, times_half_pointer_size, |
1196 FixedArray::kHeaderSize - argc * kPointerSize)); | 1195 FixedArray::kHeaderSize - argc * kPointerSize)); |
1197 __ mov(ecx, Operand(esp, argc * kPointerSize)); | 1196 __ mov(ecx, Operand(esp, argc * kPointerSize)); |
1198 __ mov(Operand(edx, 0), ecx); | 1197 __ mov(Operand(edx, 0), ecx); |
1199 | 1198 |
1200 // Check if value is a smi. | 1199 // Check if value is a smi. |
1201 __ test(ecx, Immediate(kSmiTagMask)); | 1200 __ test(ecx, Immediate(kSmiTagMask)); |
1202 __ j(not_zero, &with_rset_update); | 1201 __ j(not_zero, &with_write_barrier); |
1203 | 1202 |
1204 __ bind(&exit); | 1203 __ bind(&exit); |
1205 __ ret((argc + 1) * kPointerSize); | 1204 __ ret((argc + 1) * kPointerSize); |
1206 | 1205 |
1207 __ bind(&with_rset_update); | 1206 __ bind(&with_write_barrier); |
1208 | 1207 |
1209 __ InNewSpace(ebx, ecx, equal, &exit); | 1208 __ InNewSpace(ebx, ecx, equal, &exit); |
1210 | 1209 |
1211 RecordWriteStub stub(ebx, edx, ecx); | 1210 __ RecordWriteHelper(ebx, edx, ecx); |
1212 __ CallStub(&stub); | |
1213 __ ret((argc + 1) * kPointerSize); | 1211 __ ret((argc + 1) * kPointerSize); |
1214 | 1212 |
1215 __ bind(&attempt_to_grow_elements); | 1213 __ bind(&attempt_to_grow_elements); |
1216 ExternalReference new_space_allocation_top = | 1214 ExternalReference new_space_allocation_top = |
1217 ExternalReference::new_space_allocation_top_address(); | 1215 ExternalReference::new_space_allocation_top_address(); |
1218 ExternalReference new_space_allocation_limit = | 1216 ExternalReference new_space_allocation_limit = |
1219 ExternalReference::new_space_allocation_limit_address(); | 1217 ExternalReference::new_space_allocation_limit_address(); |
1220 | 1218 |
1221 const int kAllocationDelta = 4; | 1219 const int kAllocationDelta = 4; |
1222 // Load top. | 1220 // Load top. |
(...skipping 19 matching lines...) Expand all Loading... |
1242 for (int i = 1; i < kAllocationDelta; i++) { | 1240 for (int i = 1; i < kAllocationDelta; i++) { |
1243 __ mov(Operand(edx, i * kPointerSize), | 1241 __ mov(Operand(edx, i * kPointerSize), |
1244 Immediate(Factory::the_hole_value())); | 1242 Immediate(Factory::the_hole_value())); |
1245 } | 1243 } |
1246 | 1244 |
1247 // Restore receiver to edx as finish sequence assumes it's here. | 1245 // Restore receiver to edx as finish sequence assumes it's here. |
1248 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | 1246 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
1249 | 1247 |
1250 // Increment element's and array's sizes. | 1248 // Increment element's and array's sizes. |
1251 __ add(FieldOperand(ebx, FixedArray::kLengthOffset), | 1249 __ add(FieldOperand(ebx, FixedArray::kLengthOffset), |
1252 Immediate(kAllocationDelta)); | 1250 Immediate(Smi::FromInt(kAllocationDelta))); |
1253 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); | 1251 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); |
1254 | 1252 |
1255 // Elements are in new space, so no remembered set updates are necessary. | 1253 // Elements are in new space, so write barrier is not required. |
1256 __ ret((argc + 1) * kPointerSize); | 1254 __ ret((argc + 1) * kPointerSize); |
1257 | 1255 |
1258 __ bind(&call_builtin); | 1256 __ bind(&call_builtin); |
1259 } | 1257 } |
1260 | 1258 |
1261 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush), | 1259 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush), |
1262 argc + 1, | 1260 argc + 1, |
1263 1); | 1261 1); |
1264 } | 1262 } |
1265 | 1263 |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2380 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | 2378 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
2381 | 2379 |
2382 // Return the generated code. | 2380 // Return the generated code. |
2383 return GetCode(); | 2381 return GetCode(); |
2384 } | 2382 } |
2385 | 2383 |
2386 | 2384 |
2387 #undef __ | 2385 #undef __ |
2388 | 2386 |
2389 } } // namespace v8::internal | 2387 } } // namespace v8::internal |
OLD | NEW |