| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 segment_bytes_allocated_ += delta; | 79 segment_bytes_allocated_ += delta; |
| 80 isolate_->counters()->zone_segment_bytes()->Set(segment_bytes_allocated_); | 80 isolate_->counters()->zone_segment_bytes()->Set(segment_bytes_allocated_); |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 template <typename Config> | 84 template <typename Config> |
| 85 ZoneSplayTree<Config>::~ZoneSplayTree() { | 85 ZoneSplayTree<Config>::~ZoneSplayTree() { |
| 86 // Reset the root to avoid unneeded iteration over all tree nodes | 86 // Reset the root to avoid unneeded iteration over all tree nodes |
| 87 // in the destructor. For a zone-allocated tree, nodes will be | 87 // in the destructor. For a zone-allocated tree, nodes will be |
| 88 // freed by the Zone. | 88 // freed by the Zone. |
| 89 SplayTree<Config, ZoneListAllocationPolicy>::ResetRoot(); | 89 SplayTree<Config, ZoneListAllocator>::ResetRoot(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 // TODO(isolates): for performance reasons, this should be replaced with a new | 93 // TODO(isolates): for performance reasons, this should be replaced with a new |
| 94 // operator that takes the zone in which the object should be | 94 // operator that takes the zone in which the object should be |
| 95 // allocated. | 95 // allocated. |
| 96 void* ZoneObject::operator new(size_t size) { | 96 void* ZoneObject::operator new(size_t size) { |
| 97 return ZONE->New(static_cast<int>(size)); | 97 return ZONE->New(static_cast<int>(size)); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void* ZoneObject::operator new(size_t size, Zone* zone) { | 100 void* ZoneObject::operator new(size_t size, Zone* zone) { |
| 101 return zone->New(static_cast<int>(size)); | 101 return zone->New(static_cast<int>(size)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 | 104 |
| 105 inline void* ZoneListAllocationPolicy::New(int size) { | 105 inline void* ZoneListAllocator::New(int size) { |
| 106 return ZONE->New(size); | 106 return ZONE->New(size); |
| 107 } | 107 } |
| 108 | 108 |
| 109 | 109 |
| 110 template <typename T> | 110 template <typename T> |
| 111 void* ZoneList<T>::operator new(size_t size) { | |
| 112 return ZONE->New(static_cast<int>(size)); | |
| 113 } | |
| 114 | |
| 115 | |
| 116 template <typename T> | |
| 117 void* ZoneList<T>::operator new(size_t size, Zone* zone) { | 111 void* ZoneList<T>::operator new(size_t size, Zone* zone) { |
| 118 return zone->New(static_cast<int>(size)); | 112 return zone->New(static_cast<int>(size)); |
| 119 } | 113 } |
| 120 | 114 |
| 121 | 115 |
| 116 template<typename T> |
| 117 ZoneList<T>* ZoneList<T>::New(Zone* zone, int capacity) { |
| 118 return new(zone) ZoneList(zone, capacity); |
| 119 } |
| 120 |
| 121 |
| 122 ZoneScope::ZoneScope(Isolate* isolate, ZoneScopeMode mode) | 122 ZoneScope::ZoneScope(Isolate* isolate, ZoneScopeMode mode) |
| 123 : isolate_(isolate), mode_(mode) { | 123 : isolate_(isolate), mode_(mode) { |
| 124 isolate_->zone()->scope_nesting_++; | 124 isolate_->zone()->scope_nesting_++; |
| 125 } | 125 } |
| 126 | 126 |
| 127 | 127 |
| 128 bool ZoneScope::ShouldDeleteOnExit() { | 128 bool ZoneScope::ShouldDeleteOnExit() { |
| 129 return isolate_->zone()->scope_nesting_ == 1 && mode_ == DELETE_ON_EXIT; | 129 return isolate_->zone()->scope_nesting_ == 1 && mode_ == DELETE_ON_EXIT; |
| 130 } | 130 } |
| 131 | 131 |
| 132 | 132 |
| 133 int ZoneScope::nesting() { | 133 int ZoneScope::nesting() { |
| 134 return Isolate::Current()->zone()->scope_nesting_; | 134 return Isolate::Current()->zone()->scope_nesting_; |
| 135 } | 135 } |
| 136 | 136 |
| 137 | 137 |
| 138 } } // namespace v8::internal | 138 } } // namespace v8::internal |
| 139 | 139 |
| 140 #endif // V8_ZONE_INL_H_ | 140 #endif // V8_ZONE_INL_H_ |
| OLD | NEW |