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

Side by Side Diff: src/handles.h

Issue 12300018: Made Isolate a mandatory parameter for everything Handle-related. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed CreateCode calls. Be nicer to MIPS. Created 7 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 | « src/frames.h ('k') | 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // garbage collector will no longer track the object stored in the 117 // garbage collector will no longer track the object stored in the
118 // handle and may deallocate it. The behavior of accessing a handle 118 // handle and may deallocate it. The behavior of accessing a handle
119 // for which the handle scope has been deleted is undefined. 119 // for which the handle scope has been deleted is undefined.
120 class HandleScope { 120 class HandleScope {
121 public: 121 public:
122 explicit inline HandleScope(Isolate* isolate); 122 explicit inline HandleScope(Isolate* isolate);
123 123
124 inline ~HandleScope(); 124 inline ~HandleScope();
125 125
126 // Counts the number of allocated handles. 126 // Counts the number of allocated handles.
127 static int NumberOfHandles(); 127 static int NumberOfHandles(Isolate* isolate);
128 128
129 // Creates a new handle with the given value. 129 // Creates a new handle with the given value.
130 template <typename T> 130 template <typename T>
131 static inline T** CreateHandle(T* value, Isolate* isolate); 131 static inline T** CreateHandle(Isolate* isolate, T* value);
132 132
133 // Deallocates any extensions used by the current scope. 133 // Deallocates any extensions used by the current scope.
134 static void DeleteExtensions(Isolate* isolate); 134 static void DeleteExtensions(Isolate* isolate);
135 135
136 static Address current_next_address(); 136 static Address current_next_address(Isolate* isolate);
137 static Address current_limit_address(); 137 static Address current_limit_address(Isolate* isolate);
138 static Address current_level_address(); 138 static Address current_level_address(Isolate* isolate);
139 139
140 // Closes the HandleScope (invalidating all handles 140 // Closes the HandleScope (invalidating all handles
141 // created in the scope of the HandleScope) and returns 141 // created in the scope of the HandleScope) and returns
142 // a Handle backed by the parent scope holding the 142 // a Handle backed by the parent scope holding the
143 // value of the argument handle. 143 // value of the argument handle.
144 template <typename T> 144 template <typename T>
145 Handle<T> CloseAndEscape(Handle<T> handle_value); 145 Handle<T> CloseAndEscape(Handle<T> handle_value);
146 146
147 Isolate* isolate() { return isolate_; } 147 Isolate* isolate() { return isolate_; }
148 148
149 private: 149 private:
150 // Prevent heap allocation or illegal handle scopes. 150 // Prevent heap allocation or illegal handle scopes.
151 HandleScope(const HandleScope&); 151 HandleScope(const HandleScope&);
152 void operator=(const HandleScope&); 152 void operator=(const HandleScope&);
153 void* operator new(size_t size); 153 void* operator new(size_t size);
154 void operator delete(void* size_t); 154 void operator delete(void* size_t);
155 155
156 inline void CloseScope(); 156 inline void CloseScope();
157 157
158 Isolate* isolate_; 158 Isolate* isolate_;
159 Object** prev_next_; 159 Object** prev_next_;
160 Object** prev_limit_; 160 Object** prev_limit_;
161 161
162 // Extend the handle scope making room for more handles. 162 // Extend the handle scope making room for more handles.
163 static internal::Object** Extend(); 163 static internal::Object** Extend(Isolate* isolate);
164 164
165 // Zaps the handles in the half-open interval [start, end). 165 // Zaps the handles in the half-open interval [start, end).
166 static void ZapRange(internal::Object** start, internal::Object** end); 166 static void ZapRange(internal::Object** start, internal::Object** end);
167 167
168 friend class v8::internal::DeferredHandles; 168 friend class v8::internal::DeferredHandles;
169 friend class v8::HandleScope; 169 friend class v8::HandleScope;
170 friend class v8::internal::HandleScopeImplementer; 170 friend class v8::internal::HandleScopeImplementer;
171 friend class v8::ImplementationUtilities; 171 friend class v8::ImplementationUtilities;
172 friend class v8::internal::Isolate; 172 friend class v8::internal::Isolate;
173 }; 173 };
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 Handle<Object> key, 223 Handle<Object> key,
224 Handle<Object> value, 224 Handle<Object> value,
225 PropertyAttributes attributes); 225 PropertyAttributes attributes);
226 226
227 Handle<Object> ForceDeleteProperty(Handle<JSObject> object, 227 Handle<Object> ForceDeleteProperty(Handle<JSObject> object,
228 Handle<Object> key); 228 Handle<Object> key);
229 229
230 Handle<Object> GetProperty(Handle<JSReceiver> obj, 230 Handle<Object> GetProperty(Handle<JSReceiver> obj,
231 const char* name); 231 const char* name);
232 232
233 Handle<Object> GetProperty(Handle<Object> obj, 233 Handle<Object> GetProperty(Isolate* isolate,
234 Handle<Object> obj,
234 Handle<Object> key); 235 Handle<Object> key);
235 236
236 Handle<Object> GetPropertyWithInterceptor(Handle<JSObject> receiver, 237 Handle<Object> GetPropertyWithInterceptor(Handle<JSObject> receiver,
237 Handle<JSObject> holder, 238 Handle<JSObject> holder,
238 Handle<String> name, 239 Handle<String> name,
239 PropertyAttributes* attributes); 240 PropertyAttributes* attributes);
240 241
241 Handle<Object> SetPrototype(Handle<JSObject> obj, Handle<Object> value); 242 Handle<Object> SetPrototype(Handle<JSObject> obj, Handle<Object> value);
242 243
243 Handle<Object> LookupSingleCharacterStringFromCode(uint32_t index); 244 Handle<Object> LookupSingleCharacterStringFromCode(Isolate* isolate,
245 uint32_t index);
244 246
245 Handle<JSObject> Copy(Handle<JSObject> obj); 247 Handle<JSObject> Copy(Handle<JSObject> obj);
246 248
247 Handle<Object> SetAccessor(Handle<JSObject> obj, Handle<AccessorInfo> info); 249 Handle<Object> SetAccessor(Handle<JSObject> obj, Handle<AccessorInfo> info);
248 250
249 Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray>, 251 Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray>,
250 Handle<JSArray> array); 252 Handle<JSArray> array);
251 253
252 // Get the JS object corresponding to the given script; create it 254 // Get the JS object corresponding to the given script; create it
253 // if none exists. 255 // if none exists.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 Handle<ObjectHashSet> ObjectHashSetRemove(Handle<ObjectHashSet> table, 321 Handle<ObjectHashSet> ObjectHashSetRemove(Handle<ObjectHashSet> table,
320 Handle<Object> key); 322 Handle<Object> key);
321 323
322 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table, 324 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table,
323 Handle<Object> key, 325 Handle<Object> key,
324 Handle<Object> value); 326 Handle<Object> value);
325 327
326 class NoHandleAllocation BASE_EMBEDDED { 328 class NoHandleAllocation BASE_EMBEDDED {
327 public: 329 public:
328 #ifndef DEBUG 330 #ifndef DEBUG
329 NoHandleAllocation() {} 331 explicit NoHandleAllocation(Isolate* isolate) {}
330 ~NoHandleAllocation() {} 332 ~NoHandleAllocation() {}
331 #else 333 #else
332 inline NoHandleAllocation(); 334 explicit inline NoHandleAllocation(Isolate* isolate);
333 inline ~NoHandleAllocation(); 335 inline ~NoHandleAllocation();
334 private: 336 private:
337 Isolate* isolate_;
335 int level_; 338 int level_;
336 bool active_; 339 bool active_;
337 #endif 340 #endif
338 }; 341 };
339 342
340 343
341 class NoHandleDereference BASE_EMBEDDED { 344 class NoHandleDereference BASE_EMBEDDED {
342 public: 345 public:
343 #ifndef DEBUG 346 #ifndef DEBUG
344 NoHandleDereference() {} 347 explicit NoHandleDereference(Isolate* isolate) {}
345 ~NoHandleDereference() {} 348 ~NoHandleDereference() {}
346 #else 349 #else
347 inline NoHandleDereference(); 350 explicit inline NoHandleDereference(Isolate* isolate);
348 inline ~NoHandleDereference(); 351 inline ~NoHandleDereference();
349 private: 352 private:
353 Isolate* isolate_;
350 bool old_state_; 354 bool old_state_;
351 #endif 355 #endif
352 }; 356 };
353 357
354 358
355 class AllowHandleDereference BASE_EMBEDDED { 359 class AllowHandleDereference BASE_EMBEDDED {
356 public: 360 public:
357 #ifndef DEBUG 361 #ifndef DEBUG
358 AllowHandleDereference() {} 362 explicit AllowHandleDereference(Isolate* isolate) {}
359 ~AllowHandleDereference() {} 363 ~AllowHandleDereference() {}
360 #else 364 #else
361 inline AllowHandleDereference(); 365 explicit inline AllowHandleDereference(Isolate* isolate);
362 inline ~AllowHandleDereference(); 366 inline ~AllowHandleDereference();
363 private: 367 private:
368 Isolate* isolate_;
364 bool old_state_; 369 bool old_state_;
365 #endif 370 #endif
366 }; 371 };
367 372
368 } } // namespace v8::internal 373 } } // namespace v8::internal
369 374
370 #endif // V8_HANDLES_H_ 375 #endif // V8_HANDLES_H_
OLDNEW
« no previous file with comments | « src/frames.h ('k') | src/handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698