Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 1265003: Slightly faster variant of Array.push. (Closed)
Patch Set: Addressing Mads' comments Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 } else { 1244 } else {
1245 // Get the elements array of the object. 1245 // Get the elements array of the object.
1246 __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset)); 1246 __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset));
1247 1247
1248 // Check that the elements are in fast mode (not dictionary). 1248 // Check that the elements are in fast mode (not dictionary).
1249 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), 1249 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset),
1250 Immediate(Factory::fixed_array_map())); 1250 Immediate(Factory::fixed_array_map()));
1251 __ j(not_equal, &miss); 1251 __ j(not_equal, &miss);
1252 1252
1253 if (argc == 1) { // Otherwise fall through to call builtin. 1253 if (argc == 1) { // Otherwise fall through to call builtin.
1254 Label call_builtin, exit, with_rset_update, 1254 Label call_builtin, exit, with_rset_update, attempt_to_grow_elements;
1255 attempt_to_grow_elements, finish_push;
1256 1255
1257 // Get the array's length into eax and calculate new length. 1256 // Get the array's length into eax and calculate new length.
1258 __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset)); 1257 __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset));
1259 STATIC_ASSERT(kSmiTagSize == 1); 1258 STATIC_ASSERT(kSmiTagSize == 1);
1260 STATIC_ASSERT(kSmiTag == 0); 1259 STATIC_ASSERT(kSmiTag == 0);
1261 __ add(Operand(eax), Immediate(argc << 1)); 1260 __ add(Operand(eax), Immediate(argc << 1));
1262 1261
1263 // Get the element's length into ecx. 1262 // Get the element's length into ecx.
1264 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); 1263 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset));
1265 __ SmiTag(ecx); 1264 __ SmiTag(ecx);
1266 1265
1267 // Check if we could survive without allocation. 1266 // Check if we could survive without allocation.
1268 __ cmp(eax, Operand(ecx)); 1267 __ cmp(eax, Operand(ecx));
1269 __ j(greater, &attempt_to_grow_elements); 1268 __ j(greater, &attempt_to_grow_elements);
1270 1269
1271 // Save new length. 1270 // Save new length.
1272 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); 1271 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax);
1273 1272
1274 // Push the element. 1273 // Push the element.
1275 __ lea(edx, FieldOperand(ebx, 1274 __ lea(edx, FieldOperand(ebx,
1276 eax, times_half_pointer_size, 1275 eax, times_half_pointer_size,
1277 FixedArray::kHeaderSize - argc * kPointerSize)); 1276 FixedArray::kHeaderSize - argc * kPointerSize));
1278 __ mov(ecx, Operand(esp, argc * kPointerSize)); 1277 __ mov(ecx, Operand(esp, argc * kPointerSize));
1279 __ mov(Operand(edx, 0), ecx); 1278 __ mov(Operand(edx, 0), ecx);
1280 1279
1281 __ bind(&finish_push);
1282
1283 // Check if value is a smi. 1280 // Check if value is a smi.
1284 __ test(ecx, Immediate(kSmiTagMask)); 1281 __ test(ecx, Immediate(kSmiTagMask));
1285 __ j(not_zero, &with_rset_update); 1282 __ j(not_zero, &with_rset_update);
1286 1283
1287 __ bind(&exit); 1284 __ bind(&exit);
1288 __ ret((argc + 1) * kPointerSize); 1285 __ ret((argc + 1) * kPointerSize);
1289 1286
1290 __ bind(&with_rset_update); 1287 __ bind(&with_rset_update);
1291 1288
1292 __ InNewSpace(ebx, ecx, equal, &exit); 1289 __ InNewSpace(ebx, ecx, equal, &exit);
(...skipping 18 matching lines...) Expand all
1311 FixedArray::kHeaderSize - argc * kPointerSize)); 1308 FixedArray::kHeaderSize - argc * kPointerSize));
1312 __ cmp(edx, Operand(ecx)); 1309 __ cmp(edx, Operand(ecx));
1313 __ j(not_equal, &call_builtin); 1310 __ j(not_equal, &call_builtin);
1314 __ add(Operand(ecx), Immediate(kAllocationDelta * kPointerSize)); 1311 __ add(Operand(ecx), Immediate(kAllocationDelta * kPointerSize));
1315 __ cmp(ecx, Operand::StaticVariable(new_space_allocation_limit)); 1312 __ cmp(ecx, Operand::StaticVariable(new_space_allocation_limit));
1316 __ j(greater, &call_builtin); 1313 __ j(greater, &call_builtin);
1317 1314
1318 // We fit and could grow elements. 1315 // We fit and could grow elements.
1319 __ mov(Operand::StaticVariable(new_space_allocation_top), ecx); 1316 __ mov(Operand::StaticVariable(new_space_allocation_top), ecx);
1320 __ mov(ecx, Operand(esp, argc * kPointerSize)); 1317 __ mov(ecx, Operand(esp, argc * kPointerSize));
1318
1319 // Push the argument...
1321 __ mov(Operand(edx, 0), ecx); 1320 __ mov(Operand(edx, 0), ecx);
1321 // ... and fill the rest with holes.
1322 for (int i = 1; i < kAllocationDelta; i++) { 1322 for (int i = 1; i < kAllocationDelta; i++) {
1323 __ mov(Operand(edx, i * kPointerSize), 1323 __ mov(Operand(edx, i * kPointerSize),
1324 Immediate(Factory::undefined_value())); 1324 Immediate(Factory::the_hole_value()));
1325 } 1325 }
1326 1326
1327 // Restore receiver to edx as finish sequence assumes it's here. 1327 // Restore receiver to edx as finish sequence assumes it's here.
1328 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); 1328 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
1329 1329
1330 // Increment element's and array's sizes. 1330 // Increment element's and array's sizes.
1331 __ add(FieldOperand(ebx, FixedArray::kLengthOffset), 1331 __ add(FieldOperand(ebx, FixedArray::kLengthOffset),
1332 Immediate(kAllocationDelta)); 1332 Immediate(kAllocationDelta));
1333 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); 1333 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax);
1334 1334
1335 __ jmp(&finish_push); 1335 // Elements are in new space, so no remembered set updates are necessary.
1336 __ ret((argc + 1) * kPointerSize);
1336 1337
1337 __ bind(&call_builtin); 1338 __ bind(&call_builtin);
1338 } 1339 }
1339 1340
1340 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush), 1341 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush),
1341 argc + 1, 1342 argc + 1,
1342 1); 1343 1);
1343 } 1344 }
1344 1345
1345 __ bind(&miss); 1346 __ bind(&miss);
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
2424 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); 2425 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET);
2425 2426
2426 // Return the generated code. 2427 // Return the generated code.
2427 return GetCode(); 2428 return GetCode();
2428 } 2429 }
2429 2430
2430 2431
2431 #undef __ 2432 #undef __
2432 2433
2433 } } // namespace v8::internal 2434 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698