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

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

Issue 8895025: Fix invalid usage of StoreIC_ArrayLength optimization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Sven Panne. Created 9 years 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 | « src/arm/ic-arm.cc ('k') | src/ia32/macro-assembler-ia32.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 2011 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 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 1367
1368 1368
1369 void StoreIC::GenerateArrayLength(MacroAssembler* masm) { 1369 void StoreIC::GenerateArrayLength(MacroAssembler* masm) {
1370 // ----------- S t a t e ------------- 1370 // ----------- S t a t e -------------
1371 // -- eax : value 1371 // -- eax : value
1372 // -- ecx : name 1372 // -- ecx : name
1373 // -- edx : receiver 1373 // -- edx : receiver
1374 // -- esp[0] : return address 1374 // -- esp[0] : return address
1375 // ----------------------------------- 1375 // -----------------------------------
1376 // 1376 //
1377 // This accepts as a receiver anything JSObject::SetElementsLength accepts 1377 // This accepts as a receiver anything JSArray::SetElementsLength accepts
1378 // (currently anything except for external arrays which means anything with 1378 // (currently anything except for external arrays which means anything with
1379 // elements of FixedArray type.), but currently is restricted to JSArray. 1379 // elements of FixedArray type). Value must be a number, but only smis are
1380 // Value must be a number, but only smis are accepted as the most common case. 1380 // accepted as the most common case.
1381 1381
1382 Label miss; 1382 Label miss;
1383 1383
1384 Register receiver = edx; 1384 Register receiver = edx;
1385 Register value = eax; 1385 Register value = eax;
1386 Register scratch = ebx; 1386 Register scratch = ebx;
1387 1387
1388 // Check that the receiver isn't a smi. 1388 // Check that the receiver isn't a smi.
1389 __ JumpIfSmi(receiver, &miss); 1389 __ JumpIfSmi(receiver, &miss);
1390 1390
1391 // Check that the object is a JS array. 1391 // Check that the object is a JS array.
1392 __ CmpObjectType(receiver, JS_ARRAY_TYPE, scratch); 1392 __ CmpObjectType(receiver, JS_ARRAY_TYPE, scratch);
1393 __ j(not_equal, &miss); 1393 __ j(not_equal, &miss);
1394 1394
1395 // Check that elements are FixedArray. 1395 // Check that elements are FixedArray.
1396 // We rely on StoreIC_ArrayLength below to deal with all types of 1396 // We rely on StoreIC_ArrayLength below to deal with all types of
1397 // fast elements (including COW). 1397 // fast elements (including COW).
1398 __ mov(scratch, FieldOperand(receiver, JSArray::kElementsOffset)); 1398 __ mov(scratch, FieldOperand(receiver, JSArray::kElementsOffset));
1399 __ CmpObjectType(scratch, FIXED_ARRAY_TYPE, scratch); 1399 __ CmpObjectType(scratch, FIXED_ARRAY_TYPE, scratch);
1400 __ j(not_equal, &miss); 1400 __ j(not_equal, &miss);
1401 1401
1402 // Check that the array has fast properties, otherwise the length
1403 // property might have been redefined.
1404 __ mov(scratch, FieldOperand(receiver, JSArray::kPropertiesOffset));
1405 __ CompareRoot(FieldOperand(scratch, FixedArray::kMapOffset),
1406 Heap::kHashTableMapRootIndex);
1407 __ j(equal, &miss);
1408
1402 // Check that value is a smi. 1409 // Check that value is a smi.
1403 __ JumpIfNotSmi(value, &miss); 1410 __ JumpIfNotSmi(value, &miss);
1404 1411
1405 // Prepare tail call to StoreIC_ArrayLength. 1412 // Prepare tail call to StoreIC_ArrayLength.
1406 __ pop(scratch); 1413 __ pop(scratch);
1407 __ push(receiver); 1414 __ push(receiver);
1408 __ push(value); 1415 __ push(value);
1409 __ push(scratch); // return address 1416 __ push(scratch); // return address
1410 1417
1411 ExternalReference ref = 1418 ExternalReference ref =
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 Condition cc = *jmp_address == Assembler::kJncShortOpcode 1684 Condition cc = *jmp_address == Assembler::kJncShortOpcode
1678 ? not_zero 1685 ? not_zero
1679 : zero; 1686 : zero;
1680 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); 1687 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc);
1681 } 1688 }
1682 1689
1683 1690
1684 } } // namespace v8::internal 1691 } } // namespace v8::internal
1685 1692
1686 #endif // V8_TARGET_ARCH_IA32 1693 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/ic-arm.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698