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

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

Issue 10917223: Guard against allocation top overflow in ObjectArray_Allocate intrinsic. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove debugging changes Created 8 years, 3 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/intrinsifier_ia32.cc ('k') | 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intrinsifier.h" 8 #include "vm/intrinsifier.h"
9 9
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 __ cmpq(RDI, max_len); 50 __ cmpq(RDI, max_len);
51 __ j(GREATER, &fall_through); 51 __ j(GREATER, &fall_through);
52 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; 52 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
53 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi. 53 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi.
54 ASSERT(kSmiTagShift == 1); 54 ASSERT(kSmiTagShift == 1);
55 __ andq(RDI, Immediate(-kObjectAlignment)); 55 __ andq(RDI, Immediate(-kObjectAlignment));
56 56
57 Isolate* isolate = Isolate::Current(); 57 Isolate* isolate = Isolate::Current();
58 Heap* heap = isolate->heap(); 58 Heap* heap = isolate->heap();
59 59
60 // RDI: allocation size.
61 __ movq(RAX, Immediate(heap->TopAddress())); 60 __ movq(RAX, Immediate(heap->TopAddress()));
62 __ movq(RAX, Address(RAX, 0)); 61 __ movq(RAX, Address(RAX, 0));
63 __ leaq(RCX, Address(RAX, RDI, TIMES_1, 0)); 62
63 // RDI: allocation size.
64 __ movq(RCX, RAX);
65 __ addq(RCX, RDI);
66 __ j(CARRY, &fall_through);
64 67
65 // Check if the allocation fits into the remaining space. 68 // Check if the allocation fits into the remaining space.
66 // RAX: potential new object start. 69 // RAX: potential new object start.
67 // RCX: potential next object start. 70 // RCX: potential next object start.
68 // RDI: allocation size. 71 // RDI: allocation size.
69 __ movq(R13, Immediate(heap->EndAddress())); 72 __ movq(R13, Immediate(heap->EndAddress()));
70 __ cmpq(RCX, Address(R13, 0)); 73 __ cmpq(RCX, Address(R13, 0));
71 __ j(ABOVE_EQUAL, &fall_through); 74 __ j(ABOVE_EQUAL, &fall_through);
72 75
73 // Successfully allocated the object(s), now update top to point to 76 // Successfully allocated the object(s), now update top to point to
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 __ LoadObject(RAX, bool_true); 1381 __ LoadObject(RAX, bool_true);
1379 __ ret(); 1382 __ ret();
1380 return true; 1383 return true;
1381 } 1384 }
1382 1385
1383 #undef __ 1386 #undef __
1384 1387
1385 } // namespace dart 1388 } // namespace dart
1386 1389
1387 #endif // defined TARGET_ARCH_X64 1390 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698