Revision f230a1cf deps/v8/include/v8.h

View differences:

deps/v8/include/v8.h
135 135
class ObjectOperationDescriptor;
136 136
class RawOperationDescriptor;
137 137
class CallHandlerHelper;
138
class EscapableHandleScope;
138 139

  
139 140
namespace internal {
140 141
class Arguments;
......
377 378
   * The referee is kept alive by the local handle even when
378 379
   * the original handle is destroyed/disposed.
379 380
   */
380
  V8_INLINE static Local<T> New(Handle<T> that);
381 381
  V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that);
382 382
  template<class M>
383 383
  V8_INLINE static Local<T> New(Isolate* isolate,
......
401 401
  friend class Context;
402 402
  template<class F> friend class internal::CustomArguments;
403 403
  friend class HandleScope;
404
  friend class EscapableHandleScope;
404 405

  
405 406
  V8_INLINE static Local<T> New(Isolate* isolate, T* that);
406 407
};
......
480 481

  
481 482

  
482 483
/**
484
 * Helper class traits to allow copying and assignment of Persistent.
485
 * This will clone the contents of storage cell, but not any of the flags, etc.
486
 */
487
template<class T>
488
struct CopyablePersistentTraits {
489
  typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
490
  static const bool kResetInDestructor = true;
491
  template<class S, class M>
492
  static V8_INLINE void Copy(const Persistent<S, M>& source,
493
                             CopyablePersistent* dest) {
494
    // do nothing, just allow copy
495
  }
496
};
497

  
498

  
499
/**
483 500
 * An object reference that is independent of any handle scope.  Where
484 501
 * a Local handle only lives as long as the HandleScope in which it was
485 502
 * allocated, a Persistent handle remains valid until it is explicitly
......
567 584
   */
568 585
  template <class S, class M2>
569 586
  V8_INLINE void Reset(Isolate* isolate, const Persistent<S, M2>& other);
570
  // TODO(dcarney): deprecate
571
  V8_INLINE void Dispose() { Reset(); }
572
  V8_DEPRECATED(V8_INLINE void Dispose(Isolate* isolate)) { Reset(); }
587

  
588
  V8_DEPRECATED("Use Reset instead",
589
                V8_INLINE void Dispose()) { Reset(); }
573 590

  
574 591
  V8_INLINE bool IsEmpty() const { return val_ == 0; }
575 592

  
......
625 642
      P* parameter,
626 643
      typename WeakCallbackData<S, P>::Callback callback);
627 644

  
628
  // TODO(dcarney): deprecate
629 645
  template<typename S, typename P>
630
  V8_INLINE void MakeWeak(
631
      P* parameter,
632
      typename WeakReferenceCallbacks<S, P>::Revivable callback);
646
  V8_DEPRECATED(
647
      "Use SetWeak instead",
648
      V8_INLINE void MakeWeak(
649
          P* parameter,
650
          typename WeakReferenceCallbacks<S, P>::Revivable callback));
633 651

  
634
  // TODO(dcarney): deprecate
635 652
  template<typename P>
636
  V8_INLINE void MakeWeak(
637
      P* parameter,
638
      typename WeakReferenceCallbacks<T, P>::Revivable callback);
653
  V8_DEPRECATED(
654
      "Use SetWeak instead",
655
      V8_INLINE void MakeWeak(
656
          P* parameter,
657
          typename WeakReferenceCallbacks<T, P>::Revivable callback));
639 658

  
640 659
  V8_INLINE void ClearWeak();
641 660

  
642
  V8_DEPRECATED(V8_INLINE void ClearWeak(Isolate* isolate)) { ClearWeak(); }
643

  
644 661
  /**
645 662
   * Marks the reference to this object independent. Garbage collector is free
646 663
   * to ignore any object groups containing this object. Weak callback for an
......
649 666
   */
650 667
  V8_INLINE void MarkIndependent();
651 668

  
652
  V8_DEPRECATED(V8_INLINE void MarkIndependent(Isolate* isolate)) {
653
    MarkIndependent();
654
  }
655

  
656 669
  /**
657 670
   * Marks the reference to this object partially dependent. Partially dependent
658 671
   * handles only depend on other partially dependent handles and these
......
663 676
   */
664 677
  V8_INLINE void MarkPartiallyDependent();
665 678

  
666
  V8_DEPRECATED(V8_INLINE void MarkPartiallyDependent(Isolate* isolate)) {
667
    MarkPartiallyDependent();
668
  }
669

  
670 679
  V8_INLINE bool IsIndependent() const;
671 680

  
672
  V8_DEPRECATED(V8_INLINE bool IsIndependent(Isolate* isolate) const) {
673
    return IsIndependent();
674
  }
675

  
676 681
  /** Checks if the handle holds the only reference to an object. */
677 682
  V8_INLINE bool IsNearDeath() const;
678 683

  
679
  V8_DEPRECATED(V8_INLINE bool IsNearDeath(Isolate* isolate) const) {
680
    return IsNearDeath();
681
  }
682

  
683 684
  /** Returns true if the handle's reference is weak.  */
684 685
  V8_INLINE bool IsWeak() const;
685 686

  
686
  V8_DEPRECATED(V8_INLINE bool IsWeak(Isolate* isolate) const) {
687
    return IsWeak();
688
  }
689

  
690 687
  /**
691 688
   * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface
692 689
   * description in v8-profiler.h for details.
693 690
   */
