Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: src/api.h

Issue 3792003: Optimizing HandleScope. Also fixed HandleScope destruction when API getter th... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698