| OLD | NEW |
| 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/allocation.h" | 5 #include "vm/allocation.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
| 9 #include "vm/thread.h" | 9 #include "vm/thread.h" |
| 10 #include "vm/zone.h" | 10 #include "vm/zone.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 static void* Allocate(uword size, Zone* zone) { | 14 static void* Allocate(uword size, Zone* zone) { |
| 15 ASSERT(zone != NULL); | 15 ASSERT(zone != NULL); |
| 16 if (size > static_cast<uword>(kIntptrMax)) { | 16 if (size > static_cast<uword>(kIntptrMax)) { |
| 17 FATAL1("ZoneAllocated object has unexpectedly large size %" Pu "", size); | 17 FATAL1("ZoneAllocated object has unexpectedly large size %" Pu "", size); |
| 18 } | 18 } |
| 19 return reinterpret_cast<void*>(zone->AllocUnsafe(size)); | 19 return reinterpret_cast<void*>(zone->AllocUnsafe(size)); |
| 20 } | 20 } |
| 21 | 21 |
| 22 | 22 |
| 23 void* ZoneAllocated::operator new(uword size) { | 23 void* ZoneAllocated::operator new(uword size) { |
| 24 return Allocate(size, Thread::Current()->zone()); | 24 return Allocate(size, Thread::Current()->zone()); |
| 25 } | 25 } |
| 26 | 26 |
| 27 | 27 |
| 28 void* ZoneAllocated::operator new(uword size, Zone* zone) { | 28 void* ZoneAllocated::operator new(uword size, Zone* zone) { |
| 29 ASSERT(zone == Thread::Current()->zone()); | 29 ASSERT(Thread::Current()->ZoneIsOwnedByThread(zone)); |
| 30 return Allocate(size, zone); | 30 return Allocate(size, zone); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 StackResource::~StackResource() { | 34 StackResource::~StackResource() { |
| 35 if (thread_ != NULL) { | 35 if (thread_ != NULL) { |
| 36 StackResource* top = thread_->top_resource(); | 36 StackResource* top = thread_->top_resource(); |
| 37 ASSERT(top == this); | 37 ASSERT(top == this); |
| 38 thread_->set_top_resource(previous_); | 38 thread_->set_top_resource(previous_); |
| 39 } | 39 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 thread()->IncrementNoSafepointScopeDepth(); | 80 thread()->IncrementNoSafepointScopeDepth(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 NoSafepointScope::~NoSafepointScope() { | 84 NoSafepointScope::~NoSafepointScope() { |
| 85 thread()->DecrementNoSafepointScopeDepth(); | 85 thread()->DecrementNoSafepointScopeDepth(); |
| 86 } | 86 } |
| 87 #endif // defined(DEBUG) | 87 #endif // defined(DEBUG) |
| 88 | 88 |
| 89 } // namespace dart | 89 } // namespace dart |
| OLD | NEW |