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

Side by Side Diff: runtime/vm/assembler_arm64.cc

Issue 1096063002: Fix array allocation overflow check on arm/arm64/mips. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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 | « runtime/vm/assembler_arm.cc ('k') | runtime/vm/assembler_mips.cc » ('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 (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // NOLINT 5 #include "vm/globals.h" // NOLINT
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 Register temp_reg, 1366 Register temp_reg,
1367 Register pp) { 1367 Register pp) {
1368 ASSERT(failure != NULL); 1368 ASSERT(failure != NULL);
1369 if (FLAG_inline_alloc) { 1369 if (FLAG_inline_alloc) {
1370 const intptr_t instance_size = cls.instance_size(); 1370 const intptr_t instance_size = cls.instance_size();
1371 Heap* heap = Isolate::Current()->heap(); 1371 Heap* heap = Isolate::Current()->heap();
1372 Heap::Space space = heap->SpaceForAllocation(cls.id()); 1372 Heap::Space space = heap->SpaceForAllocation(cls.id());
1373 const uword top_address = heap->TopAddress(space); 1373 const uword top_address = heap->TopAddress(space);
1374 LoadImmediate(temp_reg, top_address, pp); 1374 LoadImmediate(temp_reg, top_address, pp);
1375 ldr(instance_reg, Address(temp_reg)); 1375 ldr(instance_reg, Address(temp_reg));
1376 AddImmediate(instance_reg, instance_reg, instance_size, pp); 1376 // TODO(koda): Protect against unsigned overflow here.
1377 AddImmediateSetFlags(instance_reg, instance_reg, instance_size, pp);
1377 1378
1378 // instance_reg: potential next object start. 1379 // instance_reg: potential next object start.
1379 const uword end_address = heap->EndAddress(space); 1380 const uword end_address = heap->EndAddress(space);
1380 ASSERT(top_address < end_address); 1381 ASSERT(top_address < end_address);
1381 // Could use ldm to load (top, end), but no benefit seen experimentally. 1382 // Could use ldm to load (top, end), but no benefit seen experimentally.
1382 ldr(TMP, Address(temp_reg, end_address - top_address)); 1383 ldr(TMP, Address(temp_reg, end_address - top_address));
1383 CompareRegisters(TMP, instance_reg); 1384 CompareRegisters(TMP, instance_reg);
1384 // fail if heap end unsigned less than or equal to instance_reg. 1385 // fail if heap end unsigned less than or equal to instance_reg.
1385 b(failure, LS); 1386 b(failure, LS);
1386 1387
(...skipping 24 matching lines...) Expand all
1411 Register instance, 1412 Register instance,
1412 Register end_address, 1413 Register end_address,
1413 Register temp1, 1414 Register temp1,
1414 Register temp2) { 1415 Register temp2) {
1415 if (FLAG_inline_alloc) { 1416 if (FLAG_inline_alloc) {
1416 Isolate* isolate = Isolate::Current(); 1417 Isolate* isolate = Isolate::Current();
1417 Heap* heap = isolate->heap(); 1418 Heap* heap = isolate->heap();
1418 Heap::Space space = heap->SpaceForAllocation(cid); 1419 Heap::Space space = heap->SpaceForAllocation(cid);
1419 LoadImmediate(temp1, heap->TopAddress(space), PP); 1420 LoadImmediate(temp1, heap->TopAddress(space), PP);
1420 ldr(instance, Address(temp1, 0)); // Potential new object start. 1421 ldr(instance, Address(temp1, 0)); // Potential new object start.
1421 AddImmediate(end_address, instance, instance_size, PP); 1422 AddImmediateSetFlags(end_address, instance, instance_size, PP);
1422 b(failure, VS); 1423 b(failure, CS); // Fail on unsigned overflow.
1423 1424
1424 // Check if the allocation fits into the remaining space. 1425 // Check if the allocation fits into the remaining space.
1425 // instance: potential new object start. 1426 // instance: potential new object start.
1426 // end_address: potential next object start. 1427 // end_address: potential next object start.
1427 LoadImmediate(temp2, heap->EndAddress(space), PP); 1428 LoadImmediate(temp2, heap->EndAddress(space), PP);
1428 ldr(temp2, Address(temp2, 0)); 1429 ldr(temp2, Address(temp2, 0));
1429 cmp(end_address, Operand(temp2)); 1430 cmp(end_address, Operand(temp2));
1430 b(failure, CS); 1431 b(failure, CS);
1431 1432
1432 // Successfully allocated the object(s), now update top to point to 1433 // Successfully allocated the object(s), now update top to point to
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 add(base, array, Operand(index, LSL, shift)); 1486 add(base, array, Operand(index, LSL, shift));
1486 } 1487 }
1487 const OperandSize size = Address::OperandSizeFor(cid); 1488 const OperandSize size = Address::OperandSizeFor(cid);
1488 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size)); 1489 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size));
1489 return Address(base, offset, Address::Offset, size); 1490 return Address(base, offset, Address::Offset, size);
1490 } 1491 }
1491 1492
1492 } // namespace dart 1493 } // namespace dart
1493 1494
1494 #endif // defined TARGET_ARCH_ARM64 1495 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_arm.cc ('k') | runtime/vm/assembler_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698