694 691
  V8_INLINE void SetWrapperClassId(uint16_t class_id);
695 692

  
696
  V8_DEPRECATED(
697
      V8_INLINE void SetWrapperClassId(Isolate * isolate, uint16_t class_id)) {
698
    SetWrapperClassId(class_id);
699
  }
700

  
701 693
  /**
702 694
   * Returns the class ID previously assigned to this handle or 0 if no class ID
703 695
   * was previously assigned.
704 696
   */
705 697
  V8_INLINE uint16_t WrapperClassId() const;
706 698

  
707
  V8_DEPRECATED(V8_INLINE uint16_t WrapperClassId(Isolate* isolate) const) {
708
    return WrapperClassId();
709
  }
710

  
711
  // TODO(dcarney): remove
712
  V8_INLINE T* ClearAndLeak();
699
  V8_DEPRECATED("This will be removed",
700
                V8_INLINE T* ClearAndLeak());
713 701

  
714
  // TODO(dcarney): remove
715
  V8_INLINE void Clear() { val_ = 0; }
702
  V8_DEPRECATED("This will be removed",
703
                V8_INLINE void Clear()) { val_ = 0; }
716 704

  
717 705
  // TODO(dcarney): remove
718 706
#ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
......
724 712
  V8_INLINE T* operator*() const { return val_; }
725 713

  
726 714
 private:
715
  friend class Isolate;
727 716
  friend class Utils;
728 717
  template<class F> friend class Handle;
729 718
  template<class F> friend class Local;
......
757 746

  
758 747
  ~HandleScope();
759 748

  
760
  /**
761
   * Closes the handle scope and returns the value as a handle in the
762
   * previous scope, which is the new current scope after the call.
763
   */
764
  template <class T> Local<T> Close(Handle<T> value);
749
  template <class T>
750
  V8_DEPRECATED("Use EscapableHandleScope::Escape instead",
751
                Local<T> Close(Handle<T> value));
765 752

  
766 753
  /**
767 754
   * Counts the number of allocated handles.
768 755
   */
769 756
  static int NumberOfHandles();
770 757

  
758
 private:
771 759
  /**
772 760
   * Creates a new handle with the given value.
773 761
   */
774
  static internal::Object** CreateHandle(internal::Object* value);
775 762
  static internal::Object** CreateHandle(internal::Isolate* isolate,
776 763
                                         internal::Object* value);
777
  // Faster version, uses HeapObject to obtain the current Isolate.
778
  static internal::Object** CreateHandle(internal::HeapObject* value);
764
  // Uses HeapObject to obtain the current Isolate.
765
  static internal::Object** CreateHandle(internal::HeapObject* heap_object,
766
                                         internal::Object* value);
767

  
768
  V8_INLINE HandleScope() {}
769
  void Initialize(Isolate* isolate);
779 770

  
780
 private:
781 771
  // Make it hard to create heap-allocated or illegal handle scopes by
782 772
  // disallowing certain operations.
783 773
  HandleScope(const HandleScope&);
......
798 788
    }
799 789
  };
800 790

  
801
  void Initialize(Isolate* isolate);
802 791
  void Leave();
803 792

  
804 793
  internal::Isolate* isolate_;
805 794
  internal::Object** prev_next_;
806 795
  internal::Object** prev_limit_;
807 796

  
797
  // TODO(dcarney): remove this field
808 798
  // Allow for the active closing of HandleScopes which allows to pass a handle
809 799
  // from the HandleScope being closed to the next top most HandleScope.
810 800
  bool is_closed_;
811 801
  internal::Object** RawClose(internal::Object** value);
812 802

  
813 803
  friend class ImplementationUtilities;
804
  friend class EscapableHandleScope;
805
  template<class F> friend class Handle;
806
  template<class F> friend class Local;
807
  friend class Object;
808
  friend class Context;
809
};
810

  
811

  
812
/**
813
 * A HandleScope which first allocates a handle in the current scope
814
 * which will be later filled with the escape value.
815
 */
816
class V8_EXPORT EscapableHandleScope : public HandleScope {
817
 public:
818
  EscapableHandleScope(Isolate* isolate);
819
  V8_INLINE ~EscapableHandleScope() {}
820

  
821
  /**
822
   * Pushes the value into the previous scope and returns a handle to it.
823
   * Cannot be called twice.
824
   */
825
  template <class T>
826
  V8_INLINE Local<T> Escape(Local<T> value) {
827
    internal::Object** slot =
828
        Escape(reinterpret_cast<internal::Object**>(*value));
829
    return Local<T>(reinterpret_cast<T*>(slot));
830
  }
831

  
832
 private:
833
  internal::Object** Escape(internal::Object** escape_value);
834

  
835
  // Make it hard to create heap-allocated or illegal handle scopes by
836
  // disallowing certain operations.
837
  EscapableHandleScope(const EscapableHandleScope&);
838
  void operator=(const EscapableHandleScope&);
839
  void* operator new(size_t size);
840
  void operator delete(void*, size_t);
841

  
842
  internal::Object** escape_slot_;
814 843
};
815 844

  
816 845

  
......
857 886
   * \param input Pointer to UTF-8 script source code.
858 887
   * \param length Length of UTF-8 script source code.
859 888
   */
860
  static ScriptData* PreCompile(const char* input, int length);
