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

Unified Diff: src/handles.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 | « src/assembler.cc ('k') | src/handles.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/handles.h
===================================================================
--- src/handles.h (revision 5685)
+++ src/handles.h (working copy)
@@ -107,12 +107,20 @@
// for which the handle scope has been deleted is undefined.
class HandleScope {
public:
- HandleScope() : previous_(current_) {
- current_.extensions = 0;
+ HandleScope() : prev_next_(current_.next), prev_limit_(current_.limit) {
+ current_.level++;
}
~HandleScope() {
- Leave(&previous_);
+ current_.next = prev_next_;
+ current_.level--;
+ if (current_.limit != prev_limit_) {
+ current_.limit = prev_limit_;
+ DeleteExtensions();
+ }
+#ifdef DEBUG
+ ZapRange(prev_next_, prev_limit_);
+#endif
}
// Counts the number of allocated handles.
@@ -136,9 +144,9 @@
// Deallocates any extensions used by the current scope.
static void DeleteExtensions();
- static Address current_extensions_address();
static Address current_next_address();
static Address current_limit_address();
+ static Address current_level_address();
private:
// Prevent heap allocation or illegal handle scopes.
@@ -148,28 +156,9 @@
void operator delete(void* size_t);
static v8::ImplementationUtilities::HandleScopeData current_;
- const v8::ImplementationUtilities::HandleScopeData previous_;
+ Object** const prev_next_;
+ Object** const prev_limit_;
- // Pushes a fresh handle scope to be used when allocating new handles.
- static void Enter(
- v8::ImplementationUtilities::HandleScopeData* previous) {
- *previous = current_;
- current_.extensions = 0;
- }
-
- // Re-establishes the previous scope state. Should be called only
- // once, and only for the current scope.
- static void Leave(
- const v8::ImplementationUtilities::HandleScopeData* previous) {
- if (current_.extensions > 0) {
- DeleteExtensions();
- }
- current_ = *previous;
-#ifdef DEBUG
- ZapRange(current_.next, current_.limit);
-#endif
- }
-
// Extend the handle scope making room for more handles.
static internal::Object** Extend();
@@ -362,7 +351,7 @@
inline NoHandleAllocation();
inline ~NoHandleAllocation();
private:
- int extensions_;
+ int level_;
#endif
};
« no previous file with comments | « src/assembler.cc ('k') | src/handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698