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

Side by Side Diff: src/mips/ic-mips.cc

Issue 9316061: MIPS: Handle single element array growth + transition in generic KeyedStoreIC (Closed)
Patch Set: rebased on r10618. Created 8 years, 10 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 | « src/mips/builtins-mips.cc ('k') | src/mips/macro-assembler-mips.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2012 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
11 // with the distribution. 11 // with the distribution.
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 StrictModeFlag strict_mode) { 1191 StrictModeFlag strict_mode) {
1192 // ---------- S t a t e -------------- 1192 // ---------- S t a t e --------------
1193 // -- a0 : value 1193 // -- a0 : value
1194 // -- a1 : key 1194 // -- a1 : key
1195 // -- a2 : receiver 1195 // -- a2 : receiver
1196 // -- ra : return address 1196 // -- ra : return address
1197 // ----------------------------------- 1197 // -----------------------------------
1198 Label slow, array, extra, check_if_double_array; 1198 Label slow, array, extra, check_if_double_array;
1199 Label fast_object_with_map_check, fast_object_without_map_check; 1199 Label fast_object_with_map_check, fast_object_without_map_check;
1200 Label fast_double_with_map_check, fast_double_without_map_check; 1200 Label fast_double_with_map_check, fast_double_without_map_check;
1201 Label transition_smi_elements, finish_object_store, non_double_value;
1202 Label transition_double_elements;
1201 1203
1202 // Register usage. 1204 // Register usage.
1203 Register value = a0; 1205 Register value = a0;
1204 Register key = a1; 1206 Register key = a1;
1205 Register receiver = a2; 1207 Register receiver = a2;
1206 Register elements = a3; // Elements array of the receiver. 1208 Register receiver_map = a3;
1207 Register elements_map = t2; 1209 Register elements_map = t2;
1208 Register receiver_map = t3; 1210 Register elements = t3; // Elements array of the receiver.
1209 // t0 and t1 are used as general scratch registers. 1211 // t0 and t1 are used as general scratch registers.
1210 1212
1211 // Check that the key is a smi. 1213 // Check that the key is a smi.
1212 __ JumpIfNotSmi(key, &slow); 1214 __ JumpIfNotSmi(key, &slow);
1213 // Check that the object isn't a smi. 1215 // Check that the object isn't a smi.
1214 __ JumpIfSmi(receiver, &slow); 1216 __ JumpIfSmi(receiver, &slow);
1215 // Get the map of the object. 1217 // Get the map of the object.
1216 __ lw(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset)); 1218 __ lw(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
1217 // Check that the receiver does not require access checks. We need 1219 // Check that the receiver does not require access checks. We need
1218 // to do this because this generic stub does not perform map checks. 1220 // to do this because this generic stub does not perform map checks.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 __ JumpIfNotSmi(value, &non_smi_value); 1293 __ JumpIfNotSmi(value, &non_smi_value);
1292 // It's irrelevant whether array is smi-only or not when writing a smi. 1294 // It's irrelevant whether array is smi-only or not when writing a smi.
1293 __ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 1295 __ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
1294 __ sll(scratch_value, key, kPointerSizeLog2 - kSmiTagSize); 1296 __ sll(scratch_value, key, kPointerSizeLog2 - kSmiTagSize);
1295 __ Addu(address, address, scratch_value); 1297 __ Addu(address, address, scratch_value);
1296 __ sw(value, MemOperand(address)); 1298 __ sw(value, MemOperand(address));
1297 __ Ret(USE_DELAY_SLOT); 1299 __ Ret(USE_DELAY_SLOT);
1298 __ mov(v0, value); 1300 __ mov(v0, value);
1299 1301
1300 __ bind(&non_smi_value); 1302 __ bind(&non_smi_value);
1301 // Escape to slow case when writing non-smi into smi-only array. 1303 // Escape to elements kind transition case.
1302 __ CheckFastObjectElements(receiver_map, scratch_value, &slow); 1304 __ CheckFastObjectElements(receiver_map, scratch_value,
1305 &transition_smi_elements);
1303 // Fast elements array, store the value to the elements backing store. 1306 // Fast elements array, store the value to the elements backing store.
1307 __ bind(&finish_object_store);
1304 __ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 1308 __ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
1305 __ sll(scratch_value, key, kPointerSizeLog2 - kSmiTagSize); 1309 __ sll(scratch_value, key, kPointerSizeLog2 - kSmiTagSize);
1306 __ Addu(address, address, scratch_value); 1310 __ Addu(address, address, scratch_value);
1307 __ sw(value, MemOperand(address)); 1311 __ sw(value, MemOperand(address));
1308 // Update write barrier for the elements array address. 1312 // Update write barrier for the elements array address.
1309 __ mov(v0, value); // Preserve the value which is returned. 1313 __ mov(v0, value); // Preserve the value which is returned.
1310 __ RecordWrite(elements, 1314 __ RecordWrite(elements,
1311 address, 1315 address,
1312 value, 1316 value,
1313 kRAHasNotBeenSaved, 1317 kRAHasNotBeenSaved,
1314 kDontSaveFPRegs, 1318 kDontSaveFPRegs,
1315 EMIT_REMEMBERED_SET, 1319 EMIT_REMEMBERED_SET,
1316 OMIT_SMI_CHECK); 1320 OMIT_SMI_CHECK);
1317 __ Ret(); 1321 __ Ret();
1318 1322
1319 __ bind(&fast_double_with_map_check); 1323 __ bind(&fast_double_with_map_check);
1320 // Check for fast double array case. If this fails, call through to the 1324 // Check for fast double array case. If this fails, call through to the
1321 // runtime. 1325 // runtime.
1322 __ Branch(&slow, ne, elements_map, 1326 __ Branch(&slow, ne, elements_map,
1323 Operand(masm->isolate()->factory()->fixed_double_array_map())); 1327 Operand(masm->isolate()->factory()->fixed_double_array_map()));
1324 __ bind(&fast_double_without_map_check); 1328 __ bind(&fast_double_without_map_check);
1325 __ StoreNumberToDoubleElements(value, 1329 __ StoreNumberToDoubleElements(value,
1326 key, 1330 key,
1327 receiver, 1331 receiver,
1328 elements, 1332 elements,
1333 a3,
1329 t0, 1334 t0,
1330 t1, 1335 t1,
1331 t2, 1336 t2,
1332 t3, 1337 &transition_double_elements);
1333 &slow);
1334 __ Ret(USE_DELAY_SLOT); 1338 __ Ret(USE_DELAY_SLOT);
1335 __ mov(v0, value); 1339 __ mov(v0, value);
1340
1341 __ bind(&transition_smi_elements);
1342 // Transition the array appropriately depending on the value type.
1343 __ lw(t0, FieldMemOperand(value, HeapObject::kMapOffset));
1344 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex);
1345 __ Branch(&non_double_value, ne, t0, Operand(at));
1346
1347 // Value is a double. Transition FAST_SMI_ONLY_ELEMENTS ->
1348 // FAST_DOUBLE_ELEMENTS and complete the store.
1349 __ LoadTransitionedArrayMapConditional(FAST_SMI_ONLY_ELEMENTS,
1350 FAST_DOUBLE_ELEMENTS,
1351 receiver_map,
1352 t0,
1353 &slow);
1354 ASSERT(receiver_map.is(a3)); // Transition code expects map in a3
1355 ElementsTransitionGenerator::GenerateSmiOnlyToDouble(masm, &slow);
1356 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1357 __ jmp(&fast_double_without_map_check);
1358
1359 __ bind(&non_double_value);
1360 // Value is not a double, FAST_SMI_ONLY_ELEMENTS -> FAST_ELEMENTS
1361 __ LoadTransitionedArrayMapConditional(FAST_SMI_ONLY_ELEMENTS,
1362 FAST_ELEMENTS,
1363 receiver_map,
1364 t0,
1365 &slow);
1366 ASSERT(receiver_map.is(a3)); // Transition code expects map in a3
1367 ElementsTransitionGenerator::GenerateSmiOnlyToObject(masm);
1368 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1369 __ jmp(&finish_object_store);
1370
1371 __ bind(&transition_double_elements);
1372 // Elements are FAST_DOUBLE_ELEMENTS, but value is an Object that's not a
1373 // HeapNumber. Make sure that the receiver is a Array with FAST_ELEMENTS and
1374 // transition array from FAST_DOUBLE_ELEMENTS to FAST_ELEMENTS
1375 __ LoadTransitionedArrayMapConditional(FAST_DOUBLE_ELEMENTS,
1376 FAST_ELEMENTS,
1377 receiver_map,
1378 t0,
1379 &slow);
1380 ASSERT(receiver_map.is(a3)); // Transition code expects map in a3
1381 ElementsTransitionGenerator::GenerateDoubleToObject(masm, &slow);
1382 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1383 __ jmp(&finish_object_store);
1336 } 1384 }
1337 1385
1338 1386
1339 void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) { 1387 void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) {
1340 // ---------- S t a t e -------------- 1388 // ---------- S t a t e --------------
1341 // -- ra : return address 1389 // -- ra : return address
1342 // -- a0 : key 1390 // -- a0 : key
1343 // -- a1 : receiver 1391 // -- a1 : receiver
1344 // ----------------------------------- 1392 // -----------------------------------
1345 Label slow; 1393 Label slow;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch)); 1749 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch));
1702 patcher.masm()->andi(at, reg, kSmiTagMask); 1750 patcher.masm()->andi(at, reg, kSmiTagMask);
1703 patcher.ChangeBranchCondition(eq); 1751 patcher.ChangeBranchCondition(eq);
1704 } 1752 }
1705 } 1753 }
1706 1754
1707 1755
1708 } } // namespace v8::internal 1756 } } // namespace v8::internal
1709 1757
1710 #endif // V8_TARGET_ARCH_MIPS 1758 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/mips/macro-assembler-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698