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

Side by Side Diff: include/v8.h

Issue 151603004: A64: Synchronize with r16587. (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 | « ChangeLog ('k') | include/v8-profiler.h » ('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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 template <class T> class Eternal { 451 template <class T> class Eternal {
452 public: 452 public:
453 V8_INLINE(Eternal()) : index_(kInitialValue) { } 453 V8_INLINE(Eternal()) : index_(kInitialValue) { }
454 template<class S> 454 template<class S>
455 V8_INLINE(Eternal(Isolate* isolate, Local<S> handle)) 455 V8_INLINE(Eternal(Isolate* isolate, Local<S> handle))
456 : index_(kInitialValue) { 456 : index_(kInitialValue) {
457 Set(isolate, handle); 457 Set(isolate, handle);
458 } 458 }
459 // Can only be safely called if already set. 459 // Can only be safely called if already set.
460 V8_INLINE(Local<T> Get(Isolate* isolate)); 460 V8_INLINE(Local<T> Get(Isolate* isolate));
461 V8_INLINE(bool IsEmpty()) { return index_ != kInitialValue; } 461 V8_INLINE(bool IsEmpty()) { return index_ == kInitialValue; }
462 template<class S> 462 template<class S>
463 V8_INLINE(void Set(Isolate* isolate, Local<S> handle)); 463 V8_INLINE(void Set(Isolate* isolate, Local<S> handle));
464 464
465 private: 465 private:
466 static const int kInitialValue = -1; 466 static const int kInitialValue = -1;
467 int index_; 467 int index_;
468 }; 468 };
469 469
470 470
471 /** 471 /**
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 #endif 627 #endif
628 628
629 V8_INLINE(void Dispose()); 629 V8_INLINE(void Dispose());
630 630
631 /** 631 /**
632 * Releases the storage cell referenced by this persistent handle. 632 * Releases the storage cell referenced by this persistent handle.
633 * Does not remove the reference to the cell from any handles. 633 * Does not remove the reference to the cell from any handles.
634 * This handle's reference, and any other references to the storage 634 * This handle's reference, and any other references to the storage
635 * cell remain and IsEmpty will still return false. 635 * cell remain and IsEmpty will still return false.
636 */ 636 */
637 // TODO(dcarney): deprecate 637 V8_DEPRECATED(V8_INLINE(void Dispose(Isolate* isolate))) { Dispose(); }
638 V8_INLINE(void Dispose(Isolate* isolate)) { Dispose(); }
639 638
640 /** 639 /**
641 * Make the reference to this object weak. When only weak handles 640 * Make the reference to this object weak. When only weak handles
642 * refer to the object, the garbage collector will perform a 641 * refer to the object, the garbage collector will perform a
643 * callback to the given V8::NearDeathCallback function, passing 642 * callback to the given V8::NearDeathCallback function, passing
644 * it the object reference and the given parameters. 643 * it the object reference and the given parameters.
645 */ 644 */
646 template<typename S, typename P> 645 template<typename S, typename P>
647 V8_INLINE(void MakeWeak( 646 V8_INLINE(void MakeWeak(
648 P* parameters, 647 P* parameters,
(...skipping 11 matching lines...) Expand all
660 typename WeakReferenceCallbacks<S, P>::Revivable callback)); 659 typename WeakReferenceCallbacks<S, P>::Revivable callback));
661 660
662 template<typename P> 661 template<typename P>
663 V8_DEPRECATED(void MakeWeak( 662 V8_DEPRECATED(void MakeWeak(
664 Isolate* isolate, 663 Isolate* isolate,
665 P* parameters, 664 P* parameters,
666 typename WeakReferenceCallbacks<T, P>::Revivable callback)); 665 typename WeakReferenceCallbacks<T, P>::Revivable callback));
667 666
668 V8_INLINE(void ClearWeak()); 667 V8_INLINE(void ClearWeak());
669 668
670 // TODO(dcarney): deprecate 669 V8_DEPRECATED(V8_INLINE(void ClearWeak(Isolate* isolate))) { ClearWeak(); }
671 V8_INLINE(void ClearWeak(Isolate* isolate)) { ClearWeak(); }
672 670
673 /** 671 /**
674 * Marks the reference to this object independent. Garbage collector is free 672 * Marks the reference to this object independent. Garbage collector is free
675 * to ignore any object groups containing this object. Weak callback for an 673 * to ignore any object groups containing this object. Weak callback for an
676 * independent handle should not assume that it will be preceded by a global 674 * independent handle should not assume that it will be preceded by a global
677 * GC prologue callback or followed by a global GC epilogue callback. 675 * GC prologue callback or followed by a global GC epilogue callback.
678 */ 676 */
679 V8_INLINE(void MarkIndependent()); 677 V8_INLINE(void MarkIndependent());
680 678
681 // TODO(dcarney): deprecate 679 V8_DEPRECATED(V8_INLINE(void MarkIndependent(Isolate* isolate))) {
682 V8_INLINE(void MarkIndependent(Isolate* isolate)) { MarkIndependent(); } 680 MarkIndependent();
681 }
683 682
684 /** 683 /**
685 * Marks the reference to this object partially dependent. Partially dependent 684 * Marks the reference to this object partially dependent. Partially dependent
686 * handles only depend on other partially dependent handles and these 685 * handles only depend on other partially dependent handles and these
687 * dependencies are provided through object groups. It provides a way to build 686 * dependencies are provided through object groups. It provides a way to build
688 * smaller object groups for young objects that represent only a subset of all 687 * smaller object groups for young objects that represent only a subset of all
689 * external dependencies. This mark is automatically cleared after each 688 * external dependencies. This mark is automatically cleared after each
690 * garbage collection. 689 * garbage collection.
691 */ 690 */
692 V8_INLINE(void MarkPartiallyDependent()); 691 V8_INLINE(void MarkPartiallyDependent());
693 692
694 // TODO(dcarney): deprecate 693 V8_DEPRECATED(V8_INLINE(void MarkPartiallyDependent(Isolate* isolate))) {
695 V8_INLINE(void MarkPartiallyDependent(Isolate* isolate)) {
696 MarkPartiallyDependent(); 694 MarkPartiallyDependent();
697 } 695 }
698 696
699 V8_INLINE(bool IsIndependent() const); 697 V8_INLINE(bool IsIndependent() const);
700 698
701 // TODO(dcarney): deprecate 699 V8_DEPRECATED(V8_INLINE(bool IsIndependent(Isolate* isolate)) const) {
702 V8_INLINE(bool IsIndependent(Isolate* isolate) const) {
703 return IsIndependent(); 700 return IsIndependent();
704 } 701 }
705 702
706 /** Checks if the handle holds the only reference to an object. */ 703 /** Checks if the handle holds the only reference to an object. */
707 V8_INLINE(bool IsNearDeath() const); 704 V8_INLINE(bool IsNearDeath() const);
708 705
709 // TODO(dcarney): deprecate 706 V8_DEPRECATED(V8_INLINE(bool IsNearDeath(Isolate* isolate)) const) {
710 V8_INLINE(bool IsNearDeath(Isolate* isolate) const) { return IsNearDeath(); } 707 return IsNearDeath();
708 }
711 709
712 /** Returns true if the handle's reference is weak. */ 710 /** Returns true if the handle's reference is weak. */
713 V8_INLINE(bool IsWeak() const); 711 V8_INLINE(bool IsWeak() const);
714 712
715 // TODO(dcarney): deprecate 713 V8_DEPRECATED(V8_INLINE(bool IsWeak(Isolate* isolate)) const) {
716 V8_INLINE(bool IsWeak(Isolate* isolate) const) { return IsWeak(); } 714 return IsWeak();
715 }
717 716
718 /** 717 /**
719 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface 718 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface
720 * description in v8-profiler.h for details. 719 * description in v8-profiler.h for details.
721 */ 720 */
722 V8_INLINE(void SetWrapperClassId(uint16_t class_id)); 721 V8_INLINE(void SetWrapperClassId(uint16_t class_id));
723 722
724 // TODO(dcarney): deprecate 723 V8_DEPRECATED(
725 V8_INLINE(void SetWrapperClassId(Isolate* isolate, uint16_t class_id)) { 724 V8_INLINE(void SetWrapperClassId(Isolate * isolate, uint16_t class_id))) {
726 SetWrapperClassId(class_id); 725 SetWrapperClassId(class_id);
727 } 726 }
728 727
729 /** 728 /**
730 * Returns the class ID previously assigned to this handle or 0 if no class ID 729 * Returns the class ID previously assigned to this handle or 0 if no class ID
731 * was previously assigned. 730 * was previously assigned.
732 */ 731 */
733 V8_INLINE(uint16_t WrapperClassId() const); 732 V8_INLINE(uint16_t WrapperClassId() const);
734 733
735 // TODO(dcarney): deprecate 734 V8_DEPRECATED(V8_INLINE(uint16_t WrapperClassId(Isolate* isolate)) const) {
736 V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const) {
737 return WrapperClassId(); 735 return WrapperClassId();
738 } 736 }
739 737
740 /** 738 /**
741 * Disposes the current contents of the handle and replaces it. 739 * Disposes the current contents of the handle and replaces it.
742 */ 740 */
743 V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other)); 741 V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other));
744 742
745 #ifndef V8_USE_UNSAFE_HANDLES 743 #ifndef V8_USE_UNSAFE_HANDLES
746 V8_INLINE(void Reset(Isolate* isolate, const Persistent<T>& other)); 744 V8_INLINE(void Reset(Isolate* isolate, const Persistent<T>& other));
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 bool Delete(uint32_t index); 2116 bool Delete(uint32_t index);
2119 2117
2120 bool SetAccessor(Handle<String> name, 2118 bool SetAccessor(Handle<String> name,
2121 AccessorGetterCallback getter, 2119 AccessorGetterCallback getter,
2122 AccessorSetterCallback setter = 0, 2120 AccessorSetterCallback setter = 0,
2123 Handle<Value> data = Handle<Value>(), 2121 Handle<Value> data = Handle<Value>(),
2124 AccessControl settings = DEFAULT, 2122 AccessControl settings = DEFAULT,
2125 PropertyAttribute attribute = None); 2123 PropertyAttribute attribute = None);
2126 2124
2127 // This function is not yet stable and should not be used at this time. 2125 // This function is not yet stable and should not be used at this time.
2128 bool SetAccessor(Handle<String> name, 2126 bool SetDeclaredAccessor(Local<String> name,
2129 Handle<DeclaredAccessorDescriptor> descriptor, 2127 Local<DeclaredAccessorDescriptor> descriptor,
2130 AccessControl settings = DEFAULT, 2128 PropertyAttribute attribute = None,
2131 PropertyAttribute attribute = None); 2129 AccessControl settings = DEFAULT);
2132 2130
2133 /** 2131 /**
2134 * Returns an array containing the names of the enumerable properties 2132 * Returns an array containing the names of the enumerable properties
2135 * of this object, including properties from prototype objects. The 2133 * of this object, including properties from prototype objects. The
2136 * array returned by this method contains the same values as would 2134 * array returned by this method contains the same values as would
2137 * be enumerated by a for-in statement over this object. 2135 * be enumerated by a for-in statement over this object.
2138 */ 2136 */
2139 Local<Array> GetPropertyNames(); 2137 Local<Array> GetPropertyNames();
2140 2138
2141 /** 2139 /**
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 */ 2354 */
2357 static Local<Array> New(int length = 0); 2355 static Local<Array> New(int length = 0);
2358 2356
2359 V8_INLINE(static Array* Cast(Value* obj)); 2357 V8_INLINE(static Array* Cast(Value* obj));
2360 private: 2358 private:
2361 Array(); 2359 Array();
2362 static void CheckCast(Value* obj); 2360 static void CheckCast(Value* obj);
2363 }; 2361 };
2364 2362
2365 2363
2364 template<typename T>
2365 class ReturnValue {
2366 public:
2367 template <class S> V8_INLINE(ReturnValue(const ReturnValue<S>& that))
2368 : value_(that.value_) {
2369 TYPE_CHECK(T, S);
2370 }
2371 // Handle setters
2372 template <typename S> V8_INLINE(void Set(const Persistent<S>& handle));
2373 template <typename S> V8_INLINE(void Set(const Handle<S> handle));
2374 // Fast primitive setters
2375 V8_INLINE(void Set(bool value));
2376 V8_INLINE(void Set(double i));
2377 V8_INLINE(void Set(int32_t i));
2378 V8_INLINE(void Set(uint32_t i));
2379 // Fast JS primitive setters
2380 V8_INLINE(void SetNull());
2381 V8_INLINE(void SetUndefined());
2382 V8_INLINE(void SetEmptyString());
2383 // Convenience getter for Isolate
2384 V8_INLINE(Isolate* GetIsolate());
2385
2386 private:
2387 template<class F> friend class ReturnValue;
2388 template<class F> friend class FunctionCallbackInfo;
2389 template<class F> friend class PropertyCallbackInfo;
2390 V8_INLINE(internal::Object* GetDefaultValue());
2391 V8_INLINE(explicit ReturnValue(internal::Object** slot));
2392 internal::Object** value_;
2393 };
2394
2395
2396 /**
2397 * The argument information given to function call callbacks. This
2398 * class provides access to information about the context of the call,
2399 * including the receiver, the number and values of arguments, and
2400 * the holder of the function.
2401 */
2402 template<typename T>
2403 class FunctionCallbackInfo {
2404 public:
2405 V8_INLINE(int Length() const);
2406 V8_INLINE(Local<Value> operator[](int i) const);
2407 V8_INLINE(Local<Function> Callee() const);
2408 V8_INLINE(Local<Object> This() const);
2409 V8_INLINE(Local<Object> Holder() const);
2410 V8_INLINE(bool IsConstructCall() const);
2411 V8_INLINE(Local<Value> Data() const);
2412 V8_INLINE(Isolate* GetIsolate() const);
2413 V8_INLINE(ReturnValue<T> GetReturnValue() const);
2414 // This shouldn't be public, but the arm compiler needs it.
2415 static const int kArgsLength = 6;
2416
2417 protected:
2418 friend class internal::FunctionCallbackArguments;
2419 friend class internal::CustomArguments<FunctionCallbackInfo>;
2420 static const int kReturnValueIndex = 0;
2421 static const int kReturnValueDefaultValueIndex = -1;
2422 static const int kIsolateIndex = -2;
2423 static const int kDataIndex = -3;
2424 static const int kCalleeIndex = -4;
2425 static const int kHolderIndex = -5;
2426
2427 V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args,
2428 internal::Object** values,
2429 int length,
2430 bool is_construct_call));
2431 internal::Object** implicit_args_;
2432 internal::Object** values_;
2433 int length_;
2434 bool is_construct_call_;
2435 };
2436
2437
2438 /**
2439 * The information passed to a property callback about the context
2440 * of the property access.
2441 */
2442 template<typename T>
2443 class PropertyCallbackInfo {
2444 public:
2445 V8_INLINE(Isolate* GetIsolate() const);
2446 V8_INLINE(Local<Value> Data() const);
2447 V8_INLINE(Local<Object> This() const);
2448 V8_INLINE(Local<Object> Holder() const);
2449 V8_INLINE(ReturnValue<T> GetReturnValue() const);
2450 // This shouldn't be public, but the arm compiler needs it.
2451 static const int kArgsLength = 6;
2452
2453 protected:
2454 friend class MacroAssembler;
2455 friend class internal::PropertyCallbackArguments;
2456 friend class internal::CustomArguments<PropertyCallbackInfo>;
2457 static const int kThisIndex = 0;
2458 static const int kHolderIndex = -1;
2459 static const int kDataIndex = -2;
2460 static const int kReturnValueIndex = -3;
2461 static const int kReturnValueDefaultValueIndex = -4;
2462 static const int kIsolateIndex = -5;
2463
2464 V8_INLINE(PropertyCallbackInfo(internal::Object** args))
2465 : args_(args) { }
2466 internal::Object** args_;
2467 };
2468
2469
2470 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
2471
2472
2366 /** 2473 /**
2367 * A JavaScript function object (ECMA-262, 15.3). 2474 * A JavaScript function object (ECMA-262, 15.3).
2368 */ 2475 */
2369 class V8_EXPORT Function : public Object { 2476 class V8_EXPORT Function : public Object {
2370 public: 2477 public:
2478 /**
2479 * Create a function in the current execution context
2480 * for a given FunctionCallback.
2481 */
2482 static Local<Function> New(Isolate* isolate,
2483 FunctionCallback callback,
2484 Local<Value> data = Local<Value>(),
2485 int length = 0);
2486
2371 Local<Object> NewInstance() const; 2487 Local<Object> NewInstance() const;
2372 Local<Object> NewInstance(int argc, Handle<Value> argv[]) const; 2488 Local<Object> NewInstance(int argc, Handle<Value> argv[]) const;
2373 Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]); 2489 Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]);
2374 void SetName(Handle<String> name); 2490 void SetName(Handle<String> name);
2375 Handle<Value> GetName() const; 2491 Handle<Value> GetName() const;
2376 2492
2377 /** 2493 /**
2378 * Name inferred from variable or property assignment of this function. 2494 * Name inferred from variable or property assignment of this function.
2379 * Used to facilitate debugging and profiling of JavaScript code written 2495 * Used to facilitate debugging and profiling of JavaScript code written
2380 * in an OO style, where many functions are anonymous but are assigned 2496 * in an OO style, where many functions are anonymous but are assigned
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
2976 PropertyAttribute attributes = None); 3092 PropertyAttribute attributes = None);
2977 V8_INLINE(void Set(const char* name, Handle<Data> value)); 3093 V8_INLINE(void Set(const char* name, Handle<Data> value));
2978 3094
2979 void SetAccessorProperty( 3095 void SetAccessorProperty(
2980 Local<String> name, 3096 Local<String> name,
2981 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), 3097 Local<FunctionTemplate> getter = Local<FunctionTemplate>(),
2982 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), 3098 Local<FunctionTemplate> setter = Local<FunctionTemplate>(),
2983 PropertyAttribute attribute = None, 3099 PropertyAttribute attribute = None,
2984 AccessControl settings = DEFAULT); 3100 AccessControl settings = DEFAULT);
2985 3101
3102 /**
3103 * Whenever the property with the given name is accessed on objects
3104 * created from this Template the getter and setter callbacks
3105 * are called instead of getting and setting the property directly
3106 * on the JavaScript object.
3107 *
3108 * \param name The name of the property for which an accessor is added.
3109 * \param getter The callback to invoke when getting the property.
3110 * \param setter The callback to invoke when setting the property.
3111 * \param data A piece of data that will be passed to the getter and setter
3112 * callbacks whenever they are invoked.
3113 * \param settings Access control settings for the accessor. This is a bit
3114 * field consisting of one of more of
3115 * DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2.
3116 * The default is to not allow cross-context access.
3117 * ALL_CAN_READ means that all cross-context reads are allowed.
3118 * ALL_CAN_WRITE means that all cross-context writes are allowed.
3119 * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all
3120 * cross-context access.
3121 * \param attribute The attributes of the property for which an accessor
3122 * is added.
3123 * \param signature The signature describes valid receivers for the accessor
3124 * and is used to perform implicit instance checks against them. If the
3125 * receiver is incompatible (i.e. is not an instance of the constructor as
3126 * defined by FunctionTemplate::HasInstance()), an implicit TypeError is
3127 * thrown and no callback is invoked.
3128 */
3129 void SetNativeDataProperty(Local<String> name,
3130 AccessorGetterCallback getter,
3131 AccessorSetterCallback setter = 0,
3132 // TODO(dcarney): gcc can't handle Local below
3133 Handle<Value> data = Handle<Value>(),
3134 PropertyAttribute attribute = None,
3135 Local<AccessorSignature> signature =
3136 Local<AccessorSignature>(),
3137 AccessControl settings = DEFAULT);
3138
3139 // This function is not yet stable and should not be used at this time.
3140 bool SetDeclaredAccessor(Local<String> name,
3141 Local<DeclaredAccessorDescriptor> descriptor,
3142 PropertyAttribute attribute = None,
3143 Local<AccessorSignature> signature =
3144 Local<AccessorSignature>(),
3145 AccessControl settings = DEFAULT);
3146
2986 private: 3147 private:
2987 Template(); 3148 Template();
2988 3149
2989 friend class ObjectTemplate; 3150 friend class ObjectTemplate;
2990 friend class FunctionTemplate; 3151 friend class FunctionTemplate;
2991 }; 3152 };
2992 3153
2993 3154
2994 template<typename T>
2995 class ReturnValue {
2996 public:
2997 template <class S> V8_INLINE(ReturnValue(const ReturnValue<S>& that))
2998 : value_(that.value_) {
2999 TYPE_CHECK(T, S);
3000 }
3001 // Handle setters
3002 template <typename S> V8_INLINE(void Set(const Persistent<S>& handle));
3003 template <typename S> V8_INLINE(void Set(const Handle<S> handle));
3004 // Fast primitive setters
3005 V8_INLINE(void Set(bool value));
3006 V8_INLINE(void Set(double i));
3007 V8_INLINE(void Set(int32_t i));
3008 V8_INLINE(void Set(uint32_t i));
3009 // Fast JS primitive setters
3010 V8_INLINE(void SetNull());
3011 V8_INLINE(void SetUndefined());
3012 V8_INLINE(void SetEmptyString());
3013 // Convenience getter for Isolate
3014 V8_INLINE(Isolate* GetIsolate());
3015
3016 private:
3017 template<class F> friend class ReturnValue;
3018 template<class F> friend class FunctionCallbackInfo;
3019 template<class F> friend class PropertyCallbackInfo;
3020 V8_INLINE(internal::Object* GetDefaultValue());
3021 V8_INLINE(explicit ReturnValue(internal::Object** slot));
3022 internal::Object** value_;
3023 };
3024
3025
3026 /** 3155 /**
3027 * The argument information given to function call callbacks. This
3028 * class provides access to information about the context of the call,
3029 * including the receiver, the number and values of arguments, and
3030 * the holder of the function.
3031 */
3032 template<typename T>
3033 class FunctionCallbackInfo {
3034 public:
3035 V8_INLINE(int Length() const);
3036 V8_INLINE(Local<Value> operator[](int i) const);
3037 V8_INLINE(Local<Function> Callee() const);
3038 V8_INLINE(Local<Object> This() const);
3039 V8_INLINE(Local<Object> Holder() const);
3040 V8_INLINE(bool IsConstructCall() const);
3041 V8_INLINE(Local<Value> Data() const);
3042 V8_INLINE(Isolate* GetIsolate() const);
3043 V8_INLINE(ReturnValue<T> GetReturnValue() const);
3044 // This shouldn't be public, but the arm compiler needs it.
3045 static const int kArgsLength = 6;
3046
3047 protected:
3048 friend class internal::FunctionCallbackArguments;
3049 friend class internal::CustomArguments<FunctionCallbackInfo>;
3050 static const int kReturnValueIndex = 0;
3051 static const int kReturnValueDefaultValueIndex = -1;
3052 static const int kIsolateIndex = -2;
3053 static const int kDataIndex = -3;
3054 static const int kCalleeIndex = -4;
3055 static const int kHolderIndex = -5;
3056
3057 V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args,
3058 internal::Object** values,
3059 int length,
3060 bool is_construct_call));
3061 internal::Object** implicit_args_;
3062 internal::Object** values_;
3063 int length_;
3064 bool is_construct_call_;
3065 };
3066
3067
3068 /**
3069 * The information passed to a property callback about the context
3070 * of the property access.
3071 */
3072 template<typename T>
3073 class PropertyCallbackInfo {
3074 public:
3075 V8_INLINE(Isolate* GetIsolate() const);
3076 V8_INLINE(Local<Value> Data() const);
3077 V8_INLINE(Local<Object> This() const);
3078 V8_INLINE(Local<Object> Holder() const);
3079 V8_INLINE(ReturnValue<T> GetReturnValue() const);
3080 // This shouldn't be public, but the arm compiler needs it.
3081 static const int kArgsLength = 6;
3082
3083 protected:
3084 friend class MacroAssembler;
3085 friend class internal::PropertyCallbackArguments;
3086 friend class internal::CustomArguments<PropertyCallbackInfo>;
3087 static const int kThisIndex = 0;
3088 static const int kHolderIndex = -1;
3089 static const int kDataIndex = -2;
3090 static const int kReturnValueIndex = -3;
3091 static const int kReturnValueDefaultValueIndex = -4;
3092 static const int kIsolateIndex = -5;
3093
3094 V8_INLINE(PropertyCallbackInfo(internal::Object** args))
3095 : args_(args) { }
3096 internal::Object** args_;
3097 };
3098
3099
3100 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
3101
3102 /**
3103 * NamedProperty[Getter|Setter] are used as interceptors on object. 3156 * NamedProperty[Getter|Setter] are used as interceptors on object.
3104 * See ObjectTemplate::SetNamedPropertyHandler. 3157 * See ObjectTemplate::SetNamedPropertyHandler.
3105 */ 3158 */
3106 typedef void (*NamedPropertyGetterCallback)( 3159 typedef void (*NamedPropertyGetterCallback)(
3107 Local<String> property, 3160 Local<String> property,
3108 const PropertyCallbackInfo<Value>& info); 3161 const PropertyCallbackInfo<Value>& info);
3109 3162
3110 3163
3111 /** 3164 /**
3112 * Returns the value if the setter intercepts the request. 3165 * Returns the value if the setter intercepts the request.
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
3442 */ 3495 */
3443 void SetAccessor(Handle<String> name, 3496 void SetAccessor(Handle<String> name,
3444 AccessorGetterCallback getter, 3497 AccessorGetterCallback getter,
3445 AccessorSetterCallback setter = 0, 3498 AccessorSetterCallback setter = 0,
3446 Handle<Value> data = Handle<Value>(), 3499 Handle<Value> data = Handle<Value>(),
3447 AccessControl settings = DEFAULT, 3500 AccessControl settings = DEFAULT,
3448 PropertyAttribute attribute = None, 3501 PropertyAttribute attribute = None,
3449 Handle<AccessorSignature> signature = 3502 Handle<AccessorSignature> signature =
3450 Handle<AccessorSignature>()); 3503 Handle<AccessorSignature>());
3451 3504
3452 // This function is not yet stable and should not be used at this time.
3453 bool SetAccessor(Handle<String> name,
3454 Handle<DeclaredAccessorDescriptor> descriptor,
3455 AccessControl settings = DEFAULT,
3456 PropertyAttribute attribute = None,
3457 Handle<AccessorSignature> signature =
3458 Handle<AccessorSignature>());
3459
3460 /** 3505 /**
3461 * Sets a named property handler on the object template. 3506 * Sets a named property handler on the object template.
3462 * 3507 *
3463 * Whenever a named property is accessed on objects created from 3508 * Whenever a named property is accessed on objects created from
3464 * this object template, the provided callback is invoked instead of 3509 * this object template, the provided callback is invoked instead of
3465 * accessing the property directly on the JavaScript object. 3510 * accessing the property directly on the JavaScript object.
3466 * 3511 *
3467 * \param getter The callback to invoke when getting a property. 3512 * \param getter The callback to invoke when getting a property.
3468 * \param setter The callback to invoke when setting a property. 3513 * \param setter The callback to invoke when setting a property.
3469 * \param query The callback to invoke to check if a property is present, 3514 * \param query The callback to invoke to check if a property is present,
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
4550 */ 4595 */
4551 static void SetJitCodeEventHandler(JitCodeEventOptions options, 4596 static void SetJitCodeEventHandler(JitCodeEventOptions options,
4552 JitCodeEventHandler event_handler); 4597 JitCodeEventHandler event_handler);
4553 4598
4554 // TODO(svenpanne) Really deprecate me when Chrome is fixed. 4599 // TODO(svenpanne) Really deprecate me when Chrome is fixed.
4555 /** Deprecated. Use Isolate::AdjustAmountOfExternalAllocatedMemory instead. */ 4600 /** Deprecated. Use Isolate::AdjustAmountOfExternalAllocatedMemory instead. */
4556 static intptr_t AdjustAmountOfExternalAllocatedMemory( 4601 static intptr_t AdjustAmountOfExternalAllocatedMemory(
4557 intptr_t change_in_bytes); 4602 intptr_t change_in_bytes);
4558 4603
4559 /** 4604 /**
4560 * Retrieve the V8 thread id of the calling thread.
4561 *
4562 * The thread id for a thread should only be retrieved after the V8
4563 * lock has been acquired with a Locker object with that thread.
4564 */
4565 static int GetCurrentThreadId();
4566
4567 /**
4568 * Forcefully terminate execution of a JavaScript thread. This can
4569 * be used to terminate long-running scripts.
4570 *
4571 * TerminateExecution should only be called when then V8 lock has
4572 * been acquired with a Locker object. Therefore, in order to be
4573 * able to terminate long-running threads, preemption must be
4574 * enabled to allow the user of TerminateExecution to acquire the
4575 * lock.
4576 *
4577 * The termination is achieved by throwing an exception that is
4578 * uncatchable by JavaScript exception handlers. Termination
4579 * exceptions act as if they were caught by a C++ TryCatch exception
4580 * handler. If forceful termination is used, any C++ TryCatch
4581 * exception handler that catches an exception should check if that
4582 * exception is a termination exception and immediately return if
4583 * that is the case. Returning immediately in that case will
4584 * continue the propagation of the termination exception if needed.
4585 *
4586 * The thread id passed to TerminateExecution must have been
4587 * obtained by calling GetCurrentThreadId on the thread in question.
4588 *
4589 * \param thread_id The thread id of the thread to terminate.
4590 */
4591 static void TerminateExecution(int thread_id);
4592
4593 /**
4594 * Forcefully terminate the current thread of JavaScript execution 4605 * Forcefully terminate the current thread of JavaScript execution
4595 * in the given isolate. If no isolate is provided, the default 4606 * in the given isolate. If no isolate is provided, the default
4596 * isolate is used. 4607 * isolate is used.
4597 * 4608 *
4598 * This method can be used by any thread even if that thread has not 4609 * This method can be used by any thread even if that thread has not
4599 * acquired the V8 lock with a Locker object. 4610 * acquired the V8 lock with a Locker object.
4600 * 4611 *
4601 * \param isolate The isolate in which to terminate the current JS execution. 4612 * \param isolate The isolate in which to terminate the current JS execution.
4602 */ 4613 */
4603 static void TerminateExecution(Isolate* isolate = NULL); 4614 static void TerminateExecution(Isolate* isolate = NULL);
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
5729 typedef internal::Internals I; 5740 typedef internal::Internals I;
5730 if (this->IsEmpty()) return; 5741 if (this->IsEmpty()) return;
5731 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), 5742 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
5732 true, 5743 true,
5733 I::kNodeIsPartiallyDependentShift); 5744 I::kNodeIsPartiallyDependentShift);
5734 } 5745 }
5735 5746
5736 5747
5737 template <class T> 5748 template <class T>
5738 void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) { 5749 void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) {
5739 Dispose(isolate); 5750 Dispose();
5740 #ifdef V8_USE_UNSAFE_HANDLES 5751 #ifdef V8_USE_UNSAFE_HANDLES
5741 *this = *New(isolate, other); 5752 *this = *New(isolate, other);
5742 #else 5753 #else
5743 if (other.IsEmpty()) { 5754 if (other.IsEmpty()) {
5744 this->val_ = NULL; 5755 this->val_ = NULL;
5745 return; 5756 return;
5746 } 5757 }
5747 internal::Object** p = reinterpret_cast<internal::Object**>(other.val_); 5758 internal::Object** p = reinterpret_cast<internal::Object**>(other.val_);
5748 this->val_ = reinterpret_cast<T*>( 5759 this->val_ = reinterpret_cast<T*>(
5749 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), p)); 5760 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), p));
5750 #endif 5761 #endif
5751 } 5762 }
5752 5763
5753 5764
5754 #ifndef V8_USE_UNSAFE_HANDLES 5765 #ifndef V8_USE_UNSAFE_HANDLES
5755 template <class T> 5766 template <class T>
5756 void Persistent<T>::Reset(Isolate* isolate, const Persistent<T>& other) { 5767 void Persistent<T>::Reset(Isolate* isolate, const Persistent<T>& other) {
5757 Dispose(isolate); 5768 Dispose();
5758 if (other.IsEmpty()) { 5769 if (other.IsEmpty()) {
5759 this->val_ = NULL; 5770 this->val_ = NULL;
5760 return; 5771 return;
5761 } 5772 }
5762 internal::Object** p = reinterpret_cast<internal::Object**>(other.val_); 5773 internal::Object** p = reinterpret_cast<internal::Object**>(other.val_);
5763 this->val_ = reinterpret_cast<T*>( 5774 this->val_ = reinterpret_cast<T*>(
5764 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), p)); 5775 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), p));
5765 } 5776 }
5766 #endif 5777 #endif
5767 5778
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
6499 */ 6510 */
6500 6511
6501 6512
6502 } // namespace v8 6513 } // namespace v8
6503 6514
6504 6515
6505 #undef TYPE_CHECK 6516 #undef TYPE_CHECK
6506 6517
6507 6518
6508 #endif // V8_H_ 6519 #endif // V8_H_
OLDNEW
« no previous file with comments | « ChangeLog ('k') | include/v8-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698