Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 segment_bytes_allocated_ += delta; | 83 segment_bytes_allocated_ += delta; |
| 84 isolate_->counters()->zone_segment_bytes()->Set(segment_bytes_allocated_); | 84 isolate_->counters()->zone_segment_bytes()->Set(segment_bytes_allocated_); |
| 85 } | 85 } |
| 86 | 86 |
| 87 | 87 |
| 88 template <typename Config> | 88 template <typename Config> |
| 89 ZoneSplayTree<Config>::~ZoneSplayTree() { | 89 ZoneSplayTree<Config>::~ZoneSplayTree() { |
| 90 // Reset the root to avoid unneeded iteration over all tree nodes | 90 // Reset the root to avoid unneeded iteration over all tree nodes |
| 91 // in the destructor. For a zone-allocated tree, nodes will be | 91 // in the destructor. For a zone-allocated tree, nodes will be |
| 92 // freed by the Zone. | 92 // freed by the Zone. |
| 93 SplayTree<Config, ZoneListAllocationPolicy>::ResetRoot(); | 93 SplayTree<Config, ZoneAllocationPolicy>::ResetRoot(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 | 96 |
| 97 // TODO(isolates): for performance reasons, this should be replaced with a new | 97 // TODO(isolates): for performance reasons, this should be replaced with a new |
| 98 // operator that takes the zone in which the object should be | 98 // operator that takes the zone in which the object should be |
| 99 // allocated. | 99 // allocated. |
| 100 void* ZoneObject::operator new(size_t size) { | 100 void* ZoneObject::operator new(size_t size) { |
| 101 return ZONE->New(static_cast<int>(size)); | 101 return ZONE->New(static_cast<int>(size)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void* ZoneObject::operator new(size_t size, Zone* zone) { | 104 void* ZoneObject::operator new(size_t size, Zone* zone) { |
| 105 return zone->New(static_cast<int>(size)); | 105 return zone->New(static_cast<int>(size)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 | 108 |
| 109 inline void* ZoneListAllocationPolicy::New(int size) { | 109 void* ZoneAllocator::New(int size) { |
| 110 return ZONE->New(size); | 110 return ZONE->New(size); |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 template <typename T> | 114 // The ZoneAllocator is used to specialize the List implementation to |
| 115 void* ZoneList<T>::operator new(size_t size) { | 115 // allocate ZoneLists and their elements in the current Zone. |
|
danno
2012/05/25 11:03:37
Does the comment apply to the following code? I'm
| |
| 116 return ZONE->New(static_cast<int>(size)); | |
| 117 } | |
| 118 | |
| 119 | |
| 120 template <typename T> | 116 template <typename T> |
| 121 void* ZoneList<T>::operator new(size_t size, Zone* zone) { | 117 void* ZoneList<T>::operator new(size_t size, Zone* zone) { |
| 122 return zone->New(static_cast<int>(size)); | 118 return zone->New(static_cast<int>(size)); |
| 123 } | 119 } |
| 124 | 120 |
| 125 | 121 |
| 122 // De-allocation attempts are silently ignored. | |
|
danno
2012/05/25 11:03:37
This comment seems unrelated?
| |
| 123 template<typename T> | |
| 124 void* ZoneList<T>::operator new(size_t size) { | |
| 125 return List<T, ZoneAllocationPolicy>::operator new(size); | |
|
danno
2012/05/25 11:03:37
Why did you move this function? And why does it n
| |
| 126 } | |
| 127 | |
| 128 | |
| 126 ZoneScope::ZoneScope(Isolate* isolate, ZoneScopeMode mode) | 129 ZoneScope::ZoneScope(Isolate* isolate, ZoneScopeMode mode) |
| 127 : isolate_(isolate), mode_(mode) { | 130 : isolate_(isolate), mode_(mode) { |
| 128 isolate_->zone()->scope_nesting_++; | 131 isolate_->zone()->scope_nesting_++; |
| 129 } | 132 } |
| 130 | 133 |
| 131 | 134 |
| 132 bool ZoneScope::ShouldDeleteOnExit() { | 135 bool ZoneScope::ShouldDeleteOnExit() { |
| 133 return isolate_->zone()->scope_nesting_ == 1 && mode_ == DELETE_ON_EXIT; | 136 return isolate_->zone()->scope_nesting_ == 1 && mode_ == DELETE_ON_EXIT; |
| 134 } | 137 } |
| 135 | 138 |
| 136 | 139 |
| 137 int ZoneScope::nesting() { | 140 int ZoneScope::nesting() { |
| 138 return Isolate::Current()->zone()->scope_nesting_; | 141 return Isolate::Current()->zone()->scope_nesting_; |
| 139 } | 142 } |
| 140 | 143 |
| 141 | 144 |
| 142 } } // namespace v8::internal | 145 } } // namespace v8::internal |
| 143 | 146 |
| 144 #endif // V8_ZONE_INL_H_ | 147 #endif // V8_ZONE_INL_H_ |
| OLD | NEW |