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

Unified Diff: src/api.cc

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 | « src/api.h ('k') | src/assembler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
===================================================================
--- src/api.cc (revision 5685)
+++ src/api.cc (working copy)
@@ -457,19 +457,37 @@
// --- H a n d l e s ---
-HandleScope::HandleScope() : is_closed_(false) {
+HandleScope::HandleScope()
+ : prev_next_(i::HandleScope::current_.next),
+ prev_limit_(i::HandleScope::current_.limit),
+ is_closed_(false) {
API_ENTRY_CHECK("HandleScope::HandleScope");
- i::HandleScope::Enter(&previous_);
+ i::HandleScope::current_.level++;
}
HandleScope::~HandleScope() {
if (!is_closed_) {
- i::HandleScope::Leave(&previous_);
+ Leave();
}
}
+void HandleScope::Leave() {
+ i::HandleScope::current_.level--;
+ ASSERT(i::HandleScope::current_.level >= 0);
+ i::HandleScope::current_.next = prev_next_;
+ if (i::HandleScope::current_.limit != prev_limit_) {
+ i::HandleScope::current_.limit = prev_limit_;
+ i::HandleScope::DeleteExtensions();
+ }
+
+#ifdef DEBUG
+ i::HandleScope::ZapRange(prev_next_, prev_limit_);
+#endif
+}
+
+
int HandleScope::NumberOfHandles() {
return i::HandleScope::NumberOfHandles();
}
@@ -553,7 +571,7 @@
result = *value;
}
is_closed_ = true;
- i::HandleScope::Leave(&previous_);
+ Leave();
if (value == NULL) {
return NULL;
« no previous file with comments | « src/api.h ('k') | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698