| 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 inline void* ZoneAllocationPolicy::New(size_t size) { |
| 109 inline void* ZoneListAllocationPolicy::New(int size) { | 109 if (zone_) { |
| 110 return ZONE->New(size); | 110 return zone_->New(size); |
| 111 } else { |
| 112 return ZONE->New(size); |
| 113 } |
| 111 } | 114 } |
| 112 | 115 |
| 113 | 116 |
| 114 template <typename T> | 117 template <typename T> |
| 115 void* ZoneList<T>::operator new(size_t size) { | 118 void* ZoneList<T>::operator new(size_t size) { |
| 116 return ZONE->New(static_cast<int>(size)); | 119 return ZONE->New(static_cast<int>(size)); |
| 117 } | 120 } |
| 118 | 121 |
| 119 | 122 |
| 120 template <typename T> | 123 template <typename T> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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 |