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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, ZoneAllocationPolicy>::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 | |
98 // operator that takes the zone in which the object should be | |
99 // allocated. | |
100 void* ZoneObject::operator new(size_t size) { | |
101 return ZONE->New(static_cast<int>(size)); | |
102 } | |
103 | |
104 void* ZoneObject::operator new(size_t size, Zone* zone) { | 97 void* ZoneObject::operator new(size_t size, Zone* zone) { |
105 return zone->New(static_cast<int>(size)); | 98 return zone->New(static_cast<int>(size)); |
106 } | 99 } |
107 | 100 |
108 inline void* ZoneAllocationPolicy::New(size_t size) { | 101 inline void* ZoneAllocationPolicy::New(size_t size) { |
109 if (zone_) { | 102 ASSERT(zone_); |
110 return zone_->New(size); | 103 return zone_->New(size); |
111 } else { | |
112 return ZONE->New(size); | |
113 } | |
114 } | 104 } |
115 | 105 |
116 | 106 |
117 template <typename T> | |
118 void* ZoneList<T>::operator new(size_t size) { | |
119 return ZONE->New(static_cast<int>(size)); | |
120 } | |
121 | |
122 | |
123 template <typename T> | 107 template <typename T> |
124 void* ZoneList<T>::operator new(size_t size, Zone* zone) { | 108 void* ZoneList<T>::operator new(size_t size, Zone* zone) { |
125 return zone->New(static_cast<int>(size)); | 109 return zone->New(static_cast<int>(size)); |
126 } | 110 } |
127 | 111 |
128 | 112 |
129 ZoneScope::ZoneScope(Isolate* isolate, ZoneScopeMode mode) | 113 ZoneScope::ZoneScope(Isolate* isolate, ZoneScopeMode mode) |
130 : isolate_(isolate), mode_(mode) { | 114 : isolate_(isolate), mode_(mode) { |
131 isolate_->zone()->scope_nesting_++; | 115 isolate_->zone()->scope_nesting_++; |
132 } | 116 } |
133 | 117 |
134 | 118 |
135 bool ZoneScope::ShouldDeleteOnExit() { | 119 bool ZoneScope::ShouldDeleteOnExit() { |
136 return isolate_->zone()->scope_nesting_ == 1 && mode_ == DELETE_ON_EXIT; | 120 return isolate_->zone()->scope_nesting_ == 1 && mode_ == DELETE_ON_EXIT; |
137 } | 121 } |
138 | 122 |
139 | 123 |
140 int ZoneScope::nesting() { | 124 int ZoneScope::nesting() { |
141 return Isolate::Current()->zone()->scope_nesting_; | 125 return Isolate::Current()->zone()->scope_nesting_; |
142 } | 126 } |
143 | 127 |
144 | 128 |
145 } } // namespace v8::internal | 129 } } // namespace v8::internal |
146 | 130 |
147 #endif // V8_ZONE_INL_H_ | 131 #endif // V8_ZONE_INL_H_ |
OLD | NEW |