889
  static ScriptData* PreCompile(Isolate* isolate,
890
                                const char* input,
891
                                int length);
861 892

  
862 893
  /**
863 894
   * Pre-compiles the specified script (context-independent).
......
1009 1040

  
1010 1041
  /**
1011 1042
   * Returns the script id value.
1012
   * DEPRECATED: Please use GetId().
1013 1043
   */
1014
  Local<Value> Id();
1044
  V8_DEPRECATED("Use GetId instead", Local<Value> Id());
1015 1045

  
1016 1046
  /**
1017 1047
   * Returns the script id.
......
1463 1493
  /** JS == */
1464 1494
  bool Equals(Handle<Value> that) const;
1465 1495
  bool StrictEquals(Handle<Value> that) const;
1496
  bool SameValue(Handle<Value> that) const;
1466 1497

  
1467 1498
  template <class T> V8_INLINE static Value* Cast(T* value);
1468 1499

  
......
1516 1547
  int Utf8Length() const;
1517 1548

  
1518 1549
  /**
1519
   * This function is no longer useful.
1520
   */
1521
  V8_DEPRECATED(V8_INLINE bool MayContainNonAscii() const) { return true; }
1522

  
1523
  /**
1524 1550
   * Returns whether this string is known to contain only one byte data.
1525 1551
   * Does not read the string.
1526 1552
   * False negatives are possible.
......
1570 1596
            int start = 0,
1571 1597
            int length = -1,
1572 1598
            int options = NO_OPTIONS) const;
1573
  // ASCII characters.
1574
  V8_DEPRECATED(int WriteAscii(char* buffer,
1575
                               int start = 0,
1576
                               int length = -1,
1577
                               int options = NO_OPTIONS) const);
1578 1599
  // One byte characters.
1579 1600
  int WriteOneByte(uint8_t* buffer,
1580 1601
                   int start = 0,
......
1705 1726

  
1706 1727
  V8_INLINE static String* Cast(v8::Value* obj);
1707 1728

  
1708
  // TODO(dcarney): deprecate
1709 1729
  /**
1710 1730
   * Allocates a new string from either UTF-8 encoded or ASCII data.
1711 1731
   * The second parameter 'length' gives the buffer length. If omitted,
1712 1732
   * the function calls 'strlen' to determine the buffer length.
1713 1733
   */
1714
  V8_INLINE static Local<String> New(const char* data, int length = -1);
1734
  V8_DEPRECATED(
1735
      "Use NewFromOneByte instead",
1736
      V8_INLINE static Local<String> New(const char* data, int length = -1));
1715 1737

  
1716
  // TODO(dcarney): deprecate
1717 1738
  /** Allocates a new string from 16-bit character codes.*/
1718
  V8_INLINE static Local<String> New(const uint16_t* data, int length = -1);
1739
  V8_DEPRECATED(
1740
      "Use NewFromTwoByte instead",
1741
      V8_INLINE static Local<String> New(
1742
          const uint16_t* data, int length = -1));
1719 1743

  
1720
  // TODO(dcarney): deprecate
1721 1744
  /**
1722 1745
   * Creates an internalized string (historically called a "symbol",
1723 1746
   * not to be confused with ES6 symbols). Returns one if it exists already.
1724 1747
   */
1725
  V8_INLINE static Local<String> NewSymbol(const char* data, int length = -1);
1748
  V8_DEPRECATED(
1749
      "Use NewFromUtf8 instead",
1750
      V8_INLINE static Local<String> NewSymbol(
1751
          const char* data, int length = -1));
