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

Side by Side Diff: include/v8.h

Issue 159236: Force inlining of some handle methods. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 * an Handle<Object>); the value will still be governed by a handle 173 * an Handle<Object>); the value will still be governed by a handle
174 * behind the scenes and the same rules apply to these values as to 174 * behind the scenes and the same rules apply to these values as to
175 * their handles. 175 * their handles.
176 */ 176 */
177 template <class T> class V8EXPORT_INLINE Handle { 177 template <class T> class V8EXPORT_INLINE Handle {
178 public: 178 public:
179 179
180 /** 180 /**
181 * Creates an empty handle. 181 * Creates an empty handle.
182 */ 182 */
183 Handle(); 183 inline Handle();
184 184
185 /** 185 /**
186 * Creates a new handle for the specified value. 186 * Creates a new handle for the specified value.
187 */ 187 */
188 explicit Handle(T* val) : val_(val) { } 188 explicit Handle(T* val) : val_(val) { }
189 189
190 /** 190 /**
191 * Creates a handle for the contents of the specified handle. This 191 * Creates a handle for the contents of the specified handle. This
192 * constructor allows you to pass handles as arguments by value and 192 * constructor allows you to pass handles as arguments by value and
193 * to assign between handles. However, if you try to assign between 193 * to assign between handles. However, if you try to assign between
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 /** 258 /**
259 * A light-weight stack-allocated object handle. All operations 259 * A light-weight stack-allocated object handle. All operations
260 * that return objects from within v8 return them in local handles. They 260 * that return objects from within v8 return them in local handles. They
261 * are created within HandleScopes, and all local handles allocated within a 261 * are created within HandleScopes, and all local handles allocated within a
262 * handle scope are destroyed when the handle scope is destroyed. Hence it 262 * handle scope are destroyed when the handle scope is destroyed. Hence it
263 * is not necessary to explicitly deallocate local handles. 263 * is not necessary to explicitly deallocate local handles.
264 */ 264 */
265 template <class T> class V8EXPORT_INLINE Local : public Handle<T> { 265 template <class T> class V8EXPORT_INLINE Local : public Handle<T> {
266 public: 266 public:
267 Local(); 267 inline Local();
268 template <class S> inline Local(Local<S> that) 268 template <class S> inline Local(Local<S> that)
269 : Handle<T>(reinterpret_cast<T*>(*that)) { 269 : Handle<T>(reinterpret_cast<T*>(*that)) {
270 /** 270 /**
271 * This check fails when trying to convert between incompatible 271 * This check fails when trying to convert between incompatible
272 * handles. For example, converting from a Handle<String> to a 272 * handles. For example, converting from a Handle<String> to a
273 * Handle<Number>. 273 * Handle<Number>.
274 */ 274 */
275 TYPE_CHECK(T, S); 275 TYPE_CHECK(T, S);
276 } 276 }
277 template <class S> inline Local(S* that) : Handle<T>(that) { } 277 template <class S> inline Local(S* that) : Handle<T>(that) { }
278 template <class S> static inline Local<T> Cast(Local<S> that) { 278 template <class S> static inline Local<T> Cast(Local<S> that) {
279 if (that.IsEmpty()) return Local<T>(); 279 if (that.IsEmpty()) return Local<T>();
280 return Local<T>(T::Cast(*that)); 280 return Local<T>(T::Cast(*that));
281 } 281 }
282 282
283 /** Create a local handle for the content of another handle. 283 /** Create a local handle for the content of another handle.
284 * The referee is kept alive by the local handle even when 284 * The referee is kept alive by the local handle even when
285 * the original handle is destroyed/disposed. 285 * the original handle is destroyed/disposed.
286 */ 286 */
287 static Local<T> New(Handle<T> that); 287 inline static Local<T> New(Handle<T> that);
288 }; 288 };
289 289
290 290
291 /** 291 /**
292 * An object reference that is independent of any handle scope. Where 292 * An object reference that is independent of any handle scope. Where
293 * a Local handle only lives as long as the HandleScope in which it was 293 * a Local handle only lives as long as the HandleScope in which it was
294 * allocated, a Persistent handle remains valid until it is explicitly 294 * allocated, a Persistent handle remains valid until it is explicitly
295 * disposed. 295 * disposed.
296 * 296 *
297 * A persistent handle contains a reference to a storage cell within 297 * A persistent handle contains a reference to a storage cell within
298 * the v8 engine which holds an object value and which is updated by 298 * the v8 engine which holds an object value and which is updated by
299 * the garbage collector whenever the object is moved. A new storage 299 * the garbage collector whenever the object is moved. A new storage
300 * cell can be created using Persistent::New and existing handles can 300 * cell can be created using Persistent::New and existing handles can
301 * be disposed using Persistent::Dispose. Since persistent handles 301 * be disposed using Persistent::Dispose. Since persistent handles
302 * are passed by value you may have many persistent handle objects 302 * are passed by value you may have many persistent handle objects
303 * that point to the same storage cell. For instance, if you pass a 303 * that point to the same storage cell. For instance, if you pass a
304 * persistent handle as an argument to a function you will not get two 304 * persistent handle as an argument to a function you will not get two
305 * different storage cells but rather two references to the same 305 * different storage cells but rather two references to the same
306 * storage cell. 306 * storage cell.
307 */ 307 */
308 template <class T> class V8EXPORT_INLINE Persistent : public Handle<T> { 308 template <class T> class V8EXPORT_INLINE Persistent : public Handle<T> {
309 public: 309 public:
310 310
311 /** 311 /**
312 * Creates an empty persistent handle that doesn't point to any 312 * Creates an empty persistent handle that doesn't point to any
313 * storage cell. 313 * storage cell.
314 */ 314 */
315 Persistent(); 315 inline Persistent();
316 316
317 /** 317 /**
318 * Creates a persistent handle for the same storage cell as the 318 * Creates a persistent handle for the same storage cell as the
319 * specified handle. This constructor allows you to pass persistent 319 * specified handle. This constructor allows you to pass persistent
320 * handles as arguments by value and to assign between persistent 320 * handles as arguments by value and to assign between persistent
321 * handles. However, attempting to assign between incompatible 321 * handles. However, attempting to assign between incompatible
322 * persistent handles, for instance from a Persistent<String> to a 322 * persistent handles, for instance from a Persistent<String> to a
323 * Persistent<Number> will cause a compiletime error. Assigning 323 * Persistent<Number> will cause a compiletime error. Assigning
324 * between compatible persistent handles, for instance assigning a 324 * between compatible persistent handles, for instance assigning a
325 * Persistent<String> to a variable declared as Persistent<Value>, 325 * Persistent<String> to a variable declared as Persistent<Value>,
(...skipping 20 matching lines...) Expand all
346 346
347 template <class S> static inline Persistent<T> Cast(Persistent<S> that) { 347 template <class S> static inline Persistent<T> Cast(Persistent<S> that) {
348 if (that.IsEmpty()) return Persistent<T>(); 348 if (that.IsEmpty()) return Persistent<T>();
349 return Persistent<T>(T::Cast(*that)); 349 return Persistent<T>(T::Cast(*that));
350 } 350 }
351 351
352 /** 352 /**
353 * Creates a new persistent handle for an existing local or 353 * Creates a new persistent handle for an existing local or
354 * persistent handle. 354 * persistent handle.
355 */ 355 */
356 static Persistent<T> New(Handle<T> that); 356 inline static Persistent<T> New(Handle<T> that);
357 357
358 /** 358 /**
359 * Releases the storage cell referenced by this persistent handle. 359 * Releases the storage cell referenced by this persistent handle.
360 * Does not remove the reference to the cell from any handles. 360 * Does not remove the reference to the cell from any handles.
361 * This handle's reference, and any any other references to the storage 361 * This handle's reference, and any any other references to the storage
362 * cell remain and IsEmpty will still return false. 362 * cell remain and IsEmpty will still return false.
363 */ 363 */
364 void Dispose(); 364 inline void Dispose();
365 365
366 /** 366 /**
367 * Make the reference to this object weak. When only weak handles 367 * Make the reference to this object weak. When only weak handles
368 * refer to the object, the garbage collector will perform a 368 * refer to the object, the garbage collector will perform a
369 * callback to the given V8::WeakReferenceCallback function, passing 369 * callback to the given V8::WeakReferenceCallback function, passing
370 * it the object reference and the given parameters. 370 * it the object reference and the given parameters.
371 */ 371 */
372 void MakeWeak(void* parameters, WeakReferenceCallback callback); 372 inline void MakeWeak(void* parameters, WeakReferenceCallback callback);
373 373
374 /** Clears the weak reference to this object.*/ 374 /** Clears the weak reference to this object.*/
375 void ClearWeak(); 375 inline void ClearWeak();
376 376
377 /** 377 /**
378 *Checks if the handle holds the only reference to an object. 378 *Checks if the handle holds the only reference to an object.
379 */ 379 */
380 bool IsNearDeath() const; 380 inline bool IsNearDeath() const;
381 381
382 /** 382 /**
383 * Returns true if the handle's reference is weak. 383 * Returns true if the handle's reference is weak.
384 */ 384 */
385 bool IsWeak() const; 385 inline bool IsWeak() const;
386 386
387 private: 387 private:
388 friend class ImplementationUtilities; 388 friend class ImplementationUtilities;
389 friend class ObjectTemplate; 389 friend class ObjectTemplate;
390 }; 390 };
391 391
392 392
393 /** 393 /**
394 * A stack-allocated class that governs a number of local handles. 394 * A stack-allocated class that governs a number of local handles.
395 * After a handle scope has been created, all local handles will be 395 * After a handle scope has been created, all local handles will be
(...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 2618
2619 } // namespace v8 2619 } // namespace v8
2620 2620
2621 2621
2622 #undef V8EXPORT 2622 #undef V8EXPORT
2623 #undef V8EXPORT_INLINE 2623 #undef V8EXPORT_INLINE
2624 #undef TYPE_CHECK 2624 #undef TYPE_CHECK
2625 2625
2626 2626
2627 #endif // V8_H_ 2627 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698