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

Side by Side Diff: src/handles.h

Issue 49001: Inline the fast path for handle creation.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/handles.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 ~HandleScope() { 113 ~HandleScope() {
114 Leave(&previous_); 114 Leave(&previous_);
115 } 115 }
116 116
117 // Counts the number of allocated handles. 117 // Counts the number of allocated handles.
118 static int NumberOfHandles(); 118 static int NumberOfHandles();
119 119
120 // Creates a new handle with the given value. 120 // Creates a new handle with the given value.
121 static void** CreateHandle(void* value); 121 static inline void** CreateHandle(void* value) {
122 void** result = current_.next;
123 if (result == current_.limit) result = Extend();
124 // Update the current next field, set the value in the created
125 // handle, and return the result.
126 ASSERT(result < current_.limit);
127 current_.next = result + 1;
128 *result = value;
129 return result;
130 }
122 131
123 private: 132 private:
124 // Prevent heap allocation or illegal handle scopes. 133 // Prevent heap allocation or illegal handle scopes.
125 HandleScope(const HandleScope&); 134 HandleScope(const HandleScope&);
126 void operator=(const HandleScope&); 135 void operator=(const HandleScope&);
127 void* operator new(size_t size); 136 void* operator new(size_t size);
128 void operator delete(void* size_t); 137 void operator delete(void* size_t);
129 138
130 static v8::ImplementationUtilities::HandleScopeData current_; 139 static v8::ImplementationUtilities::HandleScopeData current_;
131 const v8::ImplementationUtilities::HandleScopeData previous_; 140 const v8::ImplementationUtilities::HandleScopeData previous_;
(...skipping 11 matching lines...) Expand all
143 const v8::ImplementationUtilities::HandleScopeData* previous) { 152 const v8::ImplementationUtilities::HandleScopeData* previous) {
144 if (current_.extensions > 0) { 153 if (current_.extensions > 0) {
145 DeleteExtensions(); 154 DeleteExtensions();
146 } 155 }
147 current_ = *previous; 156 current_ = *previous;
148 #ifdef DEBUG 157 #ifdef DEBUG
149 ZapRange(current_.next, current_.limit); 158 ZapRange(current_.next, current_.limit);
150 #endif 159 #endif
151 } 160 }
152 161
162 // Extend the handle scope making room for more handles.
163 static void** Extend();
164
153 // Deallocates any extensions used by the current scope. 165 // Deallocates any extensions used by the current scope.
154 static void DeleteExtensions(); 166 static void DeleteExtensions();
155 167
156 // Zaps the handles in the half-open interval [start, end). 168 // Zaps the handles in the half-open interval [start, end).
157 static void ZapRange(void** start, void** end); 169 static void ZapRange(void** start, void** end);
158 170
159 friend class v8::HandleScope; 171 friend class v8::HandleScope;
160 friend class v8::ImplementationUtilities; 172 friend class v8::ImplementationUtilities;
161 }; 173 };
162 174
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 private: 327 private:
316 bool has_been_transformed_; // Tells whether the object has been transformed. 328 bool has_been_transformed_; // Tells whether the object has been transformed.
317 int unused_property_fields_; // Captures the unused number of field. 329 int unused_property_fields_; // Captures the unused number of field.
318 Handle<JSObject> object_; // The object being optimized. 330 Handle<JSObject> object_; // The object being optimized.
319 }; 331 };
320 332
321 333
322 } } // namespace v8::internal 334 } } // namespace v8::internal
323 335
324 #endif // V8_HANDLES_H_ 336 #endif // V8_HANDLES_H_
OLDNEW
« no previous file with comments | « no previous file | src/handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698