1726 1752

  
1727 1753
  enum NewStringType {
1728 1754
    kNormalString, kInternalizedString, kUndetectableString
......
1801 1827
   */
1802 1828
  bool CanMakeExternal();
1803 1829

  
1804
  // TODO(dcarney): deprecate
1805 1830
  /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/
1806
  V8_INLINE static Local<String> NewUndetectable(const char* data,
1807
                                                 int length = -1);
1831
  V8_DEPRECATED(
1832
      "Use NewFromUtf8 instead",
1833
      V8_INLINE static Local<String> NewUndetectable(const char* data,
1834
                                                     int length = -1));
1808 1835

  
1809
  // TODO(dcarney): deprecate
1810 1836
  /** Creates an undetectable string from the supplied 16-bit character codes.*/
1811
  V8_INLINE static Local<String> NewUndetectable(const uint16_t* data,
1812
                                                 int length = -1);
1837
  V8_DEPRECATED(
1838
      "Use NewFromTwoByte instead",
1839
      V8_INLINE static Local<String> NewUndetectable(const uint16_t* data,
1840
                                                     int length = -1));
1813 1841

  
1814 1842
  /**
1815 1843
   * Converts an object to a UTF-8-encoded character array.  Useful if
......
1843 1871
   */
1844 1872
  class V8_EXPORT AsciiValue {
1845 1873
   public:
1846
    // TODO(dcarney): deprecate
1847
    explicit AsciiValue(Handle<v8::Value> obj);
1874
    V8_DEPRECATED("Use Utf8Value instead",
1875
                  explicit AsciiValue(Handle<v8::Value> obj));
1848 1876
    ~AsciiValue();
1849 1877
    char* operator*() { return str_; }
1850 1878
    const char* operator*() const { return str_; }
......
2265 2293
   * Call an Object as a function if a callback is set by the
2266 2294
   * ObjectTemplate::SetCallAsFunctionHandler method.
2267 2295
   */
2268
  Local<Value> CallAsFunction(Handle<Object> recv,
2296
  Local<Value> CallAsFunction(Handle<Value> recv,
2269 2297
                              int argc,
2270 2298
                              Handle<Value> argv[]);
2271 2299

  
......
2364 2392
  V8_INLINE Isolate* GetIsolate() const;
2365 2393
  V8_INLINE ReturnValue<T> GetReturnValue() const;
2366 2394
  // This shouldn't be public, but the arm compiler needs it.
2367
  static const int kArgsLength = 6;
2395
  static const int kArgsLength = 7;
2368 2396

  
2369 2397
 protected:
2370 2398
  friend class internal::FunctionCallbackArguments;
2371 2399
  friend class internal::CustomArguments<FunctionCallbackInfo>;
2372
  static const int kReturnValueIndex = 0;
2373
  static const int kReturnValueDefaultValueIndex = -1;
2374
  static const int kIsolateIndex = -2;
2375
  static const int kDataIndex = -3;
2376
  static const int kCalleeIndex = -4;
2377
  static const int kHolderIndex = -5;
2400
  static const int kHolderIndex = 0;
2401
  static const int kIsolateIndex = 1;
2402
  static const int kReturnValueDefaultValueIndex = 2;
2403
  static const int kReturnValueIndex = 3;
2404
  static const int kDataIndex = 4;
2405
  static const int kCalleeIndex = 5;
2406
  static const int kContextSaveIndex = 6;
2378 2407

  
2379 2408
  V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
2380 2409
                   internal::Object** values,
......
2406 2435
  friend class MacroAssembler;
2407 2436
  friend class internal::PropertyCallbackArguments;
2408 2437
  friend class internal::CustomArguments<PropertyCallbackInfo>;
2409
  static const int kThisIndex = 0;
2410
  static const int kDataIndex = -1;
2411
  static const int kReturnValueIndex = -2;
2412
  static const int kReturnValueDefaultValueIndex = -3;
2413
  static const int kIsolateIndex = -4;
2414
  static const int kHolderIndex = -5;
2438
  static const int kHolderIndex = 0;
2439
  static const int kIsolateIndex = 1;
2440
  static const int kReturnValueDefaultValueIndex = 2;
2441
  static const int kReturnValueIndex = 3;
2442
  static const int kDataIndex = 4;
2443
  static const int kThisIndex = 5;
2415 2444

  
2416 2445
  V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
2417 2446
  internal::Object** args_;
......
2437 2466

  
2438 2467
  Local<Object> NewInstance() const;
2439 2468
  Local<Object> NewInstance(int argc, Handle<Value> argv[]) const;
2440
  Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]);
2469
  Local<Value> Call(Handle<Value> recv, int argc, Handle<Value> argv[]);
2441 2470
  void SetName(Handle<String> name);
2442 2471
  Handle<Value> GetName() const;
2443 2472

  
......
2450 2479
  Handle<Value> GetInferredName() const;
2451 2480

  
2452 2481
  /**
2482
   * User-defined name assigned to the "displayName" property of this function.
2483
   * Used to facilitate debugging and profiling of JavaScript code.
2484
   */
2485
  Handle<Value> GetDisplayName() const;
2486

  
2487
  /**
2453 2488
   * Returns zero based line number of function body and
2454 2489
   * kLineOffsetNotFound if no information available.
2455 2490
   */
......
2461 2496
  int GetScriptColumnNumber() const;
2462 2497

  
2463 2498
  /**
2499
   * Tells whether this function is builtin.
2500
   */
2501
  bool IsBuiltin() const;
2502

  
2503
  /**
2464 2504
   * Returns scriptId object.
2465
   * DEPRECATED: use ScriptId() instead.
2466 2505
   */
2467
  Handle<Value> GetScriptId() const;
2506
  V8_DEPRECATED("Use ScriptId instead", Handle<Value> GetScriptId()) const;
2468 2507

  
2469 2508
  /**
2470 2509
   * Returns scriptId.
......
2627 2666
   * Size of a view in bytes.
2628 2667
   */
2629 2668
  size_t ByteLength();
2630
  /**
2631
   * Base address of a view.
2632
   */
2633
  void* BaseAddress();
2634 2669

  
2635 2670
  V8_INLINE static ArrayBufferView* Cast(Value* obj);
2636 2671

  
......
2830 2865
 public:
2831 2866
  static Local<Value> New(double time);
2832 2867

  
2833
  // Deprecated, use Date::ValueOf() instead.
2834
  // TODO(svenpanne) Actually deprecate when Chrome is adapted.
2835
  double NumberValue() const { return ValueOf(); }
2868
  V8_DEPRECATED(
2869
      "Use ValueOf instead",
2870
      double NumberValue()) const { return ValueOf(); }
2836 2871

  
2837 2872
  /**
2838 2873
   * A specialization of Value::NumberValue that is more efficient
......
2868 2903
 public:
2869 2904
  static Local<Value> New(double value);
2870 2905

  
2871
  // Deprecated, use NumberObject::ValueOf() instead.
2872
  // TODO(svenpanne) Actually deprecate when Chrome is adapted.
2873
  double NumberValue() const { return ValueOf(); }
2906
  V8_DEPRECATED(
2907
      "Use ValueOf instead",
2908
      double NumberValue()) const { return ValueOf(); }
2874 2909

  
2875 2910
  /**
2876 2911
   * Returns the Number held by the object.
......
2891 2926
 public:
2892 2927
  static Local<Value> New(bool value);
2893 2928

  
2894
  // Deprecated, use BooleanObject::ValueOf() instead.
2895
  // TODO(svenpanne) Actually deprecate when Chrome is adapted.
2896
  bool BooleanValue() const { return ValueOf(); }
2929
  V8_DEPRECATED(
2930
      "Use ValueOf instead",
2931
      bool BooleanValue()) const { return ValueOf(); }
2897 2932

  
2898 2933
  /**
2899 2934
   * Returns the Boolean held by the object.
......
2914 2949
 public:
2915 2950
  static Local<Value> New(Handle<String> value);
2916 2951

  
2917
  // Deprecated, use StringObject::ValueOf() instead.
2918
  // TODO(svenpanne) Actually deprecate when Chrome is adapted.
2919
  Local<String> StringValue() const { return ValueOf(); }
2952
  V8_DEPRECATED(
2953
      "Use ValueOf instead",
2954
      Local<String> StringValue()) const { return ValueOf(); }
2920 2955

  
2921 2956
  /**
2922 2957
   * Returns the String held by the object.
......
2939 2974
 public:
2940 2975
  static Local<Value> New(Isolate* isolate, Handle<Symbol> value);
2941 2976

  
2942
  // Deprecated, use SymbolObject::ValueOf() instead.
2943
  // TODO(svenpanne) Actually deprecate when Chrome is adapted.
2944
  Local<Symbol> SymbolValue() const { return ValueOf(); }
2977
  V8_DEPRECATED(
2978
      "Use ValueOf instead",
2979
      Local<Symbol> SymbolValue()) const { return ValueOf(); }
2945 2980

  
2946 2981
  /**
2947 2982
   * Returns the Symbol held by the object.
......
3744 3779
  uint32_t* stack_limit() const { return stack_limit_; }
3745 3780
  // Sets an address beyond which the VM's stack may not grow.
3746 3781
  void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
3747
  Maybe<bool> is_memory_constrained() const { return is_memory_constrained_; }
3748
  // If set to true, V8 will limit it's memory usage, at the potential cost of
3749
  // lower performance.  Note, this option is a tentative addition to the API
3750
  // and may be removed or modified without warning.
3751
  void set_memory_constrained(bool value) {
3752
    is_memory_constrained_ = Maybe<bool>(value);
3753
  }
3754 3782

  
3755 3783
 private:
3756 3784
  int max_young_space_size_;
3757 3785
  int max_old_space_size_;
3758 3786
  int max_executable_size_;
3759 3787
  uint32_t* stack_limit_;
3760
  Maybe<bool> is_memory_constrained_;
3761 3788
};
3762 3789

  
3763 3790

  
3791
/**
3792
 * Sets the given ResourceConstraints on the current isolate.
3793
 */
3764 3794
bool V8_EXPORT SetResourceConstraints(ResourceConstraints* constraints);
3765 3795

  
3766 3796

  
......
3773 3803
typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error);
3774 3804

  
3775 3805

  
3776
/**
3777
 * Schedules an exception to be thrown when returning to JavaScript.  When an
3778
 * exception has been scheduled it is illegal to invoke any JavaScript
3779
 * operation; the caller must return immediately and only after the exception
3780
 * has been handled does it become legal to invoke JavaScript operations.
3781
 */
