Index: src/api.h |
=================================================================== |
--- src/api.h (revision 5685) |
+++ src/api.h (working copy) |
@@ -353,7 +353,7 @@ |
inline internal::Object** GetSpareOrNewBlock(); |
- inline void DeleteExtensions(int extensions); |
+ inline void DeleteExtensions(internal::Object** prev_limit); |
inline void IncrementCallDepth() {call_depth_++;} |
inline void DecrementCallDepth() {call_depth_--;} |
@@ -465,25 +465,28 @@ |
} |
-void HandleScopeImplementer::DeleteExtensions(int extensions) { |
- if (spare_ != NULL) { |
- DeleteArray(spare_); |
- spare_ = NULL; |
- } |
- for (int i = extensions; i > 1; --i) { |
- internal::Object** block = blocks_.RemoveLast(); |
+void HandleScopeImplementer::DeleteExtensions(internal::Object** prev_limit) { |
+ while (!blocks_.is_empty()) { |
+ internal::Object** block_start = blocks_.last(); |
+ internal::Object** block_limit = block_start + kHandleBlockSize; |
#ifdef DEBUG |
- v8::ImplementationUtilities::ZapHandleRange(block, |
- &block[kHandleBlockSize]); |
+ // NoHandleAllocation may make the prev_limit to point inside the block. |
+ if (block_start <= prev_limit && prev_limit <= block_limit) break; |
+#else |
+ if (prev_limit == block_limit) break; |
#endif |
- DeleteArray(block); |
- } |
- spare_ = blocks_.RemoveLast(); |
+ |
+ blocks_.RemoveLast(); |
#ifdef DEBUG |
- v8::ImplementationUtilities::ZapHandleRange( |
- spare_, |
- &spare_[kHandleBlockSize]); |
+ v8::ImplementationUtilities::ZapHandleRange(block_start, block_limit); |
#endif |
+ if (spare_ != NULL) { |
+ DeleteArray(spare_); |
+ } |
+ spare_ = block_start; |
+ } |
+ ASSERT((blocks_.is_empty() && prev_limit == NULL) || |
+ (!blocks_.is_empty() && prev_limit != NULL)); |
} |
} } // namespace v8::internal |