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

Unified Diff: runtime/vm/assembler.cc

Issue 10836061: Change the zone allocation api. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/assembler.h ('k') | runtime/vm/bigint_operations_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/assembler.cc
===================================================================
--- runtime/vm/assembler.cc (revision 10253)
+++ runtime/vm/assembler.cc (working copy)
@@ -13,9 +13,9 @@
namespace dart {
-static uword NewContents(int capacity) {
+static uword NewContents(intptr_t capacity) {
Zone* zone = Isolate::Current()->current_zone();
- uword result = zone->Allocate(capacity);
+ uword result = zone->AllocUnsafe(capacity);
#if defined(DEBUG)
// Initialize the buffer with kBreakPointInstruction to force a break
// point if we ever execute an uninitialized part of the code buffer.
@@ -48,7 +48,7 @@
buffer_->has_ensured_capacity_ = false;
// Make sure the generated instruction doesn't take up more
// space than the minimum gap.
- int delta = gap_ - ComputeGap();
+ intptr_t delta = gap_ - ComputeGap();
ASSERT(delta <= kMinimumGap);
}
#endif
@@ -56,7 +56,7 @@
AssemblerBuffer::AssemblerBuffer()
: pointer_offsets_(new ZoneGrowableArray<int>(16)) {
- static const int kInitialBufferCapacity = 4 * KB;
+ static const intptr_t kInitialBufferCapacity = 4 * KB;
contents_ = NewContents(kInitialBufferCapacity);
cursor_ = contents_;
limit_ = ComputeLimit(contents_, kInitialBufferCapacity);
@@ -99,9 +99,13 @@
void AssemblerBuffer::ExtendCapacity() {
- int old_size = Size();
- int old_capacity = Capacity();
- int new_capacity = Utils::Minimum(old_capacity * 2, old_capacity + 1 * MB);
+ intptr_t old_size = Size();
+ intptr_t old_capacity = Capacity();
+ intptr_t new_capacity =
+ Utils::Minimum(old_capacity * 2, old_capacity + 1 * MB);
+ if (new_capacity < old_capacity) {
+ FATAL("Unexpected overflow in AssemblerBuffer::ExtendCapacity");
+ }
// Allocate the new data area and copy contents of the old one to it.
uword new_contents = NewContents(new_capacity);
« no previous file with comments | « runtime/vm/assembler.h ('k') | runtime/vm/bigint_operations_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698