3782
Handle<Value> V8_EXPORT ThrowException(Handle<Value> exception);
3806
V8_DEPRECATED(
3807
    "Use Isolate::ThrowException instead",
3808
    Handle<Value> V8_EXPORT ThrowException(Handle<Value> exception));
3783 3809

  
3784 3810
/**
3785 3811
 * Create new error objects by calling the corresponding error object
......
3870 3896
typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags);
3871 3897
typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags);
3872 3898

  
3873
typedef void (*GCCallback)();
3874

  
3875 3899

  
3876 3900
/**
3877 3901
 * Collection of V8 heap information.
......
4019 4043
   */
4020 4044
  CpuProfiler* GetCpuProfiler();
4021 4045

  
4046
  /** Returns true if this isolate has a current context. */
4047
  bool InContext();
4048

  
4022 4049
  /** Returns the context that is on the top of the stack. */
4023 4050
  Local<Context> GetCurrentContext();
4024 4051

  
4025 4052
  /**
4053
   * Returns the context of the calling JavaScript code.  That is the
4054
   * context of the top-most JavaScript frame.  If there are no
4055
   * JavaScript frames an empty handle is returned.
4056
   */
4057
  Local<Context> GetCallingContext();
4058

  
4059
  /** Returns the last entered context. */
4060
  Local<Context> GetEnteredContext();
4061

  
4062
  /**
4063
   * Schedules an exception to be thrown when returning to JavaScript.  When an
4064
   * exception has been scheduled it is illegal to invoke any JavaScript
4065
   * operation; the caller must return immediately and only after the exception
4066
   * has been handled does it become legal to invoke JavaScript operations.
4067
   */
4068
  Local<Value> ThrowException(Local<Value> exception);
4069

  
4070
  /**
4026 4071
   * Allows the host application to group objects together. If one
4027 4072
   * object in the group is alive, all objects in the group are alive.
4028 4073
   * After each garbage collection, object groups are removed. It is
......
4033 4078
   * garbage collection types it is sufficient to provide object groups
4034 4079
   * for partially dependent handles only.
4035 4080
   */
