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

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

Issue 10987086: MIPS: Fix issue 2346 (order of operations in keyed store on arrays) and turn get-own-property-descr… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased on r12737 and fixed typos Created 8 years, 2 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 | Annotate | Revision Log
« 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 2012 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
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 // Push receiver, key and value for runtime call. 1182 // Push receiver, key and value for runtime call.
1183 __ Push(a2, a1, a0); 1183 __ Push(a2, a1, a0);
1184 __ li(a1, Operand(Smi::FromInt(NONE))); // PropertyAttributes. 1184 __ li(a1, Operand(Smi::FromInt(NONE))); // PropertyAttributes.
1185 __ li(a0, Operand(Smi::FromInt(strict_mode))); // Strict mode. 1185 __ li(a0, Operand(Smi::FromInt(strict_mode))); // Strict mode.
1186 __ Push(a1, a0); 1186 __ Push(a1, a0);
1187 1187
1188 __ TailCallRuntime(Runtime::kSetProperty, 5, 1); 1188 __ TailCallRuntime(Runtime::kSetProperty, 5, 1);
1189 } 1189 }
1190 1190
1191 1191
1192 static void KeyedStoreGenerateGenericHelper(
1193 MacroAssembler* masm,
1194 Label* fast_object,
1195 Label* fast_double,
1196 Label* slow,
1197 KeyedStoreCheckMap check_map,
1198 KeyedStoreIncrementLength increment_length,
1199 Register value,
1200 Register key,
1201 Register receiver,
1202 Register receiver_map,
1203 Register elements_map,
1204 Register elements) {
1205 Label transition_smi_elements;
1206 Label finish_object_store, non_double_value, transition_double_elements;
1207 Label fast_double_without_map_check;
1208
1209 // Fast case: Do the store, could be either Object or double.
1210 __ bind(fast_object);
1211 Register scratch_value = t0;
1212 Register address = t1;
1213 if (check_map == kCheckMap) {
1214 __ lw(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset));
1215 __ Branch(fast_double, ne, elements_map,
1216 Operand(masm->isolate()->factory()->fixed_array_map()));
1217 }
1218 // Smi stores don't require further checks.
1219 Label non_smi_value;
1220 __ JumpIfNotSmi(value, &non_smi_value);
1221
1222 if (increment_length == kIncrementLength) {
1223 // Add 1 to receiver->length.
1224 __ Addu(scratch_value, key, Operand(Smi::FromInt(1)));
1225 __ sw(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset));
1226 }
1227 // It's irrelevant whether array is smi-only or not when writing a smi.
1228 __ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
1229 __ sll(scratch_value, key, kPointerSizeLog2 - kSmiTagSize);
1230 __ Addu(address, address, scratch_value);
1231 __ sw(value, MemOperand(address));
1232 __ Ret();
1233
1234 __ bind(&non_smi_value);
1235 // Escape to elements kind transition case.
1236 __ CheckFastObjectElements(receiver_map, scratch_value,
1237 &transition_smi_elements);
1238
1239 // Fast elements array, store the value to the elements backing store.
1240 __ bind(&finish_object_store);
1241 if (increment_length == kIncrementLength) {
1242 // Add 1 to receiver->length.
1243 __ Addu(scratch_value, key, Operand(Smi::FromInt(1)));
1244 __ sw(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset));
1245 }
1246 __ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
1247 __ sll(scratch_value, key, kPointerSizeLog2 - kSmiTagSize);
1248 __ Addu(address, address, scratch_value);
1249 __ sw(value, MemOperand(address));
1250 // Update write barrier for the elements array address.
1251 __ mov(scratch_value, value); // Preserve the value which is returned.
1252 __ RecordWrite(elements,
1253 address,
1254 scratch_value,
1255 kRAHasNotBeenSaved,
1256 kDontSaveFPRegs,
1257 EMIT_REMEMBERED_SET,
1258 OMIT_SMI_CHECK);
1259 __ Ret();
1260
1261 __ bind(fast_double);
1262 if (check_map == kCheckMap) {
1263 // Check for fast double array case. If this fails, call through to the
1264 // runtime.
1265 __ LoadRoot(at, Heap::kFixedDoubleArrayMapRootIndex);
1266 __ Branch(slow, ne, elements_map, Operand(at));
1267 }
1268 __ bind(&fast_double_without_map_check);
1269 __ StoreNumberToDoubleElements(value,
1270 key,
1271 receiver,
1272 elements,
1273 a3,
1274 t0,
1275 t1,
1276 t2,
1277 &transition_double_elements);
1278 if (increment_length == kIncrementLength) {
1279 // Add 1 to receiver->length.
1280 __ Addu(scratch_value, key, Operand(Smi::FromInt(1)));
1281 __ sw(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset));
1282 }
1283 __ Ret();
1284
1285 __ bind(&transition_smi_elements);
1286 // Transition the array appropriately depending on the value type.
1287 __ lw(t0, FieldMemOperand(value, HeapObject::kMapOffset));
1288 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex);
1289 __ Branch(&non_double_value, ne, t0, Operand(at));
1290
1291 // Value is a double. Transition FAST_SMI_ELEMENTS ->
1292 // FAST_DOUBLE_ELEMENTS and complete the store.
1293 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS,
1294 FAST_DOUBLE_ELEMENTS,
1295 receiver_map,
1296 t0,
1297 slow);
1298 ASSERT(receiver_map.is(a3)); // Transition code expects map in a3
1299 ElementsTransitionGenerator::GenerateSmiToDouble(masm, slow);
1300 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1301 __ jmp(&fast_double_without_map_check);
1302
1303 __ bind(&non_double_value);
1304 // Value is not a double, FAST_SMI_ELEMENTS -> FAST_ELEMENTS
1305 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS,
1306 FAST_ELEMENTS,
1307 receiver_map,
1308 t0,
1309 slow);
1310 ASSERT(receiver_map.is(a3)); // Transition code expects map in a3
1311 ElementsTransitionGenerator::GenerateMapChangeElementsTransition(masm);
1312 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1313 __ jmp(&finish_object_store);
1314
1315 __ bind(&transition_double_elements);
1316 // Elements are FAST_DOUBLE_ELEMENTS, but value is an Object that's not a
1317 // HeapNumber. Make sure that the receiver is a Array with FAST_ELEMENTS and
1318 // transition array from FAST_DOUBLE_ELEMENTS to FAST_ELEMENTS
1319 __ LoadTransitionedArrayMapConditional(FAST_DOUBLE_ELEMENTS,
1320 FAST_ELEMENTS,
1321 receiver_map,
1322 t0,
1323 slow);
1324 ASSERT(receiver_map.is(a3)); // Transition code expects map in a3
1325 ElementsTransitionGenerator::GenerateDoubleToObject(masm, slow);
1326 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1327 __ jmp(&finish_object_store);
1328 }
1329
1330
1192 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, 1331 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm,
1193 StrictModeFlag strict_mode) { 1332 StrictModeFlag strict_mode) {
1194 // ---------- S t a t e -------------- 1333 // ---------- S t a t e --------------
1195 // -- a0 : value 1334 // -- a0 : value
1196 // -- a1 : key 1335 // -- a1 : key
1197 // -- a2 : receiver 1336 // -- a2 : receiver
1198 // -- ra : return address 1337 // -- ra : return address
1199 // ----------------------------------- 1338 // -----------------------------------
1200 Label slow, array, extra, check_if_double_array; 1339 Label slow, fast_object, fast_object_grow;
1201 Label fast_object_with_map_check, fast_object_without_map_check; 1340 Label fast_double, fast_double_grow;
1202 Label fast_double_with_map_check, fast_double_without_map_check; 1341 Label array, extra, check_if_double_array;
1203 Label transition_smi_elements, finish_object_store, non_double_value;
1204 Label transition_double_elements;
1205 1342
1206 // Register usage. 1343 // Register usage.
1207 Register value = a0; 1344 Register value = a0;
1208 Register key = a1; 1345 Register key = a1;
1209 Register receiver = a2; 1346 Register receiver = a2;
1210 Register receiver_map = a3; 1347 Register receiver_map = a3;
1211 Register elements_map = t2; 1348 Register elements_map = t2;
1212 Register elements = t3; // Elements array of the receiver. 1349 Register elements = t3; // Elements array of the receiver.
1213 // t0 and t1 are used as general scratch registers. 1350 // t0 and t1 are used as general scratch registers.
1214 1351
(...skipping 11 matching lines...) Expand all
1226 // Check if the object is a JS array or not. 1363 // Check if the object is a JS array or not.
1227 __ lbu(t0, FieldMemOperand(receiver_map, Map::kInstanceTypeOffset)); 1364 __ lbu(t0, FieldMemOperand(receiver_map, Map::kInstanceTypeOffset));
1228 __ Branch(&array, eq, t0, Operand(JS_ARRAY_TYPE)); 1365 __ Branch(&array, eq, t0, Operand(JS_ARRAY_TYPE));
1229 // Check that the object is some kind of JSObject. 1366 // Check that the object is some kind of JSObject.
1230 __ Branch(&slow, lt, t0, Operand(FIRST_JS_OBJECT_TYPE)); 1367 __ Branch(&slow, lt, t0, Operand(FIRST_JS_OBJECT_TYPE));
1231 1368
1232 // Object case: Check key against length in the elements array. 1369 // Object case: Check key against length in the elements array.
1233 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); 1370 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1234 // Check array bounds. Both the key and the length of FixedArray are smis. 1371 // Check array bounds. Both the key and the length of FixedArray are smis.
1235 __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset)); 1372 __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
1236 __ Branch(&fast_object_with_map_check, lo, key, Operand(t0)); 1373 __ Branch(&fast_object, lo, key, Operand(t0));
1237 1374
1238 // Slow case, handle jump to runtime. 1375 // Slow case, handle jump to runtime.
1239 __ bind(&slow); 1376 __ bind(&slow);
1240 // Entry registers are intact. 1377 // Entry registers are intact.
1241 // a0: value. 1378 // a0: value.
1242 // a1: key. 1379 // a1: key.
1243 // a2: receiver. 1380 // a2: receiver.
1244 GenerateRuntimeSetProperty(masm, strict_mode); 1381 GenerateRuntimeSetProperty(masm, strict_mode);
1245 1382
1246 // Extra capacity case: Check if there is extra capacity to 1383 // Extra capacity case: Check if there is extra capacity to
1247 // perform the store and update the length. Used for adding one 1384 // perform the store and update the length. Used for adding one
1248 // element to the array by writing to array[array.length]. 1385 // element to the array by writing to array[array.length].
1249 __ bind(&extra); 1386 __ bind(&extra);
1250 // Condition code from comparing key and array length is still available. 1387 // Condition code from comparing key and array length is still available.
1251 // Only support writing to array[array.length]. 1388 // Only support writing to array[array.length].
1252 __ Branch(&slow, ne, key, Operand(t0)); 1389 __ Branch(&slow, ne, key, Operand(t0));
1253 // Check for room in the elements backing store. 1390 // Check for room in the elements backing store.
1254 // Both the key and the length of FixedArray are smis. 1391 // Both the key and the length of FixedArray are smis.
1255 __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset)); 1392 __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
1256 __ Branch(&slow, hs, key, Operand(t0)); 1393 __ Branch(&slow, hs, key, Operand(t0));
1257 __ lw(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset)); 1394 __ lw(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset));
1258 __ Branch( 1395 __ Branch(
1259 &check_if_double_array, ne, elements_map, Heap::kFixedArrayMapRootIndex); 1396 &check_if_double_array, ne, elements_map, Heap::kFixedArrayMapRootIndex);
1260 1397
1261 // Calculate key + 1 as smi. 1398 __ jmp(&fast_object_grow);
1262 STATIC_ASSERT(kSmiTag == 0);
1263 __ Addu(t0, key, Operand(Smi::FromInt(1)));
1264 __ sw(t0, FieldMemOperand(receiver, JSArray::kLengthOffset));
1265 __ Branch(&fast_object_without_map_check);
1266 1399
1267 __ bind(&check_if_double_array); 1400 __ bind(&check_if_double_array);
1268 __ Branch(&slow, ne, elements_map, Heap::kFixedDoubleArrayMapRootIndex); 1401 __ Branch(&slow, ne, elements_map, Heap::kFixedDoubleArrayMapRootIndex);
1269 // Add 1 to key, and go to common element store code for doubles. 1402 __ jmp(&fast_double_grow);
1270 STATIC_ASSERT(kSmiTag == 0);
1271 __ Addu(t0, key, Operand(Smi::FromInt(1)));
1272 __ sw(t0, FieldMemOperand(receiver, JSArray::kLengthOffset));
1273 __ jmp(&fast_double_without_map_check);
1274 1403
1275 // Array case: Get the length and the elements array from the JS 1404 // Array case: Get the length and the elements array from the JS
1276 // array. Check that the array is in fast mode (and writable); if it 1405 // array. Check that the array is in fast mode (and writable); if it
1277 // is the length is always a smi. 1406 // is the length is always a smi.
1278 __ bind(&array); 1407 __ bind(&array);
1279 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); 1408 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1280 1409
1281 // Check the key against the length in the array. 1410 // Check the key against the length in the array.
1282 __ lw(t0, FieldMemOperand(receiver, JSArray::kLengthOffset)); 1411 __ lw(t0, FieldMemOperand(receiver, JSArray::kLengthOffset));
1283 __ Branch(&extra, hs, key, Operand(t0)); 1412 __ Branch(&extra, hs, key, Operand(t0));
1284 // Fall through to fast case.
1285 1413
1286 __ bind(&fast_object_with_map_check); 1414 KeyedStoreGenerateGenericHelper(masm, &fast_object, &fast_double,
1287 Register scratch_value = t0; 1415 &slow, kCheckMap, kDontIncrementLength,
danno 2012/10/16 08:27:48 nit: spacing. I'll fix when I land.
1288 Register address = t1; 1416 value, key, receiver, receiver_map,
1289 __ lw(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset)); 1417 elements_map, elements);
1290 __ Branch(&fast_double_with_map_check, 1418 KeyedStoreGenerateGenericHelper(masm, &fast_object_grow, &fast_double_grow,
1291 ne, 1419 &slow, kDontCheckMap, kIncrementLength,
1292 elements_map, 1420 value, key, receiver, receiver_map,
1293 Heap::kFixedArrayMapRootIndex); 1421 elements_map, elements);
1294 __ bind(&fast_object_without_map_check);
1295 // Smi stores don't require further checks.
1296 Label non_smi_value;
1297 __ JumpIfNotSmi(value, &non_smi_value);
1298 // It's irrelevant whether array is smi-only or not when writing a smi.
1299 __ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
1300 __ sll(scratch_value, key, kPointerSizeLog2 - kSmiTagSize);
1301 __ Addu(address, address, scratch_value);
1302 __ sw(value, MemOperand(address));
1303 __ Ret(USE_DELAY_SLOT);
1304 __ mov(v0, value);
1305
1306 __ bind(&non_smi_value);
1307 // Escape to elements kind transition case.
1308 __ CheckFastObjectElements(receiver_map, scratch_value,
1309 &transition_smi_elements);
1310 // Fast elements array, store the value to the elements backing store.
1311 __ bind(&finish_object_store);
1312 __ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
1313 __ sll(scratch_value, key, kPointerSizeLog2 - kSmiTagSize);
1314 __ Addu(address, address, scratch_value);
1315 __ sw(value, MemOperand(address));
1316 // Update write barrier for the elements array address.
1317 __ mov(v0, value); // Preserve the value which is returned.
1318 __ RecordWrite(elements,
1319 address,
1320 value,
1321 kRAHasNotBeenSaved,
1322 kDontSaveFPRegs,
1323 EMIT_REMEMBERED_SET,
1324 OMIT_SMI_CHECK);
1325 __ Ret();
1326
1327 __ bind(&fast_double_with_map_check);
1328 // Check for fast double array case. If this fails, call through to the
1329 // runtime.
1330 __ Branch(&slow, ne, elements_map, Heap::kFixedDoubleArrayMapRootIndex);
1331 __ bind(&fast_double_without_map_check);
1332 __ StoreNumberToDoubleElements(value,
1333 key,
1334 receiver,
1335 elements,
1336 a3,
1337 t0,
1338 t1,
1339 t2,
1340 &transition_double_elements);
1341 __ Ret(USE_DELAY_SLOT);
1342 __ mov(v0, value);
1343
1344 __ bind(&transition_smi_elements);
1345 // Transition the array appropriately depending on the value type.
1346 __ lw(t0, FieldMemOperand(value, HeapObject::kMapOffset));
1347 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex);
1348 __ Branch(&non_double_value, ne, t0, Operand(at));
1349
1350
1351 // Value is a double. Transition FAST_SMI_ELEMENTS -> FAST_DOUBLE_ELEMENTS
1352 // and complete the store.
1353 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS,
1354 FAST_DOUBLE_ELEMENTS,
1355 receiver_map,
1356 t0,
1357 &slow);
1358 ASSERT(receiver_map.is(a3)); // Transition code expects map in a3
1359 ElementsTransitionGenerator::GenerateSmiToDouble(masm, &slow);
1360 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1361 __ jmp(&fast_double_without_map_check);
1362
1363 __ bind(&non_double_value);
1364 // Value is not a double, FAST_SMI_ELEMENTS -> FAST_ELEMENTS
1365 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS,
1366 FAST_ELEMENTS,
1367 receiver_map,
1368 t0,
1369 &slow);
1370 ASSERT(receiver_map.is(a3)); // Transition code expects map in a3
1371 ElementsTransitionGenerator::GenerateMapChangeElementsTransition(masm);
1372 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1373 __ jmp(&finish_object_store);
1374
1375 __ bind(&transition_double_elements);
1376 // Elements are double, but value is an Object that's not a HeapNumber. Make
1377 // sure that the receiver is a Array with Object elements and transition array
1378 // from double elements to Object elements.
1379 __ LoadTransitionedArrayMapConditional(FAST_DOUBLE_ELEMENTS,
1380 FAST_ELEMENTS,
1381 receiver_map,
1382 t0,
1383 &slow);
1384 ASSERT(receiver_map.is(a3)); // Transition code expects map in a3
1385 ElementsTransitionGenerator::GenerateDoubleToObject(masm, &slow);
1386 __ lw(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
1387 __ jmp(&finish_object_store);
1388 } 1422 }
1389 1423
1390 1424
1391 void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) { 1425 void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) {
1392 // ---------- S t a t e -------------- 1426 // ---------- S t a t e --------------
1393 // -- ra : return address 1427 // -- ra : return address
1394 // -- a0 : key 1428 // -- a0 : key
1395 // -- a1 : receiver 1429 // -- a1 : receiver
1396 // ----------------------------------- 1430 // -----------------------------------
1397 Label slow; 1431 Label slow;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 } else { 1787 } else {
1754 ASSERT(Assembler::IsBne(branch_instr)); 1788 ASSERT(Assembler::IsBne(branch_instr));
1755 patcher.ChangeBranchCondition(eq); 1789 patcher.ChangeBranchCondition(eq);
1756 } 1790 }
1757 } 1791 }
1758 1792
1759 1793
1760 } } // namespace v8::internal 1794 } } // namespace v8::internal
1761 1795
1762 #endif // V8_TARGET_ARCH_MIPS 1796 #endif // V8_TARGET_ARCH_MIPS
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