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 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 | 5 |
6 #ifndef V8_HANDLES_INL_H_ | 6 #ifndef V8_HANDLES_INL_H_ |
7 #define V8_HANDLES_INL_H_ | 7 #define V8_HANDLES_INL_H_ |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/handles.h" | 10 #include "src/handles.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 HandleScope::HandleScope(Isolate* isolate) { | 85 HandleScope::HandleScope(Isolate* isolate) { |
86 HandleScopeData* current = isolate->handle_scope_data(); | 86 HandleScopeData* current = isolate->handle_scope_data(); |
87 isolate_ = isolate; | 87 isolate_ = isolate; |
88 prev_next_ = current->next; | 88 prev_next_ = current->next; |
89 prev_limit_ = current->limit; | 89 prev_limit_ = current->limit; |
90 current->level++; | 90 current->level++; |
91 } | 91 } |
92 | 92 |
93 | 93 |
94 HandleScope::~HandleScope() { | 94 HandleScope::~HandleScope() { |
95 #ifdef DEBUG | 95 CloseScope(isolate_, prev_next_, prev_limit_); |
96 if (FLAG_check_handle_count) { | |
97 int before = NumberOfHandles(isolate_); | |
98 CloseScope(isolate_, prev_next_, prev_limit_); | |
99 int after = NumberOfHandles(isolate_); | |
100 DCHECK(after - before < kCheckHandleThreshold); | |
101 DCHECK(before < kCheckHandleThreshold); | |
102 } else { | |
103 #endif // DEBUG | |
104 CloseScope(isolate_, prev_next_, prev_limit_); | |
105 #ifdef DEBUG | |
106 } | |
107 #endif // DEBUG | |
108 } | 96 } |
109 | 97 |
110 | 98 |
111 void HandleScope::CloseScope(Isolate* isolate, | 99 void HandleScope::CloseScope(Isolate* isolate, |
112 Object** prev_next, | 100 Object** prev_next, |
113 Object** prev_limit) { | 101 Object** prev_limit) { |
114 HandleScopeData* current = isolate->handle_scope_data(); | 102 HandleScopeData* current = isolate->handle_scope_data(); |
115 | 103 |
116 std::swap(current->next, prev_next); | 104 std::swap(current->next, prev_next); |
117 current->level--; | 105 current->level--; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 current->level = level_; | 174 current->level = level_; |
187 DCHECK_EQ(current->next, current->limit); | 175 DCHECK_EQ(current->next, current->limit); |
188 current->limit = limit_; | 176 current->limit = limit_; |
189 } | 177 } |
190 | 178 |
191 #endif | 179 #endif |
192 | 180 |
193 } } // namespace v8::internal | 181 } } // namespace v8::internal |
194 | 182 |
195 #endif // V8_HANDLES_INL_H_ | 183 #endif // V8_HANDLES_INL_H_ |
OLD | NEW |