4036
  void SetObjectGroupId(const Persistent<Value>& object,
4037
                        UniqueId id);
4081
  template<typename T> void SetObjectGroupId(const Persistent<T>& object,
4082
                                             UniqueId id);
4038 4083

  
4039 4084
  /**
4040 4085
   * Allows the host application to declare implicit references from an object
......
4043 4088
   * are removed. It is intended to be used in the before-garbage-collection
4044 4089
   * callback function.
4045 4090
   */
4046
  void SetReferenceFromGroup(UniqueId id,
4047
                             const Persistent<Value>& child);
4091
  template<typename T> void SetReferenceFromGroup(UniqueId id,
4092
                                                  const Persistent<T>& child);
4048 4093

  
4049 4094
  /**
4050 4095
   * Allows the host application to declare implicit references from an object
......
4052 4097
   * too. After each garbage collection, all implicit references are removed. It
4053 4098
   * is intended to be used in the before-garbage-collection callback function.
4054 4099
   */
4055
  void SetReference(const Persistent<Object>& parent,
4056
                    const Persistent<Value>& child);
4100
  template<typename T, typename S>
4101
  void SetReference(const Persistent<T>& parent, const Persistent<S>& child);
4102

  
4103
  typedef void (*GCPrologueCallback)(Isolate* isolate,
4104
                                     GCType type,
4105
                                     GCCallbackFlags flags);
4106
  typedef void (*GCEpilogueCallback)(Isolate* isolate,
4107
                                     GCType type,
4108
                                     GCCallbackFlags flags);
4109

  
4110
  /**
4111
   * Enables the host application to receive a notification before a
4112
   * garbage collection.  Allocations are not allowed in the
4113
   * callback function, you therefore cannot manipulate objects (set
4114
   * or delete properties for example) since it is possible such
4115
   * operations will result in the allocation of objects. It is possible
4116
   * to specify the GCType filter for your callback. But it is not possible to
4117
   * register the same callback function two times with different
4118
   * GCType filters.
4119
   */
4120
  void AddGCPrologueCallback(
4121
      GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll);
4122

  
4123
  /**
4124
   * This function removes callback which was installed by
4125
   * AddGCPrologueCallback function.
4126
   */
4127
  void RemoveGCPrologueCallback(GCPrologueCallback callback);
4128

  
4129
  /**
4130
   * Enables the host application to receive a notification after a
4131
   * garbage collection.  Allocations are not allowed in the
4132
   * callback function, you therefore cannot manipulate objects (set
4133
   * or delete properties for example) since it is possible such
4134
   * operations will result in the allocation of objects. It is possible
4135
   * to specify the GCType filter for your callback. But it is not possible to
4136
   * register the same callback function two times with different
4137
   * GCType filters.
4138
   */
4139
  void AddGCEpilogueCallback(
4140
      GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll);
4141

  
4142
  /**
4143
   * This function removes callback which was installed by
4144
   * AddGCEpilogueCallback function.
4145
   */
4146
  void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
4057 4147

  
4058 4148
 private:
4059 4149
  Isolate();
......
4062 4152
  Isolate& operator=(const Isolate&);
4063 4153
  void* operator new(size_t size);
4064 4154
  void operator delete(void*, size_t);
4065
};
4066 4155

  
4156
  void SetObjectGroupId(internal::Object** object, UniqueId id);
4157
  void SetReferenceFromGroup(UniqueId id, internal::Object** object);
4158
  void SetReference(internal::Object** parent, internal::Object** child);
4159
};
4067 4160

  
4068 4161
class V8_EXPORT StartupData {
4069 4162
 public:
......
4412 4505
  static void RemoveGCPrologueCallback(GCPrologueCallback callback);
4413 4506

  
4414 4507
  /**
4415
   * The function is deprecated. Please use AddGCPrologueCallback instead.
4416
   * Enables the host application to receive a notification before a
4417
   * garbage collection.  Allocations are not allowed in the
4418
   * callback function, you therefore cannot manipulate objects (set
4419
   * or delete properties for example) since it is possible such
4420
   * operations will result in the allocation of objects.
4421
   */
4422
  V8_DEPRECATED(static void SetGlobalGCPrologueCallback(GCCallback));
4423

  
4424
  /**
4425 4508
   * Enables the host application to receive a notification after a
4426 4509
   * garbage collection.  Allocations are not allowed in the
4427 4510
   * callback function, you therefore cannot manipulate objects (set
......
4441 4524
  static void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
4442 4525

  
4443 4526
  /**
4444
   * The function is deprecated. Please use AddGCEpilogueCallback instead.
4445
   * Enables the host application to receive a notification after a
4446
   * major garbage collection.  Allocations are not allowed in the
4447
   * callback function, you therefore cannot manipulate objects (set
4448
   * or delete properties for example) since it is possible such
4449
   * operations will result in the allocation of objects.
4450
   */
4451
  V8_DEPRECATED(static void SetGlobalGCEpilogueCallback(GCCallback));
4452

  
4453
  /**
4454 4527
   * Enables the host application to provide a mechanism to be notified
4455 4528
   * and perform custom logging when V8 Allocates Executable Memory.
4456 4529
   */
......
4498 4571
      ReturnAddressLocationResolver return_address_resolver);
