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

Side by Side Diff: include/v8.h

Issue 148343005: A64: Synchronize with r18147. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | « Makefile ('k') | src/a64/full-codegen-a64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 class Symbol; 116 class Symbol;
117 class SymbolObject; 117 class SymbolObject;
118 class Private; 118 class Private;
119 class Uint32; 119 class Uint32;
120 class Utils; 120 class Utils;
121 class Value; 121 class Value;
122 template <class T> class Handle; 122 template <class T> class Handle;
123 template <class T> class Local; 123 template <class T> class Local;
124 template <class T> class Eternal; 124 template <class T> class Eternal;
125 template<class T> class NonCopyablePersistentTraits; 125 template<class T> class NonCopyablePersistentTraits;
126 template<class T> class PersistentBase;
126 template<class T, 127 template<class T,
127 class M = NonCopyablePersistentTraits<T> > class Persistent; 128 class M = NonCopyablePersistentTraits<T> > class Persistent;
129 template<class T> class UniquePersistent;
128 template<class T, class P> class WeakCallbackObject; 130 template<class T, class P> class WeakCallbackObject;
129 class FunctionTemplate; 131 class FunctionTemplate;
130 class ObjectTemplate; 132 class ObjectTemplate;
131 class Data; 133 class Data;
132 template<typename T> class PropertyCallbackInfo; 134 template<typename T> class PropertyCallbackInfo;
133 class StackTrace; 135 class StackTrace;
134 class StackFrame; 136 class StackFrame;
135 class Isolate; 137 class Isolate;
136 class DeclaredAccessorDescriptor; 138 class DeclaredAccessorDescriptor;
137 class ObjectOperationDescriptor; 139 class ObjectOperationDescriptor;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 252
251 V8_INLINE T* operator*() const { return val_; } 253 V8_INLINE T* operator*() const { return val_; }
252 254
253 /** 255 /**
254 * Checks whether two handles are the same. 256 * Checks whether two handles are the same.
255 * Returns true if both are empty, or if the objects 257 * Returns true if both are empty, or if the objects
256 * to which they refer are identical. 258 * to which they refer are identical.
257 * The handles' references are not checked. 259 * The handles' references are not checked.
258 */ 260 */
259 template <class S> V8_INLINE bool operator==(const Handle<S>& that) const { 261 template <class S> V8_INLINE bool operator==(const Handle<S>& that) const {
260 internal::Object** a = reinterpret_cast<internal::Object**>(**this); 262 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
261 internal::Object** b = reinterpret_cast<internal::Object**>(*that); 263 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
262 if (a == 0) return b == 0; 264 if (a == 0) return b == 0;
263 if (b == 0) return false; 265 if (b == 0) return false;
264 return *a == *b; 266 return *a == *b;
265 } 267 }
266 268
267 template <class S> V8_INLINE bool operator==( 269 template <class S> V8_INLINE bool operator==(
268 const Persistent<S>& that) const { 270 const PersistentBase<S>& that) const {
269 internal::Object** a = reinterpret_cast<internal::Object**>(**this); 271 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
270 internal::Object** b = reinterpret_cast<internal::Object**>(*that); 272 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
271 if (a == 0) return b == 0; 273 if (a == 0) return b == 0;
272 if (b == 0) return false; 274 if (b == 0) return false;
273 return *a == *b; 275 return *a == *b;
274 } 276 }
275 277
276 /** 278 /**
277 * Checks whether two handles are different. 279 * Checks whether two handles are different.
278 * Returns true if only one of the handles is empty, or if 280 * Returns true if only one of the handles is empty, or if
279 * the objects to which they refer are different. 281 * the objects to which they refer are different.
280 * The handles' references are not checked. 282 * The handles' references are not checked.
(...skipping 16 matching lines...) Expand all
297 return Handle<T>(T::Cast(*that)); 299 return Handle<T>(T::Cast(*that));
298 } 300 }
299 301
300 template <class S> V8_INLINE Handle<S> As() { 302 template <class S> V8_INLINE Handle<S> As() {
301 return Handle<S>::Cast(*this); 303 return Handle<S>::Cast(*this);
302 } 304 }
303 305
304 V8_INLINE static Handle<T> New(Isolate* isolate, Handle<T> that) { 306 V8_INLINE static Handle<T> New(Isolate* isolate, Handle<T> that) {
305 return New(isolate, that.val_); 307 return New(isolate, that.val_);
306 } 308 }
307 V8_INLINE static Handle<T> New(Isolate* isolate, const Persistent<T>& that) { 309 V8_INLINE static Handle<T> New(Isolate* isolate,
310 const PersistentBase<T>& that) {
308 return New(isolate, that.val_); 311 return New(isolate, that.val_);
309 } 312 }
310 313
311 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR 314 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
312 315
313 private: 316 private:
314 #endif 317 #endif
315 /** 318 /**
316 * Creates a new handle for the specified value. 319 * Creates a new handle for the specified value.
317 */ 320 */
318 V8_INLINE explicit Handle(T* val) : val_(val) {} 321 V8_INLINE explicit Handle(T* val) : val_(val) {}
319 322
320 private: 323 private:
321 friend class Utils; 324 friend class Utils;
322 template<class F, class M> friend class Persistent; 325 template<class F, class M> friend class Persistent;
326 template<class F> friend class PersistentBase;
327 template<class F> friend class Handle;
323 template<class F> friend class Local; 328 template<class F> friend class Local;
324 template<class F> friend class FunctionCallbackInfo; 329 template<class F> friend class FunctionCallbackInfo;
325 template<class F> friend class PropertyCallbackInfo; 330 template<class F> friend class PropertyCallbackInfo;
326 template<class F> friend class internal::CustomArguments; 331 template<class F> friend class internal::CustomArguments;
327 friend Handle<Primitive> Undefined(Isolate* isolate); 332 friend Handle<Primitive> Undefined(Isolate* isolate);
328 friend Handle<Primitive> Null(Isolate* isolate); 333 friend Handle<Primitive> Null(Isolate* isolate);
329 friend Handle<Boolean> True(Isolate* isolate); 334 friend Handle<Boolean> True(Isolate* isolate);
330 friend Handle<Boolean> False(Isolate* isolate); 335 friend Handle<Boolean> False(Isolate* isolate);
331 friend class Context; 336 friend class Context;
332 friend class HandleScope; 337 friend class HandleScope;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 template <class S> V8_INLINE Local<S> As() { 381 template <class S> V8_INLINE Local<S> As() {
377 return Local<S>::Cast(*this); 382 return Local<S>::Cast(*this);
378 } 383 }
379 384
380 /** 385 /**
381 * Create a local handle for the content of another handle. 386 * Create a local handle for the content of another handle.
382 * The referee is kept alive by the local handle even when 387 * The referee is kept alive by the local handle even when
383 * the original handle is destroyed/disposed. 388 * the original handle is destroyed/disposed.
384 */ 389 */
385 V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that); 390 V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that);
386 template<class M>
387 V8_INLINE static Local<T> New(Isolate* isolate, 391 V8_INLINE static Local<T> New(Isolate* isolate,
388 const Persistent<T, M>& that); 392 const PersistentBase<T>& that);
389 393
390 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR 394 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
391 395
392 private: 396 private:
393 #endif 397 #endif
394 template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { } 398 template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { }
395 399
396 private: 400 private:
397 friend class Utils; 401 friend class Utils;
398 template<class F> friend class Eternal; 402 template<class F> friend class Eternal;
403 template<class F> friend class PersistentBase;
399 template<class F, class M> friend class Persistent; 404 template<class F, class M> friend class Persistent;
400 template<class F> friend class Handle; 405 template<class F> friend class Handle;
406 template<class F> friend class Local;
401 template<class F> friend class FunctionCallbackInfo; 407 template<class F> friend class FunctionCallbackInfo;
402 template<class F> friend class PropertyCallbackInfo; 408 template<class F> friend class PropertyCallbackInfo;
403 friend class String; 409 friend class String;
404 friend class Object; 410 friend class Object;
405 friend class Context; 411 friend class Context;
406 template<class F> friend class internal::CustomArguments; 412 template<class F> friend class internal::CustomArguments;
407 friend class HandleScope; 413 friend class HandleScope;
408 friend class EscapableHandleScope; 414 friend class EscapableHandleScope;
409 415
410 V8_INLINE static Local<T> New(Isolate* isolate, T* that); 416 V8_INLINE static Local<T> New(Isolate* isolate, T* that);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 typename M = NonCopyablePersistentTraits<T> > 461 typename M = NonCopyablePersistentTraits<T> >
456 class WeakReferenceCallbacks { 462 class WeakReferenceCallbacks {
457 public: 463 public:
458 typedef void (*Revivable)(Isolate* isolate, 464 typedef void (*Revivable)(Isolate* isolate,
459 Persistent<T, M>* object, 465 Persistent<T, M>* object,
460 P* parameter); 466 P* parameter);
461 }; 467 };
462 468
463 469
464 /** 470 /**
471 * An object reference that is independent of any handle scope. Where
472 * a Local handle only lives as long as the HandleScope in which it was
473 * allocated, a PersistentBase handle remains valid until it is explicitly
474 * disposed.
475 *
476 * A persistent handle contains a reference to a storage cell within
477 * the v8 engine which holds an object value and which is updated by
478 * the garbage collector whenever the object is moved. A new storage
479 * cell can be created using the constructor or PersistentBase::Reset and
480 * existing handles can be disposed using PersistentBase::Reset.
481 *
482 */
483 template <class T> class PersistentBase {
484 public:
485 /**
486 * If non-empty, destroy the underlying storage cell
487 * IsEmpty() will return true after this call.
488 */
489 V8_INLINE void Reset();
490 /**
491 * If non-empty, destroy the underlying storage cell
492 * and create a new one with the contents of other if other is non empty
493 */
494 template <class S>
495 V8_INLINE void Reset(Isolate* isolate, const Handle<S>& other);
496
497 /**
498 * If non-empty, destroy the underlying storage cell
499 * and create a new one with the contents of other if other is non empty
500 */
501 template <class S>
502 V8_INLINE void Reset(Isolate* isolate, const PersistentBase<S>& other);
503
504 V8_INLINE bool IsEmpty() const { return val_ == 0; }
505
506 template <class S>
507 V8_INLINE bool operator==(const PersistentBase<S>& that) const {
508 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
509 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
510 if (a == 0) return b == 0;
511 if (b == 0) return false;
512 return *a == *b;
513 }
514
515 template <class S> V8_INLINE bool operator==(const Handle<S>& that) const {
516 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
517 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
518 if (a == 0) return b == 0;
519 if (b == 0) return false;
520 return *a == *b;
521 }
522
523 template <class S>
524 V8_INLINE bool operator!=(const PersistentBase<S>& that) const {
525 return !operator==(that);
526 }
527
528 template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const {
529 return !operator==(that);
530 }
531
532 template<typename P>
533 V8_INLINE void SetWeak(
534 P* parameter,
535 typename WeakCallbackData<T, P>::Callback callback);
536
537 template<typename S, typename P>
538 V8_INLINE void SetWeak(
539 P* parameter,
540 typename WeakCallbackData<S, P>::Callback callback);
541
542 V8_INLINE void ClearWeak();
543
544 /**
545 * Marks the reference to this object independent. Garbage collector is free
546 * to ignore any object groups containing this object. Weak callback for an
547 * independent handle should not assume that it will be preceded by a global
548 * GC prologue callback or followed by a global GC epilogue callback.
549 */
550 V8_INLINE void MarkIndependent();
551
552 /**
553 * Marks the reference to this object partially dependent. Partially dependent
554 * handles only depend on other partially dependent handles and these
555 * dependencies are provided through object groups. It provides a way to build
556 * smaller object groups for young objects that represent only a subset of all
557 * external dependencies. This mark is automatically cleared after each
558 * garbage collection.
559 */
560 V8_INLINE void MarkPartiallyDependent();
561
562 V8_INLINE bool IsIndependent() const;
563
564 /** Checks if the handle holds the only reference to an object. */
565 V8_INLINE bool IsNearDeath() const;
566
567 /** Returns true if the handle's reference is weak. */
568 V8_INLINE bool IsWeak() const;
569
570 /**
571 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface
572 * description in v8-profiler.h for details.
573 */
574 V8_INLINE void SetWrapperClassId(uint16_t class_id);
575
576 /**
577 * Returns the class ID previously assigned to this handle or 0 if no class ID
578 * was previously assigned.
579 */
580 V8_INLINE uint16_t WrapperClassId() const;
581
582 private:
583 friend class Isolate;
584 friend class Utils;
585 template<class F> friend class Handle;
586 template<class F> friend class Local;
587 template<class F1, class F2> friend class Persistent;
588 template<class F> friend class UniquePersistent;
589 template<class F> friend class PersistentBase;
590 template<class F> friend class ReturnValue;
591
592 explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
593 PersistentBase(PersistentBase& other); // NOLINT
594 void operator=(PersistentBase&);
595 V8_INLINE static T* New(Isolate* isolate, T* that);
596
597 T* val_;
598 };
599
600
601 /**
465 * Default traits for Persistent. This class does not allow 602 * Default traits for Persistent. This class does not allow
466 * use of the copy constructor or assignment operator. 603 * use of the copy constructor or assignment operator.
467 * At present kResetInDestructor is not set, but that will change in a future 604 * At present kResetInDestructor is not set, but that will change in a future
468 * version. 605 * version.
469 */ 606 */
470 template<class T> 607 template<class T>
471 class NonCopyablePersistentTraits { 608 class NonCopyablePersistentTraits {
472 public: 609 public:
473 typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent; 610 typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent;
474 static const bool kResetInDestructor = false; 611 static const bool kResetInDestructor = false;
(...skipping 19 matching lines...) Expand all
494 static const bool kResetInDestructor = true; 631 static const bool kResetInDestructor = true;
495 template<class S, class M> 632 template<class S, class M>
496 static V8_INLINE void Copy(const Persistent<S, M>& source, 633 static V8_INLINE void Copy(const Persistent<S, M>& source,
497 CopyablePersistent* dest) { 634 CopyablePersistent* dest) {
498 // do nothing, just allow copy 635 // do nothing, just allow copy
499 } 636 }
500 }; 637 };
501 638
502 639
503 /** 640 /**
504 * An object reference that is independent of any handle scope. Where 641 * A PersistentBase which allows copy and assignment.
505 * a Local handle only lives as long as the HandleScope in which it was
506 * allocated, a Persistent handle remains valid until it is explicitly
507 * disposed.
508 *
509 * A persistent handle contains a reference to a storage cell within
510 * the v8 engine which holds an object value and which is updated by
511 * the garbage collector whenever the object is moved. A new storage
512 * cell can be created using the constructor or Persistent::Reset and
513 * existing handles can be disposed using Persistent::Reset.
514 * 642 *
515 * Copy, assignment and destructor bevavior is controlled by the traits 643 * Copy, assignment and destructor bevavior is controlled by the traits
516 * class M. 644 * class M.
645 *
646 * Note: Persistent class hierarchy is subject to future changes.
517 */ 647 */
518 template <class T, class M> class Persistent { 648 template <class T, class M> class Persistent : public PersistentBase<T> {
519 public: 649 public:
520 /** 650 /**
521 * A Persistent with no storage cell. 651 * A Persistent with no storage cell.
522 */ 652 */
523 V8_INLINE Persistent() : val_(0) { } 653 V8_INLINE Persistent() : PersistentBase<T>(0) { }
524 /** 654 /**
525 * Construct a Persistent from a Handle. 655 * Construct a Persistent from a Handle.
526 * When the Handle is non-empty, a new storage cell is created 656 * When the Handle is non-empty, a new storage cell is created
527 * pointing to the same object, and no flags are set. 657 * pointing to the same object, and no flags are set.
528 */ 658 */
529 template <class S> V8_INLINE Persistent(Isolate* isolate, Handle<S> that) 659 template <class S> V8_INLINE Persistent(Isolate* isolate, Handle<S> that)
530 : val_(New(isolate, *that)) { 660 : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
531 TYPE_CHECK(T, S); 661 TYPE_CHECK(T, S);
532 } 662 }
533 /** 663 /**
534 * Construct a Persistent from a Persistent. 664 * Construct a Persistent from a Persistent.
535 * When the Persistent is non-empty, a new storage cell is created 665 * When the Persistent is non-empty, a new storage cell is created
536 * pointing to the same object, and no flags are set. 666 * pointing to the same object, and no flags are set.
537 */ 667 */
538 template <class S, class M2> 668 template <class S, class M2>
539 V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that) 669 V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that)
540 : val_(New(isolate, *that)) { 670 : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
541 TYPE_CHECK(T, S); 671 TYPE_CHECK(T, S);
542 } 672 }
543 /** 673 /**
544 * The copy constructors and assignment operator create a Persistent 674 * The copy constructors and assignment operator create a Persistent
545 * exactly as the Persistent constructor, but the Copy function from the 675 * exactly as the Persistent constructor, but the Copy function from the
546 * traits class is called, allowing the setting of flags based on the 676 * traits class is called, allowing the setting of flags based on the
547 * copied Persistent. 677 * copied Persistent.
548 */ 678 */
549 V8_INLINE Persistent(const Persistent& that) : val_(0) { 679 V8_INLINE Persistent(const Persistent& that) : PersistentBase<T>(0) {
550 Copy(that); 680 Copy(that);
551 } 681 }
552 template <class S, class M2> 682 template <class S, class M2>
553 V8_INLINE Persistent(const Persistent<S, M2>& that) : val_(0) { 683 V8_INLINE Persistent(const Persistent<S, M2>& that) : PersistentBase<T>(0) {
554 Copy(that); 684 Copy(that);
555 } 685 }
556 V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT 686 V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT
557 Copy(that); 687 Copy(that);
558 return *this; 688 return *this;
559 } 689 }
560 template <class S, class M2> 690 template <class S, class M2>
561 V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLINT 691 V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLINT
562 Copy(that); 692 Copy(that);
563 return *this; 693 return *this;
564 } 694 }
565 /** 695 /**
566 * The destructor will dispose the Persistent based on the 696 * The destructor will dispose the Persistent based on the
567 * kResetInDestructor flags in the traits class. Since not calling dispose 697 * kResetInDestructor flags in the traits class. Since not calling dispose
568 * can result in a memory leak, it is recommended to always set this flag. 698 * can result in a memory leak, it is recommended to always set this flag.
569 */ 699 */
570 V8_INLINE ~Persistent() { 700 V8_INLINE ~Persistent() {
571 if (M::kResetInDestructor) Reset(); 701 if (M::kResetInDestructor) this->Reset();
572 } 702 }
573 703
574 /**
575 * If non-empty, destroy the underlying storage cell
576 * IsEmpty() will return true after this call.
577 */
578 V8_INLINE void Reset();
579 /**
580 * If non-empty, destroy the underlying storage cell
581 * and create a new one with the contents of other if other is non empty
582 */
583 template <class S>
584 V8_INLINE void Reset(Isolate* isolate, const Handle<S>& other);
585 /**
586 * If non-empty, destroy the underlying storage cell
587 * and create a new one with the contents of other if other is non empty
588 */
589 template <class S, class M2>
590 V8_INLINE void Reset(Isolate* isolate, const Persistent<S, M2>& other);
591
592 V8_DEPRECATED("Use Reset instead", 704 V8_DEPRECATED("Use Reset instead",
593 V8_INLINE void Dispose()) { Reset(); } 705 V8_INLINE void Dispose()) { this->Reset(); }
594
595 V8_INLINE bool IsEmpty() const { return val_ == 0; }
596 706
597 // TODO(dcarney): this is pretty useless, fix or remove 707 // TODO(dcarney): this is pretty useless, fix or remove
598 template <class S> 708 template <class S>
599 V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT 709 V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT
600 #ifdef V8_ENABLE_CHECKS 710 #ifdef V8_ENABLE_CHECKS
601 // If we're going to perform the type check then we have to check 711 // If we're going to perform the type check then we have to check
602 // that the handle isn't empty before doing the checked cast. 712 // that the handle isn't empty before doing the checked cast.
603 if (!that.IsEmpty()) T::Cast(*that); 713 if (!that.IsEmpty()) T::Cast(*that);
604 #endif 714 #endif
605 return reinterpret_cast<Persistent<T>&>(that); 715 return reinterpret_cast<Persistent<T>&>(that);
606 } 716 }
607 717
608 // TODO(dcarney): this is pretty useless, fix or remove 718 // TODO(dcarney): this is pretty useless, fix or remove
609 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT 719 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT
610 return Persistent<S>::Cast(*this); 720 return Persistent<S>::Cast(*this);
611 } 721 }
612 722
613 template <class S, class M2>
614 V8_INLINE bool operator==(const Persistent<S, M2>& that) const {
615 internal::Object** a = reinterpret_cast<internal::Object**>(**this);
616 internal::Object** b = reinterpret_cast<internal::Object**>(*that);
617 if (a == 0) return b == 0;
618 if (b == 0) return false;
619 return *a == *b;
620 }
621
622 template <class S> V8_INLINE bool operator==(const Handle<S>& that) const {
623 internal::Object** a = reinterpret_cast<internal::Object**>(**this);
624 internal::Object** b = reinterpret_cast<internal::Object**>(*that);
625 if (a == 0) return b == 0;
626 if (b == 0) return false;
627 return *a == *b;
628 }
629
630 template <class S, class M2>
631 V8_INLINE bool operator!=(const Persistent<S, M2>& that) const {
632 return !operator==(that);
633 }
634
635 template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const {
636 return !operator==(that);
637 }
638
639 template<typename P>
640 V8_INLINE void SetWeak(
641 P* parameter,
642 typename WeakCallbackData<T, P>::Callback callback);
643
644 template<typename S, typename P>
645 V8_INLINE void SetWeak(
646 P* parameter,
647 typename WeakCallbackData<S, P>::Callback callback);
648
649 template<typename S, typename P> 723 template<typename S, typename P>
650 V8_DEPRECATED( 724 V8_DEPRECATED(
651 "Use SetWeak instead", 725 "Use SetWeak instead",
652 V8_INLINE void MakeWeak( 726 V8_INLINE void MakeWeak(
653 P* parameter, 727 P* parameter,
654 typename WeakReferenceCallbacks<S, P>::Revivable callback)); 728 typename WeakReferenceCallbacks<S, P>::Revivable callback));
655 729
656 template<typename P> 730 template<typename P>
657 V8_DEPRECATED( 731 V8_DEPRECATED(
658 "Use SetWeak instead", 732 "Use SetWeak instead",
659 V8_INLINE void MakeWeak( 733 V8_INLINE void MakeWeak(
660 P* parameter, 734 P* parameter,
661 typename WeakReferenceCallbacks<T, P>::Revivable callback)); 735 typename WeakReferenceCallbacks<T, P>::Revivable callback));
662 736
663 V8_INLINE void ClearWeak(); 737 // This will be removed.
664 738 V8_INLINE T* ClearAndLeak();
665 /**
666 * Marks the reference to this object independent. Garbage collector is free
667 * to ignore any object groups containing this object. Weak callback for an
668 * independent handle should not assume that it will be preceded by a global
669 * GC prologue callback or followed by a global GC epilogue callback.
670 */
671 V8_INLINE void MarkIndependent();
672
673 /**
674 * Marks the reference to this object partially dependent. Partially dependent
675 * handles only depend on other partially dependent handles and these
676 * dependencies are provided through object groups. It provides a way to build
677 * smaller object groups for young objects that represent only a subset of all
678 * external dependencies. This mark is automatically cleared after each
679 * garbage collection.
680 */
681 V8_INLINE void MarkPartiallyDependent();
682
683 V8_INLINE bool IsIndependent() const;
684
685 /** Checks if the handle holds the only reference to an object. */
686 V8_INLINE bool IsNearDeath() const;
687
688 /** Returns true if the handle's reference is weak. */
689 V8_INLINE bool IsWeak() const;
690
691 /**
692 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface
693 * description in v8-profiler.h for details.
694 */
695 V8_INLINE void SetWrapperClassId(uint16_t class_id);
696
697 /**
698 * Returns the class ID previously assigned to this handle or 0 if no class ID
699 * was previously assigned.
700 */
701 V8_INLINE uint16_t WrapperClassId() const;
702 739
703 V8_DEPRECATED("This will be removed", 740 V8_DEPRECATED("This will be removed",
704 V8_INLINE T* ClearAndLeak()); 741 V8_INLINE void Clear()) { this->val_ = 0; }
705
706 V8_DEPRECATED("This will be removed",
707 V8_INLINE void Clear()) { val_ = 0; }
708 742
709 // TODO(dcarney): remove 743 // TODO(dcarney): remove
710 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR 744 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
711 745
712 private: 746 private:
713 #endif 747 #endif
714 template <class S> V8_INLINE Persistent(S* that) : val_(that) { } 748 template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { }
715 749
716 V8_INLINE T* operator*() const { return val_; } 750 V8_INLINE T* operator*() const { return this->val_; }
717 751
718 private: 752 private:
719 friend class Isolate; 753 friend class Isolate;
720 friend class Utils; 754 friend class Utils;
721 template<class F> friend class Handle; 755 template<class F> friend class Handle;
722 template<class F> friend class Local; 756 template<class F> friend class Local;
723 template<class F1, class F2> friend class Persistent; 757 template<class F1, class F2> friend class Persistent;
724 template<class F> friend class ReturnValue; 758 template<class F> friend class ReturnValue;
725 759
726 V8_INLINE static T* New(Isolate* isolate, T* that);
727 template<class S, class M2> 760 template<class S, class M2>
728 V8_INLINE void Copy(const Persistent<S, M2>& that); 761 V8_INLINE void Copy(const Persistent<S, M2>& that);
762 };
729 763
730 T* val_; 764
765 /**
766 * A PersistentBase which has move semantics.
767 *
768 * Note: Persistent class hierarchy is subject to future changes.
769 */
770 template<class T>
771 class UniquePersistent : public PersistentBase<T> {
772 struct RValue {
773 V8_INLINE explicit RValue(UniquePersistent* object) : object(object) {}
774 UniquePersistent* object;
775 };
776
777 public:
778 /**
779 * A UniquePersistent with no storage cell.
780 */
781 V8_INLINE UniquePersistent() : PersistentBase<T>(0) { }
782 /**
783 * Construct a UniquePersistent from a Handle.
784 * When the Handle is non-empty, a new storage cell is created
785 * pointing to the same object, and no flags are set.
786 */
787 template <class S>
788 V8_INLINE UniquePersistent(Isolate* isolate, Handle<S> that)
789 : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
790 TYPE_CHECK(T, S);
791 }
792 /**
793 * Construct a UniquePersistent from a PersistentBase.
794 * When the Persistent is non-empty, a new storage cell is created
795 * pointing to the same object, and no flags are set.
796 */
797 template <class S>
798 V8_INLINE UniquePersistent(Isolate* isolate, const PersistentBase<S>& that)
799 : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) {
800 TYPE_CHECK(T, S);
801 }
802 /**
803 * Move constructor.
804 */
805 V8_INLINE UniquePersistent(RValue rvalue)
806 : PersistentBase<T>(rvalue.object->val_) {
807 rvalue.object->val_ = 0;
808 }
809 V8_INLINE ~UniquePersistent() { this->Reset(); }
810 /**
811 * Move via assignment.
812 */
813 template<class S>
814 V8_INLINE UniquePersistent& operator=(UniquePersistent<S> rhs) {
815 TYPE_CHECK(T, S);
816 this->val_ = rhs.val_;
817 rhs.val_ = 0;
818 return *this;
819 }
820 /**
821 * Cast operator for moves.
822 */
823 V8_INLINE operator RValue() { return RValue(this); }
824 /**
825 * Pass allows returning uniques from functions, etc.
826 */
827 V8_INLINE UniquePersistent Pass() { return UniquePersistent(RValue(this)); }
828
829 private:
830 UniquePersistent(UniquePersistent&);
831 void operator=(UniquePersistent&);
731 }; 832 };
732 833
834
733 /** 835 /**
734 * A stack-allocated class that governs a number of local handles. 836 * A stack-allocated class that governs a number of local handles.
735 * After a handle scope has been created, all local handles will be 837 * After a handle scope has been created, all local handles will be
736 * allocated within that handle scope until either the handle scope is 838 * allocated within that handle scope until either the handle scope is
737 * deleted or another handle scope is created. If there is already a 839 * deleted or another handle scope is created. If there is already a
738 * handle scope and a new one is created, all allocations will take 840 * handle scope and a new one is created, all allocations will take
739 * place in the new handle scope until it is deleted. After that, 841 * place in the new handle scope until it is deleted. After that,
740 * new handles will again be allocated in the original handle scope. 842 * new handles will again be allocated in the original handle scope.
741 * 843 *
742 * After the handle scope of a local handle has been deleted the 844 * After the handle scope of a local handle has been deleted the
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 int GetEndColumn() const; 1233 int GetEndColumn() const;
1132 1234
1133 /** 1235 /**
1134 * Passes on the value set by the embedder when it fed the script from which 1236 * Passes on the value set by the embedder when it fed the script from which
1135 * this Message was generated to V8. 1237 * this Message was generated to V8.
1136 */ 1238 */
1137 bool IsSharedCrossOrigin() const; 1239 bool IsSharedCrossOrigin() const;
1138 1240
1139 // TODO(1245381): Print to a string instead of on a FILE. 1241 // TODO(1245381): Print to a string instead of on a FILE.
1140 static void PrintCurrentStackTrace(Isolate* isolate, FILE* out); 1242 static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
1141 // Will be deprecated soon. 1243 V8_DEPRECATED("Will be removed",
1142 static void PrintCurrentStackTrace(FILE* out); 1244 static void PrintCurrentStackTrace(FILE* out));
1143 1245
1144 static const int kNoLineNumberInfo = 0; 1246 static const int kNoLineNumberInfo = 0;
1145 static const int kNoColumnInfo = 0; 1247 static const int kNoColumnInfo = 0;
1146 static const int kNoScriptIdInfo = 0; 1248 static const int kNoScriptIdInfo = 0;
1147 }; 1249 };
1148 1250
1149 1251
1150 /** 1252 /**
1151 * Representation of a JavaScript stack trace. The information collected is a 1253 * Representation of a JavaScript stack trace. The information collected is a
1152 * snapshot of the execution stack and the information remains valid after 1254 * snapshot of the execution stack and the information remains valid after
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 * Grab a snapshot of the current JavaScript execution stack. 1292 * Grab a snapshot of the current JavaScript execution stack.
1191 * 1293 *
1192 * \param frame_limit The maximum number of stack frames we want to capture. 1294 * \param frame_limit The maximum number of stack frames we want to capture.
1193 * \param options Enumerates the set of things we will capture for each 1295 * \param options Enumerates the set of things we will capture for each
1194 * StackFrame. 1296 * StackFrame.
1195 */ 1297 */
1196 static Local<StackTrace> CurrentStackTrace( 1298 static Local<StackTrace> CurrentStackTrace(
1197 Isolate* isolate, 1299 Isolate* isolate,
1198 int frame_limit, 1300 int frame_limit,
1199 StackTraceOptions options = kOverview); 1301 StackTraceOptions options = kOverview);
1200 // Will be deprecated soon. 1302 V8_DEPRECATED("Will be removed",
1201 static Local<StackTrace> CurrentStackTrace( 1303 static Local<StackTrace> CurrentStackTrace(
1202 int frame_limit, 1304 int frame_limit, StackTraceOptions options = kOverview));
1203 StackTraceOptions options = kOverview);
1204 }; 1305 };
1205 1306
1206 1307
1207 /** 1308 /**
1208 * A single JavaScript stack frame. 1309 * A single JavaScript stack frame.
1209 */ 1310 */
1210 class V8_EXPORT StackFrame { 1311 class V8_EXPORT StackFrame {
1211 public: 1312 public:
1212 /** 1313 /**
1213 * Returns the number, 1-based, of the line for the associate function call. 1314 * Returns the number, 1-based, of the line for the associate function call.
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 1626
1526 1627
1527 /** 1628 /**
1528 * A primitive boolean value (ECMA-262, 4.3.14). Either the true 1629 * A primitive boolean value (ECMA-262, 4.3.14). Either the true
1529 * or false value. 1630 * or false value.
1530 */ 1631 */
1531 class V8_EXPORT Boolean : public Primitive { 1632 class V8_EXPORT Boolean : public Primitive {
1532 public: 1633 public:
1533 bool Value() const; 1634 bool Value() const;
1534 V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value); 1635 V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value);
1535 // Will be deprecated soon. 1636 V8_DEPRECATED("Will be removed",
1536 V8_INLINE static Handle<Boolean> New(bool value); 1637 V8_INLINE static Handle<Boolean> New(bool value));
1537 }; 1638 };
1538 1639
1539 1640
1540 /** 1641 /**
1541 * A JavaScript string value (ECMA-262, 4.3.17). 1642 * A JavaScript string value (ECMA-262, 4.3.17).
1542 */ 1643 */
1543 class V8_EXPORT String : public Primitive { 1644 class V8_EXPORT String : public Primitive {
1544 public: 1645 public:
1545 enum Encoding { 1646 enum Encoding {
1546 UNKNOWN_ENCODING = 0x1, 1647 UNKNOWN_ENCODING = 0x1,
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 /** 1897 /**
1797 * Creates a new external string using the data defined in the given 1898 * Creates a new external string using the data defined in the given
1798 * resource. When the external string is no longer live on V8's heap the 1899 * resource. When the external string is no longer live on V8's heap the
1799 * resource will be disposed by calling its Dispose method. The caller of 1900 * resource will be disposed by calling its Dispose method. The caller of
1800 * this function should not otherwise delete or modify the resource. Neither 1901 * this function should not otherwise delete or modify the resource. Neither
1801 * should the underlying buffer be deallocated or modified except through the 1902 * should the underlying buffer be deallocated or modified except through the
1802 * destructor of the external string resource. 1903 * destructor of the external string resource.
1803 */ 1904 */
1804 static Local<String> NewExternal(Isolate* isolate, 1905 static Local<String> NewExternal(Isolate* isolate,
1805 ExternalStringResource* resource); 1906 ExternalStringResource* resource);
1806 // Will be deprecated soon. 1907 V8_DEPRECATED("Will be removed", static Local<String> NewExternal(
1807 static Local<String> NewExternal(ExternalStringResource* resource); 1908 ExternalStringResource* resource));
1808 1909
1809 /** 1910 /**
1810 * Associate an external string resource with this string by transforming it 1911 * Associate an external string resource with this string by transforming it
1811 * in place so that existing references to this string in the JavaScript heap 1912 * in place so that existing references to this string in the JavaScript heap
1812 * will use the external string resource. The external string resource's 1913 * will use the external string resource. The external string resource's
1813 * character contents need to be equivalent to this string. 1914 * character contents need to be equivalent to this string.
1814 * Returns true if the string has been changed to be an external string. 1915 * Returns true if the string has been changed to be an external string.
1815 * The string is not modified if the operation fails. See NewExternal for 1916 * The string is not modified if the operation fails. See NewExternal for
1816 * information on the lifetime of the resource. 1917 * information on the lifetime of the resource.
1817 */ 1918 */
1818 bool MakeExternal(ExternalStringResource* resource); 1919 bool MakeExternal(ExternalStringResource* resource);
1819 1920
1820 /** 1921 /**
1821 * Creates a new external string using the ASCII data defined in the given 1922 * Creates a new external string using the ASCII data defined in the given
1822 * resource. When the external string is no longer live on V8's heap the 1923 * resource. When the external string is no longer live on V8's heap the
1823 * resource will be disposed by calling its Dispose method. The caller of 1924 * resource will be disposed by calling its Dispose method. The caller of
1824 * this function should not otherwise delete or modify the resource. Neither 1925 * this function should not otherwise delete or modify the resource. Neither
1825 * should the underlying buffer be deallocated or modified except through the 1926 * should the underlying buffer be deallocated or modified except through the
1826 * destructor of the external string resource. 1927 * destructor of the external string resource.
1827 */ 1928 */
1828 static Local<String> NewExternal(Isolate* isolate, 1929 static Local<String> NewExternal(Isolate* isolate,
1829 ExternalAsciiStringResource* resource); 1930 ExternalAsciiStringResource* resource);
1830 // Will be deprecated soon. 1931 V8_DEPRECATED("Will be removed", static Local<String> NewExternal(
1831 static Local<String> NewExternal(ExternalAsciiStringResource* resource); 1932 ExternalAsciiStringResource* resource));
1832 1933
1833 /** 1934 /**
1834 * Associate an external string resource with this string by transforming it 1935 * Associate an external string resource with this string by transforming it
1835 * in place so that existing references to this string in the JavaScript heap 1936 * in place so that existing references to this string in the JavaScript heap
1836 * will use the external string resource. The external string resource's 1937 * will use the external string resource. The external string resource's
1837 * character contents need to be equivalent to this string. 1938 * character contents need to be equivalent to this string.
1838 * Returns true if the string has been changed to be an external string. 1939 * Returns true if the string has been changed to be an external string.
1839 * The string is not modified if the operation fails. See NewExternal for 1940 * The string is not modified if the operation fails. See NewExternal for
1840 * information on the lifetime of the resource. 1941 * information on the lifetime of the resource.
1841 */ 1942 */
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
2379 * Clones an element at index |index|. Returns an empty 2480 * Clones an element at index |index|. Returns an empty
2380 * handle if cloning fails (for any reason). 2481 * handle if cloning fails (for any reason).
2381 */ 2482 */
2382 Local<Object> CloneElementAt(uint32_t index); 2483 Local<Object> CloneElementAt(uint32_t index);
2383 2484
2384 /** 2485 /**
2385 * Creates a JavaScript array with the given length. If the length 2486 * Creates a JavaScript array with the given length. If the length
2386 * is negative the returned array will have length 0. 2487 * is negative the returned array will have length 0.
2387 */ 2488 */
2388 static Local<Array> New(Isolate* isolate, int length = 0); 2489 static Local<Array> New(Isolate* isolate, int length = 0);
2389 // Will be deprecated soon. 2490 V8_DEPRECATED("Will be removed", static Local<Array> New(int length = 0));
2390 static Local<Array> New(int length = 0);
2391 2491
2392 V8_INLINE static Array* Cast(Value* obj); 2492 V8_INLINE static Array* Cast(Value* obj);
2393 private: 2493 private:
2394 Array(); 2494 Array();
2395 static void CheckCast(Value* obj); 2495 static void CheckCast(Value* obj);
2396 }; 2496 };
2397 2497
2398 2498
2399 template<typename T> 2499 template<typename T>
2400 class ReturnValue { 2500 class ReturnValue {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2644 */ 2744 */
2645 size_t ByteLength() const; 2745 size_t ByteLength() const;
2646 2746
2647 /** 2747 /**
2648 * Create a new ArrayBuffer. Allocate |byte_length| bytes. 2748 * Create a new ArrayBuffer. Allocate |byte_length| bytes.
2649 * Allocated memory will be owned by a created ArrayBuffer and 2749 * Allocated memory will be owned by a created ArrayBuffer and
2650 * will be deallocated when it is garbage-collected, 2750 * will be deallocated when it is garbage-collected,
2651 * unless the object is externalized. 2751 * unless the object is externalized.
2652 */ 2752 */
2653 static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length); 2753 static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
2654 // Will be deprecated soon. 2754 V8_DEPRECATED("Will be removed",
2655 static Local<ArrayBuffer> New(size_t byte_length); 2755 static Local<ArrayBuffer> New(size_t byte_length));
2656 2756
2657 /** 2757 /**
2658 * Create a new ArrayBuffer over an existing memory block. 2758 * Create a new ArrayBuffer over an existing memory block.
2659 * The created array buffer is immediately in externalized state. 2759 * The created array buffer is immediately in externalized state.
2660 * The memory block will not be reclaimed when a created ArrayBuffer 2760 * The memory block will not be reclaimed when a created ArrayBuffer
2661 * is garbage-collected. 2761 * is garbage-collected.
2662 */ 2762 */
2663 static Local<ArrayBuffer> New(Isolate* isolate, void* data, 2763 static Local<ArrayBuffer> New(Isolate* isolate, void* data,
2664 size_t byte_length); 2764 size_t byte_length);
2665 // Will be deprecated soon. 2765 V8_DEPRECATED("Will be removed",
2666 static Local<ArrayBuffer> New(void* data, size_t byte_length); 2766 static Local<ArrayBuffer> New(void* data, size_t byte_length));
2667 2767
2668 /** 2768 /**
2669 * Returns true if ArrayBuffer is extrenalized, that is, does not 2769 * Returns true if ArrayBuffer is extrenalized, that is, does not
2670 * own its memory block. 2770 * own its memory block.
2671 */ 2771 */
2672 bool IsExternal() const; 2772 bool IsExternal() const;
2673 2773
2674 /** 2774 /**
2675 * Neuters this ArrayBuffer and all its views (typed arrays). 2775 * Neuters this ArrayBuffer and all its views (typed arrays).
2676 * Neutering sets the byte length of the buffer and all typed arrays to zero, 2776 * Neutering sets the byte length of the buffer and all typed arrays to zero,
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 static void CheckCast(Value* obj); 3017 static void CheckCast(Value* obj);
2918 }; 3018 };
2919 3019
2920 3020
2921 /** 3021 /**
2922 * An instance of the built-in Date constructor (ECMA-262, 15.9). 3022 * An instance of the built-in Date constructor (ECMA-262, 15.9).
2923 */ 3023 */
2924 class V8_EXPORT Date : public Object { 3024 class V8_EXPORT Date : public Object {
2925 public: 3025 public:
2926 static Local<Value> New(Isolate* isolate, double time); 3026 static Local<Value> New(Isolate* isolate, double time);
2927 // Will be deprecated soon. 3027 V8_DEPRECATED("Will be removed", static Local<Value> New(double time));
2928 static Local<Value> New(double time);
2929 3028
2930 V8_DEPRECATED( 3029 V8_DEPRECATED(
2931 "Use ValueOf instead", 3030 "Use ValueOf instead",
2932 double NumberValue() const) { return ValueOf(); } 3031 double NumberValue() const) { return ValueOf(); }
2933 3032
2934 /** 3033 /**
2935 * A specialization of Value::NumberValue that is more efficient 3034 * A specialization of Value::NumberValue that is more efficient
2936 * because we know the structure of this object. 3035 * because we know the structure of this object.
2937 */ 3036 */
2938 double ValueOf() const; 3037 double ValueOf() const;
2939 3038
2940 V8_INLINE static Date* Cast(v8::Value* obj); 3039 V8_INLINE static Date* Cast(v8::Value* obj);
2941 3040
2942 /** 3041 /**
2943 * Notification that the embedder has changed the time zone, 3042 * Notification that the embedder has changed the time zone,
2944 * daylight savings time, or other date / time configuration 3043 * daylight savings time, or other date / time configuration
2945 * parameters. V8 keeps a cache of various values used for 3044 * parameters. V8 keeps a cache of various values used for
2946 * date / time computation. This notification will reset 3045 * date / time computation. This notification will reset
2947 * those cached values for the current context so that date / 3046 * those cached values for the current context so that date /
2948 * time configuration changes would be reflected in the Date 3047 * time configuration changes would be reflected in the Date
2949 * object. 3048 * object.
2950 * 3049 *
2951 * This API should not be called more than needed as it will 3050 * This API should not be called more than needed as it will
2952 * negatively impact the performance of date operations. 3051 * negatively impact the performance of date operations.
2953 */ 3052 */
2954 static void DateTimeConfigurationChangeNotification(Isolate* isolate); 3053 static void DateTimeConfigurationChangeNotification(Isolate* isolate);
2955 // Will be deprecated soon. 3054 V8_DEPRECATED("Will be removed",
2956 static void DateTimeConfigurationChangeNotification(); 3055 static void DateTimeConfigurationChangeNotification());
2957 3056
2958 private: 3057 private:
2959 static void CheckCast(v8::Value* obj); 3058 static void CheckCast(v8::Value* obj);
2960 }; 3059 };
2961 3060
2962 3061
2963 /** 3062 /**
2964 * A Number object (ECMA-262, 4.3.21). 3063 * A Number object (ECMA-262, 4.3.21).
2965 */ 3064 */
2966 class V8_EXPORT NumberObject : public Object { 3065 class V8_EXPORT NumberObject : public Object {
2967 public: 3066 public:
2968 static Local<Value> New(Isolate* isolate, double value); 3067 static Local<Value> New(Isolate* isolate, double value);
2969 // Will be deprecated soon. 3068 V8_DEPRECATED("Will be removed", static Local<Value> New(double value));
2970 static Local<Value> New(double value);
2971 3069
2972 V8_DEPRECATED( 3070 V8_DEPRECATED(
2973 "Use ValueOf instead", 3071 "Use ValueOf instead",
2974 double NumberValue() const) { return ValueOf(); } 3072 double NumberValue() const) { return ValueOf(); }
2975 3073
2976 /** 3074 /**
2977 * Returns the Number held by the object. 3075 * Returns the Number held by the object.
2978 */ 3076 */
2979 double ValueOf() const; 3077 double ValueOf() const;
2980 3078
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3122 3220
3123 /** 3221 /**
3124 * The superclass of object and function templates. 3222 * The superclass of object and function templates.
3125 */ 3223 */
3126 class V8_EXPORT Template : public Data { 3224 class V8_EXPORT Template : public Data {
3127 public: 3225 public:
3128 /** Adds a property to each instance created by this template.*/ 3226 /** Adds a property to each instance created by this template.*/
3129 void Set(Handle<String> name, Handle<Data> value, 3227 void Set(Handle<String> name, Handle<Data> value,
3130 PropertyAttribute attributes = None); 3228 PropertyAttribute attributes = None);
3131 V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value); 3229 V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value);
3132 // Will be deprecated soon. 3230 V8_DEPRECATED("Will be removed",
3133 V8_INLINE void Set(const char* name, Handle<Data> value); 3231 V8_INLINE void Set(const char* name, Handle<Data> value));
3134 3232
3135 void SetAccessorProperty( 3233 void SetAccessorProperty(
3136 Local<String> name, 3234 Local<String> name,
3137 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), 3235 Local<FunctionTemplate> getter = Local<FunctionTemplate>(),
3138 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), 3236 Local<FunctionTemplate> setter = Local<FunctionTemplate>(),
3139 PropertyAttribute attribute = None, 3237 PropertyAttribute attribute = None,
3140 AccessControl settings = DEFAULT); 3238 AccessControl settings = DEFAULT);
3141 3239
3142 /** 3240 /**
3143 * Whenever the property with the given name is accessed on objects 3241 * Whenever the property with the given name is accessed on objects
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
3659 * A Signature specifies which receivers and arguments are valid 3757 * A Signature specifies which receivers and arguments are valid
3660 * parameters to a function. 3758 * parameters to a function.
3661 */ 3759 */
3662 class V8_EXPORT Signature : public Data { 3760 class V8_EXPORT Signature : public Data {
3663 public: 3761 public:
3664 static Local<Signature> New(Isolate* isolate, 3762 static Local<Signature> New(Isolate* isolate,
3665 Handle<FunctionTemplate> receiver = 3763 Handle<FunctionTemplate> receiver =
3666 Handle<FunctionTemplate>(), 3764 Handle<FunctionTemplate>(),
3667 int argc = 0, 3765 int argc = 0,
3668 Handle<FunctionTemplate> argv[] = 0); 3766 Handle<FunctionTemplate> argv[] = 0);
3669 // Will be deprecated soon. 3767 V8_DEPRECATED("Will be removed",
3670 static Local<Signature> New(Handle<FunctionTemplate> receiver = 3768 static Local<Signature> New(Handle<FunctionTemplate> receiver =
3671 Handle<FunctionTemplate>(), 3769 Handle<FunctionTemplate>(),
3672 int argc = 0, 3770 int argc = 0,
3673 Handle<FunctionTemplate> argv[] = 0); 3771 Handle<FunctionTemplate> argv[] =
3772 0));
3773
3674 private: 3774 private:
3675 Signature(); 3775 Signature();
3676 }; 3776 };
3677 3777
3678 3778
3679 /** 3779 /**
3680 * An AccessorSignature specifies which receivers are valid parameters 3780 * An AccessorSignature specifies which receivers are valid parameters
3681 * to an accessor callback. 3781 * to an accessor callback.
3682 */ 3782 */
3683 class V8_EXPORT AccessorSignature : public Data { 3783 class V8_EXPORT AccessorSignature : public Data {
3684 public: 3784 public:
3685 static Local<AccessorSignature> New(Isolate* isolate, 3785 static Local<AccessorSignature> New(Isolate* isolate,
3686 Handle<FunctionTemplate> receiver = 3786 Handle<FunctionTemplate> receiver =
3687 Handle<FunctionTemplate>()); 3787 Handle<FunctionTemplate>());
3688 // Will be deprecated soon. 3788 V8_DEPRECATED("Will be removed", static Local<AccessorSignature> New(
3689 static Local<AccessorSignature> New(Handle<FunctionTemplate> receiver = 3789 Handle<FunctionTemplate> receiver =
3690 Handle<FunctionTemplate>()); 3790 Handle<FunctionTemplate>()));
3691 3791
3692 private: 3792 private:
3693 AccessorSignature(); 3793 AccessorSignature();
3694 }; 3794 };
3695 3795
3696 3796
3697 class V8_EXPORT DeclaredAccessorDescriptor : public Data { 3797 class V8_EXPORT DeclaredAccessorDescriptor : public Data {
3698 private: 3798 private:
3699 DeclaredAccessorDescriptor(); 3799 DeclaredAccessorDescriptor();
3700 }; 3800 };
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3787 // Note that the strings passed into this constructor must live as long 3887 // Note that the strings passed into this constructor must live as long
3788 // as the Extension itself. 3888 // as the Extension itself.
3789 Extension(const char* name, 3889 Extension(const char* name,
3790 const char* source = 0, 3890 const char* source = 0,
3791 int dep_count = 0, 3891 int dep_count = 0,
3792 const char** deps = 0, 3892 const char** deps = 0,
3793 int source_length = -1); 3893 int source_length = -1);
3794 virtual ~Extension() { } 3894 virtual ~Extension() { }
3795 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( 3895 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
3796 v8::Isolate* isolate, v8::Handle<v8::String> name) { 3896 v8::Isolate* isolate, v8::Handle<v8::String> name) {
3897 #if defined(V8_DEPRECATION_WARNINGS)
3898 return v8::Handle<v8::FunctionTemplate>();
3899 #else
3797 return GetNativeFunction(name); 3900 return GetNativeFunction(name);
3901 #endif
3798 } 3902 }
3799 // Will be deprecated soon. 3903
3800 virtual v8::Handle<v8::FunctionTemplate> 3904 V8_DEPRECATED("Will be removed",
3801 GetNativeFunction(v8::Handle<v8::String> name) { 3905 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
3906 v8::Handle<v8::String> name)) {
3802 return v8::Handle<v8::FunctionTemplate>(); 3907 return v8::Handle<v8::FunctionTemplate>();
3803 } 3908 }
3804 3909
3805 const char* name() const { return name_; } 3910 const char* name() const { return name_; }
3806 size_t source_length() const { return source_length_; } 3911 size_t source_length() const { return source_length_; }
3807 const String::ExternalAsciiStringResource* source() const { 3912 const String::ExternalAsciiStringResource* source() const {
3808 return &source_; } 3913 return &source_; }
3809 int dependency_count() { return dep_count_; } 3914 int dependency_count() { return dep_count_; }
3810 const char** dependencies() { return deps_; } 3915 const char** dependencies() { return deps_; }
3811 void set_auto_enable(bool value) { auto_enable_ = value; } 3916 void set_auto_enable(bool value) { auto_enable_ = value; }
(...skipping 27 matching lines...) Expand all
3839 }; 3944 };
3840 3945
3841 3946
3842 // --- Statics --- 3947 // --- Statics ---
3843 3948
3844 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate); 3949 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate);
3845 V8_INLINE Handle<Primitive> Null(Isolate* isolate); 3950 V8_INLINE Handle<Primitive> Null(Isolate* isolate);
3846 V8_INLINE Handle<Boolean> True(Isolate* isolate); 3951 V8_INLINE Handle<Boolean> True(Isolate* isolate);
3847 V8_INLINE Handle<Boolean> False(Isolate* isolate); 3952 V8_INLINE Handle<Boolean> False(Isolate* isolate);
3848 3953
3849 // Will be removed soon. 3954 V8_DEPRECATED("Will be removed", Handle<Primitive> V8_EXPORT Undefined());
3850 Handle<Primitive> V8_EXPORT Undefined(); 3955 V8_DEPRECATED("Will be removed", Handle<Primitive> V8_EXPORT Null());
3851 Handle<Primitive> V8_EXPORT Null(); 3956 V8_DEPRECATED("Will be removed", Handle<Boolean> V8_EXPORT True());
3852 Handle<Boolean> V8_EXPORT True(); 3957 V8_DEPRECATED("Will be removed", Handle<Boolean> V8_EXPORT False());
3853 Handle<Boolean> V8_EXPORT False();
3854 3958
3855 3959
3856 /** 3960 /**
3857 * A set of constraints that specifies the limits of the runtime's memory use. 3961 * A set of constraints that specifies the limits of the runtime's memory use.
3858 * You must set the heap size before initializing the VM - the size cannot be 3962 * You must set the heap size before initializing the VM - the size cannot be
3859 * adjusted after the VM is initialized. 3963 * adjusted after the VM is initialized.
3860 * 3964 *
3861 * If you are using threads then you should hold the V8::Locker lock while 3965 * If you are using threads then you should hold the V8::Locker lock while
3862 * setting the stack limit and you must set a non-default stack limit separately 3966 * setting the stack limit and you must set a non-default stack limit separately
3863 * for each thread. 3967 * for each thread.
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
4879 RevivableCallback weak_reference_callback); 4983 RevivableCallback weak_reference_callback);
4880 static void ClearWeak(internal::Object** global_handle); 4984 static void ClearWeak(internal::Object** global_handle);
4881 static void Eternalize(Isolate* isolate, 4985 static void Eternalize(Isolate* isolate,
4882 Value* handle, 4986 Value* handle,
4883 int* index); 4987 int* index);
4884 static Local<Value> GetEternal(Isolate* isolate, int index); 4988 static Local<Value> GetEternal(Isolate* isolate, int index);
4885 4989
4886 template <class T> friend class Handle; 4990 template <class T> friend class Handle;
4887 template <class T> friend class Local; 4991 template <class T> friend class Local;
4888 template <class T> friend class Eternal; 4992 template <class T> friend class Eternal;
4993 template <class T> friend class PersistentBase;
4889 template <class T, class M> friend class Persistent; 4994 template <class T, class M> friend class Persistent;
4890 friend class Context; 4995 friend class Context;
4891 }; 4996 };
4892 4997
4893 4998
4894 /** 4999 /**
4895 * An external exception handler. 5000 * An external exception handler.
4896 */ 5001 */
4897 class V8_EXPORT TryCatch { 5002 class V8_EXPORT TryCatch {
4898 public: 5003 public:
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
5671 template <class T> 5776 template <class T>
5672 Local<T>::Local() : Handle<T>() { } 5777 Local<T>::Local() : Handle<T>() { }
5673 5778
5674 5779
5675 template <class T> 5780 template <class T>
5676 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) { 5781 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) {
5677 return New(isolate, that.val_); 5782 return New(isolate, that.val_);
5678 } 5783 }
5679 5784
5680 template <class T> 5785 template <class T>
5681 template <class M> 5786 Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) {
5682 Local<T> Local<T>::New(Isolate* isolate, const Persistent<T, M>& that) {
5683 return New(isolate, that.val_); 5787 return New(isolate, that.val_);
5684 } 5788 }
5685 5789
5686 template <class T> 5790 template <class T>
5687 Handle<T> Handle<T>::New(Isolate* isolate, T* that) { 5791 Handle<T> Handle<T>::New(Isolate* isolate, T* that) {
5688 if (that == NULL) return Handle<T>(); 5792 if (that == NULL) return Handle<T>();
5689 T* that_ptr = that; 5793 T* that_ptr = that;
5690 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); 5794 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
5691 return Handle<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( 5795 return Handle<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
5692 reinterpret_cast<internal::Isolate*>(isolate), *p))); 5796 reinterpret_cast<internal::Isolate*>(isolate), *p)));
(...skipping 17 matching lines...) Expand all
5710 V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle), &this->index_); 5814 V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle), &this->index_);
5711 } 5815 }
5712 5816
5713 5817
5714 template<class T> 5818 template<class T>
5715 Local<T> Eternal<T>::Get(Isolate* isolate) { 5819 Local<T> Eternal<T>::Get(Isolate* isolate) {
5716 return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_))); 5820 return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_)));
5717 } 5821 }
5718 5822
5719 5823
5720 template <class T, class M> 5824 template <class T>
5721 T* Persistent<T, M>::New(Isolate* isolate, T* that) { 5825 T* PersistentBase<T>::New(Isolate* isolate, T* that) {
5722 if (that == NULL) return NULL; 5826 if (that == NULL) return NULL;
5723 internal::Object** p = reinterpret_cast<internal::Object**>(that); 5827 internal::Object** p = reinterpret_cast<internal::Object**>(that);
5724 return reinterpret_cast<T*>( 5828 return reinterpret_cast<T*>(
5725 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), 5829 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
5726 p)); 5830 p));
5727 } 5831 }
5728 5832
5729 5833
5730 template <class T, class M> 5834 template <class T, class M>
5731 template <class S, class M2> 5835 template <class S, class M2>
5732 void Persistent<T, M>::Copy(const Persistent<S, M2>& that) { 5836 void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
5733 TYPE_CHECK(T, S); 5837 TYPE_CHECK(T, S);
5734 Reset(); 5838 this->Reset();
5735 if (that.IsEmpty()) return; 5839 if (that.IsEmpty()) return;
5736 internal::Object** p = reinterpret_cast<internal::Object**>(that.val_); 5840 internal::Object** p = reinterpret_cast<internal::Object**>(that.val_);
5737 this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p)); 5841 this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p));
5738 M::Copy(that, this); 5842 M::Copy(that, this);
5739 } 5843 }
5740 5844
5741 5845
5742 template <class T, class M> 5846 template <class T>
5743 bool Persistent<T, M>::IsIndependent() const { 5847 bool PersistentBase<T>::IsIndependent() const {
5744 typedef internal::Internals I; 5848 typedef internal::Internals I;
5745 if (this->IsEmpty()) return false; 5849 if (this->IsEmpty()) return false;
5746 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_), 5850 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
5747 I::kNodeIsIndependentShift); 5851 I::kNodeIsIndependentShift);
5748 } 5852 }
5749 5853
5750 5854
5751 template <class T, class M> 5855 template <class T>
5752 bool Persistent<T, M>::IsNearDeath() const { 5856 bool PersistentBase<T>::IsNearDeath() const {
5753 typedef internal::Internals I; 5857 typedef internal::Internals I;
5754 if (this->IsEmpty()) return false; 5858 if (this->IsEmpty()) return false;
5755 uint8_t node_state = 5859 uint8_t node_state =
5756 I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)); 5860 I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_));
5757 return node_state == I::kNodeStateIsNearDeathValue || 5861 return node_state == I::kNodeStateIsNearDeathValue ||
5758 node_state == I::kNodeStateIsPendingValue; 5862 node_state == I::kNodeStateIsPendingValue;
5759 } 5863 }
5760 5864
5761 5865
5762 template <class T, class M> 5866 template <class T>
5763 bool Persistent<T, M>::IsWeak() const { 5867 bool PersistentBase<T>::IsWeak() const {
5764 typedef internal::Internals I; 5868 typedef internal::Internals I;
5765 if (this->IsEmpty()) return false; 5869 if (this->IsEmpty()) return false;
5766 return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) == 5870 return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) ==
5767 I::kNodeStateIsWeakValue; 5871 I::kNodeStateIsWeakValue;
5768 } 5872 }
5769 5873
5770 5874
5771 template <class T, class M> 5875 template <class T>
5772 void Persistent<T, M>::Reset() { 5876 void PersistentBase<T>::Reset() {
5773 if (this->IsEmpty()) return; 5877 if (this->IsEmpty()) return;
5774 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_)); 5878 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_));
5775 val_ = 0; 5879 val_ = 0;
5776 } 5880 }
5777 5881
5778 5882
5779 template <class T, class M> 5883 template <class T>
5780 template <class S> 5884 template <class S>
5781 void Persistent<T, M>::Reset(Isolate* isolate, const Handle<S>& other) { 5885 void PersistentBase<T>::Reset(Isolate* isolate, const Handle<S>& other) {
5782 TYPE_CHECK(T, S); 5886 TYPE_CHECK(T, S);
5783 Reset(); 5887 Reset();
5784 if (other.IsEmpty()) return; 5888 if (other.IsEmpty()) return;
5785 this->val_ = New(isolate, other.val_); 5889 this->val_ = New(isolate, other.val_);
5786 } 5890 }
5787 5891
5788 5892
5789 template <class T, class M> 5893 template <class T>
5790 template <class S, class M2> 5894 template <class S>
5791 void Persistent<T, M>::Reset(Isolate* isolate, 5895 void PersistentBase<T>::Reset(Isolate* isolate,
5792 const Persistent<S, M2>& other) { 5896 const PersistentBase<S>& other) {
5793 TYPE_CHECK(T, S); 5897 TYPE_CHECK(T, S);
5794 Reset(); 5898 Reset();
5795 if (other.IsEmpty()) return; 5899 if (other.IsEmpty()) return;
5796 this->val_ = New(isolate, other.val_); 5900 this->val_ = New(isolate, other.val_);
5797 } 5901 }
5798 5902
5799 5903
5800 template <class T, class M> 5904 template <class T>
5801 template <typename S, typename P> 5905 template <typename S, typename P>
5802 void Persistent<T, M>::SetWeak( 5906 void PersistentBase<T>::SetWeak(
5803 P* parameter, 5907 P* parameter,
5804 typename WeakCallbackData<S, P>::Callback callback) { 5908 typename WeakCallbackData<S, P>::Callback callback) {
5805 TYPE_CHECK(S, T); 5909 TYPE_CHECK(S, T);
5806 typedef typename WeakCallbackData<Value, void>::Callback Callback; 5910 typedef typename WeakCallbackData<Value, void>::Callback Callback;
5807 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), 5911 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
5808 parameter, 5912 parameter,
5809 reinterpret_cast<Callback>(callback), 5913 reinterpret_cast<Callback>(callback),
5810 NULL); 5914 NULL);
5811 } 5915 }
5812 5916
5813 5917
5814 template <class T, class M> 5918 template <class T>
5815 template <typename P> 5919 template <typename P>
5816 void Persistent<T, M>::SetWeak( 5920 void PersistentBase<T>::SetWeak(
5817 P* parameter, 5921 P* parameter,
5818 typename WeakCallbackData<T, P>::Callback callback) { 5922 typename WeakCallbackData<T, P>::Callback callback) {
5819 SetWeak<T, P>(parameter, callback); 5923 SetWeak<T, P>(parameter, callback);
5820 } 5924 }
5821 5925
5822 5926
5823 template <class T, class M> 5927 template <class T, class M>
5824 template <typename S, typename P> 5928 template <typename S, typename P>
5825 void Persistent<T, M>::MakeWeak( 5929 void Persistent<T, M>::MakeWeak(
5826 P* parameters, 5930 P* parameters,
5827 typename WeakReferenceCallbacks<S, P>::Revivable callback) { 5931 typename WeakReferenceCallbacks<S, P>::Revivable callback) {
5828 TYPE_CHECK(S, T); 5932 TYPE_CHECK(S, T);
5829 typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable; 5933 typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable;
5830 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), 5934 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
5831 parameters, 5935 parameters,
5832 NULL, 5936 NULL,
5833 reinterpret_cast<Revivable>(callback)); 5937 reinterpret_cast<Revivable>(callback));
5834 } 5938 }
5835 5939
5836 5940
5837 template <class T, class M> 5941 template <class T, class M>
5838 template <typename P> 5942 template <typename P>
5839 void Persistent<T, M>::MakeWeak( 5943 void Persistent<T, M>::MakeWeak(
5840 P* parameters, 5944 P* parameters,
5841 typename WeakReferenceCallbacks<T, P>::Revivable callback) { 5945 typename WeakReferenceCallbacks<T, P>::Revivable callback) {
5842 MakeWeak<T, P>(parameters, callback); 5946 MakeWeak<T, P>(parameters, callback);
5843 } 5947 }
5844 5948
5845 5949
5846 template <class T, class M> 5950 template <class T>
5847 void Persistent<T, M>::ClearWeak() { 5951 void PersistentBase<T>::ClearWeak() {
5848 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)); 5952 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_));
5849 } 5953 }
5850 5954
5851 5955
5852 template <class T, class M> 5956 template <class T>
5853 void Persistent<T, M>::MarkIndependent() { 5957 void PersistentBase<T>::MarkIndependent() {
5854 typedef internal::Internals I; 5958 typedef internal::Internals I;
5855 if (this->IsEmpty()) return; 5959 if (this->IsEmpty()) return;
5856 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), 5960 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
5857 true, 5961 true,
5858 I::kNodeIsIndependentShift); 5962 I::kNodeIsIndependentShift);
5859 } 5963 }
5860 5964
5861 5965
5862 template <class T, class M> 5966 template <class T>
5863 void Persistent<T, M>::MarkPartiallyDependent() { 5967 void PersistentBase<T>::MarkPartiallyDependent() {
5864 typedef internal::Internals I; 5968 typedef internal::Internals I;
5865 if (this->IsEmpty()) return; 5969 if (this->IsEmpty()) return;
5866 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), 5970 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
5867 true, 5971 true,
5868 I::kNodeIsPartiallyDependentShift); 5972 I::kNodeIsPartiallyDependentShift);
5869 } 5973 }
5870 5974
5871 5975
5872 template <class T, class M> 5976 template <class T, class M>
5873 T* Persistent<T, M>::ClearAndLeak() { 5977 T* Persistent<T, M>::ClearAndLeak() {
5874 T* old; 5978 T* old;
5875 old = val_; 5979 old = this->val_;
5876 val_ = NULL; 5980 this->val_ = NULL;
5877 return old; 5981 return old;
5878 } 5982 }
5879 5983
5880 5984
5881 template <class T, class M> 5985 template <class T>
5882 void Persistent<T, M>::SetWrapperClassId(uint16_t class_id) { 5986 void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
5883 typedef internal::Internals I; 5987 typedef internal::Internals I;
5884 if (this->IsEmpty()) return; 5988 if (this->IsEmpty()) return;
5885 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); 5989 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
5886 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; 5990 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
5887 *reinterpret_cast<uint16_t*>(addr) = class_id; 5991 *reinterpret_cast<uint16_t*>(addr) = class_id;
5888 } 5992 }
5889 5993
5890 5994
5891 template <class T, class M> 5995 template <class T>
5892 uint16_t Persistent<T, M>::WrapperClassId() const { 5996 uint16_t PersistentBase<T>::WrapperClassId() const {
5893 typedef internal::Internals I; 5997 typedef internal::Internals I;
5894 if (this->IsEmpty()) return 0; 5998 if (this->IsEmpty()) return 0;
5895 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); 5999 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
5896 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; 6000 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
5897 return *reinterpret_cast<uint16_t*>(addr); 6001 return *reinterpret_cast<uint16_t*>(addr);
5898 } 6002 }
5899 6003
5900 6004
5901 template<typename T> 6005 template<typename T>
5902 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} 6006 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {}
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
6655 */ 6759 */
6656 6760
6657 6761
6658 } // namespace v8 6762 } // namespace v8
6659 6763
6660 6764
6661 #undef TYPE_CHECK 6765 #undef TYPE_CHECK
6662 6766
6663 6767
6664 #endif // V8_H_ 6768 #endif // V8_H_
OLDNEW
« no previous file with comments | « Makefile ('k') | src/a64/full-codegen-a64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698