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

Side by Side Diff: include/v8.h

Issue 157543002: A64: Synchronize with r18581. (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 | « build/gyp_v8 ('k') | samples/lineprocessor.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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 731
732 732
733 /** 733 /**
734 * A PersistentBase which has move semantics. 734 * A PersistentBase which has move semantics.
735 * 735 *
736 * Note: Persistent class hierarchy is subject to future changes. 736 * Note: Persistent class hierarchy is subject to future changes.
737 */ 737 */
738 template<class T> 738 template<class T>
739 class UniquePersistent : public PersistentBase<T> { 739 class UniquePersistent : public PersistentBase<T> {
740 struct RValue { 740 struct RValue {
741 V8_INLINE explicit RValue(UniquePersistent* object) : object(object) {} 741 V8_INLINE explicit RValue(UniquePersistent* obj) : object(obj) {}
742 UniquePersistent* object; 742 UniquePersistent* object;
743 }; 743 };
744 744
745 public: 745 public:
746 /** 746 /**
747 * A UniquePersistent with no storage cell. 747 * A UniquePersistent with no storage cell.
748 */ 748 */
749 V8_INLINE UniquePersistent() : PersistentBase<T>(0) { } 749 V8_INLINE UniquePersistent() : PersistentBase<T>(0) { }
750 /** 750 /**
751 * Construct a UniquePersistent from a Handle. 751 * Construct a UniquePersistent from a Handle.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 */ 816 */
817 class V8_EXPORT HandleScope { 817 class V8_EXPORT HandleScope {
818 public: 818 public:
819 HandleScope(Isolate* isolate); 819 HandleScope(Isolate* isolate);
820 820
821 ~HandleScope(); 821 ~HandleScope();
822 822
823 /** 823 /**
824 * Counts the number of allocated handles. 824 * Counts the number of allocated handles.
825 */ 825 */
826 static int NumberOfHandles(); 826 static int NumberOfHandles(Isolate* isolate);
827 827
828 private: 828 private:
829 /** 829 /**
830 * Creates a new handle with the given value. 830 * Creates a new handle with the given value.
831 */ 831 */
832 static internal::Object** CreateHandle(internal::Isolate* isolate, 832 static internal::Object** CreateHandle(internal::Isolate* isolate,
833 internal::Object* value); 833 internal::Object* value);
834 // Uses HeapObject to obtain the current Isolate. 834 // Uses HeapObject to obtain the current Isolate.
835 static internal::Object** CreateHandle(internal::HeapObject* heap_object, 835 static internal::Object** CreateHandle(internal::HeapObject* heap_object,
836 internal::Object* value); 836 internal::Object* value);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 * compiling it, and can be stored between compilations. When script 938 * compiling it, and can be stored between compilations. When script
939 * data is given to the compile method compilation will be faster. 939 * data is given to the compile method compilation will be faster.
940 */ 940 */
941 class V8_EXPORT ScriptData { // NOLINT 941 class V8_EXPORT ScriptData { // NOLINT
942 public: 942 public:
943 virtual ~ScriptData() { } 943 virtual ~ScriptData() { }
944 944
945 /** 945 /**
946 * Pre-compiles the specified script (context-independent). 946 * Pre-compiles the specified script (context-independent).
947 * 947 *
948 * \param input Pointer to UTF-8 script source code.
949 * \param length Length of UTF-8 script source code.
950 */
951 static ScriptData* PreCompile(Isolate* isolate,
952 const char* input,
953 int length);
954
955 /**
956 * Pre-compiles the specified script (context-independent).
957 *
958 * NOTE: Pre-compilation using this method cannot happen on another thread 948 * NOTE: Pre-compilation using this method cannot happen on another thread
959 * without using Lockers. 949 * without using Lockers.
960 * 950 *
961 * \param source Script source code. 951 * \param source Script source code.
962 */ 952 */
963 static ScriptData* PreCompile(Handle<String> source); 953 static ScriptData* PreCompile(Handle<String> source);
964 954
965 /** 955 /**
966 * Load previous pre-compilation data. 956 * Load previous pre-compilation data.
967 * 957 *
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 int options = NO_OPTIONS) const; 1651 int options = NO_OPTIONS) const;
1662 // UTF-8 encoded characters. 1652 // UTF-8 encoded characters.
1663 int WriteUtf8(char* buffer, 1653 int WriteUtf8(char* buffer,
1664 int length = -1, 1654 int length = -1,
1665 int* nchars_ref = NULL, 1655 int* nchars_ref = NULL,
1666 int options = NO_OPTIONS) const; 1656 int options = NO_OPTIONS) const;
1667 1657
1668 /** 1658 /**
1669 * A zero length string. 1659 * A zero length string.
1670 */ 1660 */
1671 static v8::Local<v8::String> Empty();
1672 V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate); 1661 V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate);
1673 1662
1674 /** 1663 /**
1675 * Returns true if the string is external 1664 * Returns true if the string is external
1676 */ 1665 */
1677 bool IsExternal() const; 1666 bool IsExternal() const;
1678 1667
1679 /** 1668 /**
1680 * Returns true if the string is both external and ASCII 1669 * Returns true if the string is both external and ASCII
1681 */ 1670 */
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 }; 1945 };
1957 1946
1958 1947
1959 /** 1948 /**
1960 * A JavaScript number value (ECMA-262, 4.3.20) 1949 * A JavaScript number value (ECMA-262, 4.3.20)
1961 */ 1950 */
1962 class V8_EXPORT Number : public Primitive { 1951 class V8_EXPORT Number : public Primitive {
1963 public: 1952 public:
1964 double Value() const; 1953 double Value() const;
1965 static Local<Number> New(Isolate* isolate, double value); 1954 static Local<Number> New(Isolate* isolate, double value);
1966 // Will be deprecated soon.
1967 static Local<Number> New(double value);
1968 V8_INLINE static Number* Cast(v8::Value* obj); 1955 V8_INLINE static Number* Cast(v8::Value* obj);
1969 private: 1956 private:
1970 Number(); 1957 Number();
1971 static void CheckCast(v8::Value* obj); 1958 static void CheckCast(v8::Value* obj);
1972 }; 1959 };
1973 1960
1974 1961
1975 /** 1962 /**
1976 * A JavaScript value representing a signed integer. 1963 * A JavaScript value representing a signed integer.
1977 */ 1964 */
1978 class V8_EXPORT Integer : public Number { 1965 class V8_EXPORT Integer : public Number {
1979 public: 1966 public:
1980 static Local<Integer> New(Isolate* isolate, int32_t value); 1967 static Local<Integer> New(Isolate* isolate, int32_t value);
1981 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value); 1968 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
1982 // Will be deprecated soon.
1983 static Local<Integer> New(int32_t value, Isolate*);
1984 static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*);
1985 static Local<Integer> New(int32_t value);
1986 static Local<Integer> NewFromUnsigned(uint32_t value);
1987 int64_t Value() const; 1969 int64_t Value() const;
1988 V8_INLINE static Integer* Cast(v8::Value* obj); 1970 V8_INLINE static Integer* Cast(v8::Value* obj);
1989 private: 1971 private:
1990 Integer(); 1972 Integer();
1991 static void CheckCast(v8::Value* obj); 1973 static void CheckCast(v8::Value* obj);
1992 }; 1974 };
1993 1975
1994 1976
1995 /** 1977 /**
1996 * A JavaScript value representing a 32-bit signed integer. 1978 * A JavaScript value representing a 32-bit signed integer.
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 Handle<Value> argv[]); 2312 Handle<Value> argv[]);
2331 2313
2332 /** 2314 /**
2333 * Call an Object as a constructor if a callback is set by the 2315 * Call an Object as a constructor if a callback is set by the
2334 * ObjectTemplate::SetCallAsFunctionHandler method. 2316 * ObjectTemplate::SetCallAsFunctionHandler method.
2335 * Note: This method behaves like the Function::NewInstance method. 2317 * Note: This method behaves like the Function::NewInstance method.
2336 */ 2318 */
2337 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); 2319 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]);
2338 2320
2339 static Local<Object> New(Isolate* isolate); 2321 static Local<Object> New(Isolate* isolate);
2340 // Will be deprecated soon. 2322
2341 static Local<Object> New();
2342 V8_INLINE static Object* Cast(Value* obj); 2323 V8_INLINE static Object* Cast(Value* obj);
2343 2324
2344 private: 2325 private:
2345 Object(); 2326 Object();
2346 static void CheckCast(Value* obj); 2327 static void CheckCast(Value* obj);
2347 Local<Value> SlowGetInternalField(int index); 2328 Local<Value> SlowGetInternalField(int index);
2348 void* SlowGetAlignedPointerFromInternalField(int index); 2329 void* SlowGetAlignedPointerFromInternalField(int index);
2349 }; 2330 };
2350 2331
2351 2332
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
3346 */ 3327 */
3347 class V8_EXPORT FunctionTemplate : public Template { 3328 class V8_EXPORT FunctionTemplate : public Template {
3348 public: 3329 public:
3349 /** Creates a function template.*/ 3330 /** Creates a function template.*/
3350 static Local<FunctionTemplate> New( 3331 static Local<FunctionTemplate> New(
3351 Isolate* isolate, 3332 Isolate* isolate,
3352 FunctionCallback callback = 0, 3333 FunctionCallback callback = 0,
3353 Handle<Value> data = Handle<Value>(), 3334 Handle<Value> data = Handle<Value>(),
3354 Handle<Signature> signature = Handle<Signature>(), 3335 Handle<Signature> signature = Handle<Signature>(),
3355 int length = 0); 3336 int length = 0);
3356 // Will be deprecated soon.
3357 static Local<FunctionTemplate> New(
3358 FunctionCallback callback = 0,
3359 Handle<Value> data = Handle<Value>(),
3360 Handle<Signature> signature = Handle<Signature>(),
3361 int length = 0);
3362 3337
3363 /** Returns the unique function instance in the current execution context.*/ 3338 /** Returns the unique function instance in the current execution context.*/
3364 Local<Function> GetFunction(); 3339 Local<Function> GetFunction();
3365 3340
3366 /** 3341 /**
3367 * Set the call-handler callback for a FunctionTemplate. This 3342 * Set the call-handler callback for a FunctionTemplate. This
3368 * callback is called whenever the function created from this 3343 * callback is called whenever the function created from this
3369 * FunctionTemplate is called. 3344 * FunctionTemplate is called.
3370 */ 3345 */
3371 void SetCallHandler(FunctionCallback callback, 3346 void SetCallHandler(FunctionCallback callback,
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
3911 */ 3886 */
3912 enum GCType { 3887 enum GCType {
3913 kGCTypeScavenge = 1 << 0, 3888 kGCTypeScavenge = 1 << 0,
3914 kGCTypeMarkSweepCompact = 1 << 1, 3889 kGCTypeMarkSweepCompact = 1 << 1,
3915 kGCTypeAll = kGCTypeScavenge | kGCTypeMarkSweepCompact 3890 kGCTypeAll = kGCTypeScavenge | kGCTypeMarkSweepCompact
3916 }; 3891 };
3917 3892
3918 enum GCCallbackFlags { 3893 enum GCCallbackFlags {
3919 kNoGCCallbackFlags = 0, 3894 kNoGCCallbackFlags = 0,
3920 kGCCallbackFlagCompacted = 1 << 0, 3895 kGCCallbackFlagCompacted = 1 << 0,
3921 kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1 3896 kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1,
3897 kGCCallbackFlagForced = 1 << 2
3922 }; 3898 };
3923 3899
3924 typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags); 3900 typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags);
3925 typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags); 3901 typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags);
3926 3902
3927 typedef void (*InterruptCallback)(Isolate* isolate, void* data); 3903 typedef void (*InterruptCallback)(Isolate* isolate, void* data);
3928 3904
3929 3905
3930 /** 3906 /**
3931 * Collection of V8 heap information. 3907 * Collection of V8 heap information.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3981 3957
3982 private: 3958 private:
3983 Isolate* const isolate_; 3959 Isolate* const isolate_;
3984 3960
3985 // Prevent copying of Scope objects. 3961 // Prevent copying of Scope objects.
3986 Scope(const Scope&); 3962 Scope(const Scope&);
3987 Scope& operator=(const Scope&); 3963 Scope& operator=(const Scope&);
3988 }; 3964 };
3989 3965
3990 /** 3966 /**
3967 * Types of garbage collections that can be requested via
3968 * RequestGarbageCollectionForTesting.
3969 */
3970 enum GarbageCollectionType {
3971 kFullGarbageCollection,
3972 kMinorGarbageCollection
3973 };
3974
3975 /**
3991 * Creates a new isolate. Does not change the currently entered 3976 * Creates a new isolate. Does not change the currently entered
3992 * isolate. 3977 * isolate.
3993 * 3978 *
3994 * When an isolate is no longer used its resources should be freed 3979 * When an isolate is no longer used its resources should be freed
3995 * by calling Dispose(). Using the delete operator is not allowed. 3980 * by calling Dispose(). Using the delete operator is not allowed.
3996 */ 3981 */
3997 static Isolate* New(); 3982 static Isolate* New();
3998 3983
3999 /** 3984 /**
4000 * Returns the entered isolate for the current thread or NULL in 3985 * Returns the entered isolate for the current thread or NULL in
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
4192 * Registered |callback| must not reenter interrupted Isolate. 4177 * Registered |callback| must not reenter interrupted Isolate.
4193 */ 4178 */
4194 void RequestInterrupt(InterruptCallback callback, void* data); 4179 void RequestInterrupt(InterruptCallback callback, void* data);
4195 4180
4196 /** 4181 /**
4197 * Clear interrupt request created by |RequestInterrupt|. 4182 * Clear interrupt request created by |RequestInterrupt|.
4198 * Can be called from another thread without acquiring a |Locker|. 4183 * Can be called from another thread without acquiring a |Locker|.
4199 */ 4184 */
4200 void ClearInterrupt(); 4185 void ClearInterrupt();
4201 4186
4187 /**
4188 * Request garbage collection in this Isolate. It is only valid to call this
4189 * function if --expose_gc was specified.
4190 *
4191 * This should only be used for testing purposes and not to enforce a garbage
4192 * collection schedule. It has strong negative impact on the garbage
4193 * collection performance. Use IdleNotification() or LowMemoryNotification()
4194 * instead to influence the garbage collection schedule.
4195 */
4196 void RequestGarbageCollectionForTesting(GarbageCollectionType type);
4197
4202 private: 4198 private:
4203 Isolate(); 4199 Isolate();
4204 Isolate(const Isolate&); 4200 Isolate(const Isolate&);
4205 ~Isolate(); 4201 ~Isolate();
4206 Isolate& operator=(const Isolate&); 4202 Isolate& operator=(const Isolate&);
4207 void* operator new(size_t size); 4203 void* operator new(size_t size);
4208 void operator delete(void*, size_t); 4204 void operator delete(void*, size_t);
4209 4205
4210 void SetObjectGroupId(internal::Object** object, UniqueId id); 4206 void SetObjectGroupId(internal::Object** object, UniqueId id);
4211 void SetReferenceFromGroup(UniqueId id, internal::Object** object); 4207 void SetReferenceFromGroup(UniqueId id, internal::Object** object);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
4389 */ 4385 */
4390 class V8_EXPORT PersistentHandleVisitor { // NOLINT 4386 class V8_EXPORT PersistentHandleVisitor { // NOLINT
4391 public: 4387 public:
4392 virtual ~PersistentHandleVisitor() {} 4388 virtual ~PersistentHandleVisitor() {}
4393 virtual void VisitPersistentHandle(Persistent<Value>* value, 4389 virtual void VisitPersistentHandle(Persistent<Value>* value,
4394 uint16_t class_id) {} 4390 uint16_t class_id) {}
4395 }; 4391 };
4396 4392
4397 4393
4398 /** 4394 /**
4399 * Asserts that no action is performed that could cause a handle's value
4400 * to be modified. Useful when otherwise unsafe handle operations need to
4401 * be performed.
4402 */
4403 class V8_EXPORT AssertNoGCScope {
4404 #ifndef DEBUG
4405 // TODO(yangguo): remove isolate argument.
4406 V8_INLINE AssertNoGCScope(Isolate* isolate) {}
4407 #else
4408 AssertNoGCScope(Isolate* isolate);
4409 ~AssertNoGCScope();
4410 private:
4411 void* disallow_heap_allocation_;
4412 #endif
4413 };
4414
4415
4416 /**
4417 * Container class for static utility functions. 4395 * Container class for static utility functions.
4418 */ 4396 */
4419 class V8_EXPORT V8 { 4397 class V8_EXPORT V8 {
4420 public: 4398 public:
4421 /** Set the callback to invoke in case of fatal errors. */ 4399 /** Set the callback to invoke in case of fatal errors. */
4422 static void SetFatalErrorHandler(FatalErrorCallback that); 4400 static void SetFatalErrorHandler(FatalErrorCallback that);
4423 4401
4424 /** 4402 /**
4425 * Set the callback to invoke to check if code generation from 4403 * Set the callback to invoke to check if code generation from
4426 * strings should be allowed. 4404 * strings should be allowed.
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
5791 } 5769 }
5792 5770
5793 template<typename T> 5771 template<typename T>
5794 void ReturnValue<T>::Set(int32_t i) { 5772 void ReturnValue<T>::Set(int32_t i) {
5795 TYPE_CHECK(T, Integer); 5773 TYPE_CHECK(T, Integer);
5796 typedef internal::Internals I; 5774 typedef internal::Internals I;
5797 if (V8_LIKELY(I::IsValidSmi(i))) { 5775 if (V8_LIKELY(I::IsValidSmi(i))) {
5798 *value_ = I::IntToSmi(i); 5776 *value_ = I::IntToSmi(i);
5799 return; 5777 return;
5800 } 5778 }
5801 Set(Integer::New(i, GetIsolate())); 5779 Set(Integer::New(GetIsolate(), i));
5802 } 5780 }
5803 5781
5804 template<typename T> 5782 template<typename T>
5805 void ReturnValue<T>::Set(uint32_t i) { 5783 void ReturnValue<T>::Set(uint32_t i) {
5806 TYPE_CHECK(T, Integer); 5784 TYPE_CHECK(T, Integer);
5807 // Can't simply use INT32_MAX here for whatever reason. 5785 // Can't simply use INT32_MAX here for whatever reason.
5808 bool fits_into_int32_t = (i & (1U << 31)) == 0; 5786 bool fits_into_int32_t = (i & (1U << 31)) == 0;
5809 if (V8_LIKELY(fits_into_int32_t)) { 5787 if (V8_LIKELY(fits_into_int32_t)) {
5810 Set(static_cast<int32_t>(i)); 5788 Set(static_cast<int32_t>(i));
5811 return; 5789 return;
5812 } 5790 }
5813 Set(Integer::NewFromUnsigned(i, GetIsolate())); 5791 Set(Integer::NewFromUnsigned(GetIsolate(), i));
5814 } 5792 }
5815 5793
5816 template<typename T> 5794 template<typename T>
5817 void ReturnValue<T>::Set(bool value) { 5795 void ReturnValue<T>::Set(bool value) {
5818 TYPE_CHECK(T, Boolean); 5796 TYPE_CHECK(T, Boolean);
5819 typedef internal::Internals I; 5797 typedef internal::Internals I;
5820 int root_index; 5798 int root_index;
5821 if (value) { 5799 if (value) {
5822 root_index = I::kTrueValueRootIndex; 5800 root_index = I::kTrueValueRootIndex;
5823 } else { 5801 } else {
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
6461 */ 6439 */
6462 6440
6463 6441
6464 } // namespace v8 6442 } // namespace v8
6465 6443
6466 6444
6467 #undef TYPE_CHECK 6445 #undef TYPE_CHECK
6468 6446
6469 6447
6470 #endif // V8_H_ 6448 #endif // V8_H_
OLDNEW
« no previous file with comments | « build/gyp_v8 ('k') | samples/lineprocessor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698