4499 4572

  
4500 4573
  /**
4501
   * Deprecated, use the variant with the Isolate parameter below instead.
4502
   */
4503
  V8_DEPRECATED(static bool SetFunctionEntryHook(FunctionEntryHook entry_hook));
4504

  
4505
  /**
4506 4574
   * Allows the host application to provide the address of a function that's
4507 4575
   * invoked on entry to every V8-generated function.
4508 4576
   * Note that \p entry_hook is invoked at the very start of each
......
4541 4609
  static void SetJitCodeEventHandler(JitCodeEventOptions options,
4542 4610
                                     JitCodeEventHandler event_handler);
4543 4611

  
4544
  // TODO(svenpanne) Really deprecate me when Chrome is fixed.
4545
  /** Deprecated. Use Isolate::AdjustAmountOfExternalAllocatedMemory instead. */
4546
  static intptr_t AdjustAmountOfExternalAllocatedMemory(
4547
      intptr_t change_in_bytes);
4612
  V8_DEPRECATED(
4613
      "Use Isolate::AdjustAmountOfExternalAllocatedMemory instead",
4614
      static intptr_t AdjustAmountOfExternalAllocatedMemory(
4615
          intptr_t change_in_bytes));
4548 4616

  
4549 4617
  /**
4550 4618
   * Forcefully terminate the current thread of JavaScript execution
......
4599 4667
   */
4600 4668
  static bool Dispose();
4601 4669

  
4602
  /** Deprecated. Use Isolate::GetHeapStatistics instead. */
4603
  V8_DEPRECATED(static void GetHeapStatistics(HeapStatistics* heap_statistics));
4604

  
4605 4670
  /**
4606 4671
   * Iterates through all external resources referenced from current isolate
4607 4672
   * heap.  GC is not invoked prior to iterating, therefore there is no
......
4899 4964
      Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
4900 4965
      Handle<Value> global_object = Handle<Value>());
4901 4966

  
4902
  /** Deprecated. Use Isolate version instead. */
4903
  V8_DEPRECATED(static Persistent<Context> New(
4904
      ExtensionConfiguration* extensions = NULL,
4905
      Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
4906
      Handle<Value> global_object = Handle<Value>()));
4967
  V8_DEPRECATED("Use Isolate::GetEnteredContext instead",
4968
                static Local<Context> GetEntered());
4907 4969

  
4908
  /** Returns the last entered context. */
4909
  static Local<Context> GetEntered();
4970
  V8_DEPRECATED("Use Isolate::GetCurrentContext instead",
4971
                static Local<Context> GetCurrent());
4910 4972

  
4911
  // TODO(svenpanne) Actually deprecate this.
4912
  /** Deprecated. Use Isolate::GetCurrentContext instead. */
4913
  static Local<Context> GetCurrent();
4914

  
4915
  /**
4916
   * Returns the context of the calling JavaScript code.  That is the
4917
   * context of the top-most JavaScript frame.  If there are no
4918
   * JavaScript frames an empty handle is returned.
4919
   */
4920
  static Local<Context> GetCalling();
4973
  V8_DEPRECATED("Use Isolate::GetCallingContext instead",
4974
                static Local<Context> GetCalling());
4921 4975

  
4922 4976
  /**
4923 4977
   * Sets the security token for the context.  To access an object in
......
4948 5002
  /** Returns true if the context has experienced an out of memory situation. */
4949 5003
  bool HasOutOfMemoryException();
4950 5004

  
4951
  /** Returns true if V8 has a current context. */
4952
  static bool InContext();
5005
  V8_DEPRECATED("Use Isolate::InContext instead",
5006
                static bool InContext());
4953 5007

  
4954 5008
  /** Returns an isolate associated with a current context. */
4955 5009
  v8::Isolate* GetIsolate();
......
5020 5074
    explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
5021 5075
      context_->Enter();
5022 5076
    }
5023
    // TODO(dcarney): deprecate
5024
    V8_INLINE Scope(Isolate* isolate, Persistent<Context>& context) // NOLINT
5077
    V8_DEPRECATED(
5078
        "Use Handle version instead",
5079
        V8_INLINE Scope(Isolate* isolate, Persistent<Context>& context)) // NOLINT
5025 5080
    : context_(Handle<Context>::New(isolate, context)) {
5026 5081
      context_->Enter();
5027 5082
    }
......
5125 5180
   */
5126 5181
  V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
5127 5182

  
5128
  /** Deprecated. Use Isolate version instead. */
5129
  V8_DEPRECATED(Unlocker());
5130

  
5131 5183
  ~Unlocker();
5132 5184
 private:
5133 5185
  void Initialize(Isolate* isolate);
......
5143 5195
   */
5144 5196
  V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
5145 5197

  
5146
  /** Deprecated. Use Isolate version instead. */
5147
  V8_DEPRECATED(Locker());
5148

  
5149 5198
  ~Locker();
5150 5199

  
5151 5200
  /**
......
5155 5204
   * that will switch between multiple threads that are in contention
5156 5205
   * for the V8 lock.
5157 5206
   */
5158
  static void StartPreemption(int every_n_ms);
5207
  static void StartPreemption(Isolate* isolate, int every_n_ms);
5159 5208

  
5160 5209
  /**
5161 5210
   * Stop preemption.
5162 5211
   */
5163
  static void StopPreemption();
5212
  static void StopPreemption(Isolate* isolate);
