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

Side by Side Diff: runtime/vm/intrinsifier_ia32.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/constants_x64.h ('k') | runtime/vm/intrinsifier_x64.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) 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 // The intrinsic code below is executed before a method has built its frame. 5 // The intrinsic code below is executed before a method has built its frame.
6 // The return address is on the stack and the arguments below it. 6 // The return address is on the stack and the arguments below it.
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved.
8 // Each intrinsification method returns true if the corresponding 8 // Each intrinsification method returns true if the corresponding
9 // Dart method was intrinsified. 9 // Dart method was intrinsified.
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 __ cmpl(EDI, max_len); 51 __ cmpl(EDI, max_len);
52 __ j(GREATER, &fall_through); 52 __ j(GREATER, &fall_through);
53 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; 53 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
54 __ leal(EDI, Address(EDI, TIMES_2, fixed_size)); // EDI is a Smi. 54 __ leal(EDI, Address(EDI, TIMES_2, fixed_size)); // EDI is a Smi.
55 ASSERT(kSmiTagShift == 1); 55 ASSERT(kSmiTagShift == 1);
56 __ andl(EDI, Immediate(-kObjectAlignment)); 56 __ andl(EDI, Immediate(-kObjectAlignment));
57 57
58 Isolate* isolate = Isolate::Current(); 58 Isolate* isolate = Isolate::Current();
59 Heap* heap = isolate->heap(); 59 Heap* heap = isolate->heap();
60 60
61 __ movl(EAX, Address::Absolute(heap->TopAddress()));
62 __ movl(EBX, EAX);
63
61 // EDI: allocation size. 64 // EDI: allocation size.
62 __ movl(EAX, Address::Absolute(heap->TopAddress())); 65 __ addl(EBX, EDI);
63 __ leal(EBX, Address(EAX, EDI, TIMES_1, 0)); 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 // EAX: potential new object start. 69 // EAX: potential new object start.
67 // EBX: potential next object start. 70 // EBX: potential next object start.
68 // EDI: allocation size. 71 // EDI: allocation size.
69 __ cmpl(EBX, Address::Absolute(heap->EndAddress())); 72 __ cmpl(EBX, Address::Absolute(heap->EndAddress()));
70 __ j(ABOVE_EQUAL, &fall_through); 73 __ j(ABOVE_EQUAL, &fall_through);
71 74
72 // Successfully allocated the object(s), now update top to point to 75 // Successfully allocated the object(s), now update top to point to
73 // next object start and initialize the object. 76 // next object start and initialize the object.
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 __ Bind(&is_true); 1426 __ Bind(&is_true);
1424 __ LoadObject(EAX, bool_true); 1427 __ LoadObject(EAX, bool_true);
1425 __ ret(); 1428 __ ret();
1426 return true; 1429 return true;
1427 } 1430 }
1428 1431
1429 #undef __ 1432 #undef __
1430 } // namespace dart 1433 } // namespace dart
1431 1434
1432 #endif // defined TARGET_ARCH_IA32 1435 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/constants_x64.h ('k') | runtime/vm/intrinsifier_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698