OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 current->next = cur + 1; | 142 current->next = cur + 1; |
143 | 143 |
144 T** result = reinterpret_cast<T**>(cur); | 144 T** result = reinterpret_cast<T**>(cur); |
145 *result = value; | 145 *result = value; |
146 return result; | 146 return result; |
147 } | 147 } |
148 | 148 |
149 | 149 |
150 #ifdef DEBUG | 150 #ifdef DEBUG |
151 inline NoHandleAllocation::NoHandleAllocation() { | 151 inline NoHandleAllocation::NoHandleAllocation() { |
| 152 Isolate* isolate = Isolate::Current(); |
152 v8::ImplementationUtilities::HandleScopeData* current = | 153 v8::ImplementationUtilities::HandleScopeData* current = |
153 Isolate::Current()->handle_scope_data(); | 154 isolate->handle_scope_data(); |
154 | 155 |
155 // Shrink the current handle scope to make it impossible to do | 156 active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); |
156 // handle allocations without an explicit handle scope. | 157 if (active_) { |
157 current->limit = current->next; | 158 // Shrink the current handle scope to make it impossible to do |
| 159 // handle allocations without an explicit handle scope. |
| 160 current->limit = current->next; |
158 | 161 |
159 level_ = current->level; | 162 level_ = current->level; |
160 current->level = 0; | 163 current->level = 0; |
| 164 } |
161 } | 165 } |
162 | 166 |
163 | 167 |
164 inline NoHandleAllocation::~NoHandleAllocation() { | 168 inline NoHandleAllocation::~NoHandleAllocation() { |
165 // Restore state in current handle scope to re-enable handle | 169 if (active_) { |
166 // allocations. | 170 // Restore state in current handle scope to re-enable handle |
167 v8::ImplementationUtilities::HandleScopeData* data = | 171 // allocations. |
168 Isolate::Current()->handle_scope_data(); | 172 v8::ImplementationUtilities::HandleScopeData* data = |
169 ASSERT_EQ(0, data->level); | 173 Isolate::Current()->handle_scope_data(); |
170 data->level = level_; | 174 ASSERT_EQ(0, data->level); |
| 175 data->level = level_; |
| 176 } |
171 } | 177 } |
172 #endif | 178 #endif |
173 | 179 |
174 | 180 |
175 } } // namespace v8::internal | 181 } } // namespace v8::internal |
176 | 182 |
177 #endif // V8_HANDLES_INL_H_ | 183 #endif // V8_HANDLES_INL_H_ |
OLD | NEW |