5164 5213

  
5165 5214
  /**
5166 5215
   * Returns whether or not the locker for a given isolate, is locked by the
......
5359 5408
  static const int kNullValueRootIndex = 7;
5360 5409
  static const int kTrueValueRootIndex = 8;
5361 5410
  static const int kFalseValueRootIndex = 9;
5362
  static const int kEmptyStringRootIndex = 131;
5411
  static const int kEmptyStringRootIndex = 132;
5363 5412

  
5364 5413
  static const int kNodeClassIdOffset = 1 * kApiPointerSize;
5365 5414
  static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
......
5370 5419
  static const int kNodeIsIndependentShift = 4;
5371 5420
  static const int kNodeIsPartiallyDependentShift = 5;
5372 5421

  
5373
  static const int kJSObjectType = 0xb1;
5422
  static const int kJSObjectType = 0xb2;
5374 5423
  static const int kFirstNonstringType = 0x80;
5375 5424
  static const int kOddballType = 0x83;
5376 5425
  static const int kForeignType = 0x87;
......
5378 5427
  static const int kUndefinedOddballKind = 5;
5379 5428
  static const int kNullOddballKind = 3;
5380 5429

  
5381
  static void CheckInitializedImpl(v8::Isolate* isolate);
5430
  V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
5382 5431
  V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
5383 5432
#ifdef V8_ENABLE_CHECKS
5384 5433
    CheckInitializedImpl(isolate);
......
5494 5543

  
5495 5544

  
5496 5545
template <class T>
5497
Local<T> Local<T>::New(Handle<T> that) {
5498
  if (that.IsEmpty()) return Local<T>();
5499
  T* that_ptr = *that;
5500
  internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
5501
  if (internal::Internals::CanCastToHeapObject(that_ptr)) {
5502
    return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
5503
        reinterpret_cast<internal::HeapObject*>(*p))));
5504
  }
5505
  return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p)));
5506
}
5507

  
5508

  
5509
template <class T>
5510 5546
Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) {
5511 5547
  return New(isolate, that.val_);
5512 5548
}
......
5847 5883

  
5848 5884
template<typename T>
5849 5885
Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
5850
  if (i < 0 || length_ <= i) return Local<Value>(*Undefined());
5886
  if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate()));
5851 5887
  return Local<Value>(reinterpret_cast<Value*>(values_ - i));
5852 5888
}
5853 5889

  
......
5929 5965

  
5930 5966

  
5931 5967
Handle<Boolean> Boolean::New(bool value) {
5932
  return value ? True() : False();
5968
  Isolate* isolate = Isolate::GetCurrent();
5969
  return value ? True(isolate) : False(isolate);
5933 5970
}
5934 5971

  
5935 5972

  
......
5941 5978
Local<Value> Object::GetInternalField(int index) {
5942 5979
#ifndef V8_ENABLE_CHECKS
5943 5980
  typedef internal::Object O;
5981
  typedef internal::HeapObject HO;
5944 5982
  typedef internal::Internals I;
5945 5983
  O* obj = *reinterpret_cast<O**>(this);
5946 5984
  // Fast path: If the object is a plain JSObject, which is the common case, we
......
5948 5986
  if (I::GetInstanceType(obj) == I::kJSObjectType) {
5949 5987
    int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
5950 5988
    O* value = I::ReadField<O*>(obj, offset);
5951
    O** result = HandleScope::CreateHandle(value);
5989
    O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value);
5952 5990
    return Local<Value>(reinterpret_cast<Value*>(result));
5953 5991
  }
5954 5992
#endif
......
6397 6435
}
6398 6436

  
6399 6437

  
6438
template<typename T>
6439
void Isolate::SetObjectGroupId(const Persistent<T>& object,
6440
                               UniqueId id) {
6441
  TYPE_CHECK(Value, T);
6442
  SetObjectGroupId(reinterpret_cast<v8::internal::Object**>(object.val_), id);
6443
}
6444

  
6445

  
6446
template<typename T>
6447
void Isolate::SetReferenceFromGroup(UniqueId id,
6448
                                    const Persistent<T>& object) {
6449
  TYPE_CHECK(Value, T);
6450
  SetReferenceFromGroup(id,
6451
                        reinterpret_cast<v8::internal::Object**>(object.val_));
6452
}
6453

  
6454

  
6455
template<typename T, typename S>
6456
void Isolate::SetReference(const Persistent<T>& parent,
6457
                           const Persistent<S>& child) {
6458
  TYPE_CHECK(Object, T);
6459
  TYPE_CHECK(Value, S);
6460
  SetReference(reinterpret_cast<v8::internal::Object**>(parent.val_),
6461
               reinterpret_cast<v8::internal::Object**>(child.val_));
6462
}
6463

  
6464

  
6400 6465
Local<Value> Context::GetEmbedderData(int index) {
6401 6466
#ifndef V8_ENABLE_CHECKS
6402 6467
  typedef internal::Object O;
6468
  typedef internal::HeapObject HO;
6403 6469
  typedef internal::Internals I;
6404
  O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this, index));
6470
  HO* context = *reinterpret_cast<HO**>(this);
6471
  O** result =
6472
      HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this, index));
6405 6473
  return Local<Value>(reinterpret_cast<Value*>(result));
6406 6474
#else
6407 6475
  return SlowGetEmbedderData(index);

Also available in: Unified diff