v8.h | v8.h | |||
---|---|---|---|---|
// Copyright 2007-2008 the V8 project authors. All rights reserved. | // Copyright 2007-2009 the V8 project authors. All rights reserved. | |||
// Redistribution and use in source and binary forms, with or without | // Redistribution and use in source and binary forms, with or without | |||
// modification, are permitted provided that the following conditions are | // modification, are permitted provided that the following conditions are | |||
// met: | // met: | |||
// | // | |||
// * Redistributions of source code must retain the above copyright | // * Redistributions of source code must retain the above copyright | |||
// notice, this list of conditions and the following disclaimer. | // notice, this list of conditions and the following disclaimer. | |||
// * Redistributions in binary form must reproduce the above | // * Redistributions in binary form must reproduce the above | |||
// copyright notice, this list of conditions and the following | // copyright notice, this list of conditions and the following | |||
// disclaimer in the documentation and/or other materials provided | // disclaimer in the documentation and/or other materials provided | |||
// with the distribution. | // with the distribution. | |||
skipping to change at line 133 | skipping to change at line 133 | |||
template <class T> class Handle; | template <class T> class Handle; | |||
template <class T> class Local; | template <class T> class Local; | |||
template <class T> class Persistent; | template <class T> class Persistent; | |||
class FunctionTemplate; | class FunctionTemplate; | |||
class ObjectTemplate; | class ObjectTemplate; | |||
class Data; | class Data; | |||
namespace internal { | namespace internal { | |||
class Object; | class Object; | |||
class Arguments; | ||||
} | } | |||
// --- W e a k H a n d l e s | // --- W e a k H a n d l e s | |||
/** | /** | |||
* A weak reference callback function. | * A weak reference callback function. | |||
* | * | |||
* \param object the weak global object to be reclaimed by the garbage coll ector | * \param object the weak global object to be reclaimed by the garbage coll ector | |||
* \param parameter the value passed in when making the weak global object | * \param parameter the value passed in when making the weak global object | |||
skipping to change at line 1381 | skipping to change at line 1382 | |||
void** values_; | void** values_; | |||
int length_; | int length_; | |||
}; | }; | |||
/** | /** | |||
* The information passed to an accessor callback about the context | * The information passed to an accessor callback about the context | |||
* of the property access. | * of the property access. | |||
*/ | */ | |||
class V8EXPORT AccessorInfo { | class V8EXPORT AccessorInfo { | |||
public: | public: | |||
inline AccessorInfo(Local<Object> self, | inline AccessorInfo(internal::Object** args) | |||
Local<Value> data, | : args_(args) { } | |||
Local<Object> holder) | ||||
: self_(self), data_(data), holder_(holder) { } | ||||
inline Local<Value> Data() const; | inline Local<Value> Data() const; | |||
inline Local<Object> This() const; | inline Local<Object> This() const; | |||
inline Local<Object> Holder() const; | inline Local<Object> Holder() const; | |||
private: | private: | |||
Local<Object> self_; | internal::Object** args_; | |||
Local<Value> data_; | ||||
Local<Object> holder_; | ||||
}; | }; | |||
typedef Handle<Value> (*InvocationCallback)(const Arguments& args); | typedef Handle<Value> (*InvocationCallback)(const Arguments& args); | |||
typedef int (*LookupCallback)(Local<Object> self, Local<String> name); | typedef int (*LookupCallback)(Local<Object> self, Local<String> name); | |||
/** | /** | |||
* Accessor[Getter|Setter] are used as callback functions when | * Accessor[Getter|Setter] are used as callback functions when | |||
* setting|getting a particular property. See objectTemplate::SetAccessor. | * setting|getting a particular property. See objectTemplate::SetAccessor. | |||
*/ | */ | |||
skipping to change at line 1533 | skipping to change at line 1530 | |||
* property with the given index on the host object. | * property with the given index on the host object. | |||
*/ | */ | |||
typedef bool (*IndexedSecurityCallback)(Local<Object> host, | typedef bool (*IndexedSecurityCallback)(Local<Object> host, | |||
uint32_t index, | uint32_t index, | |||
AccessType type, | AccessType type, | |||
Local<Value> data); | Local<Value> data); | |||
/** | /** | |||
* A FunctionTemplate is used to create functions at runtime. There | * A FunctionTemplate is used to create functions at runtime. There | |||
* can only be one function created from a FunctionTemplate in a | * can only be one function created from a FunctionTemplate in a | |||
* context. | * context. The lifetime of the created function is equal to the | |||
* lifetime of the context. So in case the embedder needs to create | ||||
* temporary functions that can be collected using Scripts is | ||||
* preferred. | ||||
* | * | |||
* A FunctionTemplate can have properties, these properties are added to th e | * A FunctionTemplate can have properties, these properties are added to th e | |||
* function object when it is created. | * function object when it is created. | |||
* | * | |||
* A FunctionTemplate has a corresponding instance template which is | * A FunctionTemplate has a corresponding instance template which is | |||
* used to create object instances when the function is used as a | * used to create object instances when the function is used as a | |||
* constructor. Properties added to the instance template are added to | * constructor. Properties added to the instance template are added to | |||
* each object instance. | * each object instance. | |||
* | * | |||
* A FunctionTemplate can have a prototype template. The prototype template | * A FunctionTemplate can have a prototype template. The prototype template | |||
skipping to change at line 1929 | skipping to change at line 1929 | |||
}; | }; | |||
// --- S t a t i c s --- | // --- S t a t i c s --- | |||
Handle<Primitive> V8EXPORT Undefined(); | Handle<Primitive> V8EXPORT Undefined(); | |||
Handle<Primitive> V8EXPORT Null(); | Handle<Primitive> V8EXPORT Null(); | |||
Handle<Boolean> V8EXPORT True(); | Handle<Boolean> V8EXPORT True(); | |||
Handle<Boolean> V8EXPORT False(); | Handle<Boolean> V8EXPORT False(); | |||
/** | /** | |||
* A set of constraints that specifies the limits of the runtime's | * A set of constraints that specifies the limits of the runtime's memory u | |||
* memory use. | se. | |||
* You must set the heap size before initializing the VM - the size cannot | ||||
be | ||||
* adjusted after the VM is initialized. | ||||
* | ||||
* If you are using threads then you should hold the V8::Locker lock while | ||||
* setting the stack limit and you must set a non-default stack limit separ | ||||
ately | ||||
* for each thread. | ||||
*/ | */ | |||
class V8EXPORT ResourceConstraints { | class V8EXPORT ResourceConstraints { | |||
public: | public: | |||
ResourceConstraints(); | ResourceConstraints(); | |||
int max_young_space_size() const { return max_young_space_size_; } | int max_young_space_size() const { return max_young_space_size_; } | |||
void set_max_young_space_size(int value) { max_young_space_size_ = value; } | void set_max_young_space_size(int value) { max_young_space_size_ = value; } | |||
int max_old_space_size() const { return max_old_space_size_; } | int max_old_space_size() const { return max_old_space_size_; } | |||
void set_max_old_space_size(int value) { max_old_space_size_ = value; } | void set_max_old_space_size(int value) { max_old_space_size_ = value; } | |||
uint32_t* stack_limit() const { return stack_limit_; } | uint32_t* stack_limit() const { return stack_limit_; } | |||
// Sets an address beyond which the VM's stack may not grow. | ||||
void set_stack_limit(uint32_t* value) { stack_limit_ = value; } | void set_stack_limit(uint32_t* value) { stack_limit_ = value; } | |||
private: | private: | |||
int max_young_space_size_; | int max_young_space_size_; | |||
int max_old_space_size_; | int max_old_space_size_; | |||
uint32_t* stack_limit_; | uint32_t* stack_limit_; | |||
}; | }; | |||
bool SetResourceConstraints(ResourceConstraints* constraints); | bool SetResourceConstraints(ResourceConstraints* constraints); | |||
// --- E x c e p t i o n s --- | // --- E x c e p t i o n s --- | |||
skipping to change at line 2138 | skipping to change at line 2144 | |||
* object in the group is alive, all objects in the group are alive. | * object in the group is alive, all objects in the group are alive. | |||
* After each garbage collection, object groups are removed. It is | * After each garbage collection, object groups are removed. It is | |||
* intended to be used in the before-garbage-collection callback | * intended to be used in the before-garbage-collection callback | |||
* function, for instance to simulate DOM tree connections among JS | * function, for instance to simulate DOM tree connections among JS | |||
* wrapper objects. | * wrapper objects. | |||
*/ | */ | |||
static void AddObjectGroup(Persistent<Value>* objects, size_t length); | static void AddObjectGroup(Persistent<Value>* objects, size_t length); | |||
/** | /** | |||
* Initializes from snapshot if possible. Otherwise, attempts to | * Initializes from snapshot if possible. Otherwise, attempts to | |||
* initialize from scratch. | * initialize from scratch. This function is called implicitly if | |||
* you use the API without calling it first. | ||||
*/ | */ | |||
static bool Initialize(); | static bool Initialize(); | |||
/** | /** | |||
* Adjusts the amount of registered external memory. Used to give | * Adjusts the amount of registered external memory. Used to give | |||
* V8 an indication of the amount of externally allocated memory | * V8 an indication of the amount of externally allocated memory | |||
* that is kept alive by JavaScript objects. V8 uses this to decide | * that is kept alive by JavaScript objects. V8 uses this to decide | |||
* when to perform global garbage collections. Registering | * when to perform global garbage collections. Registering | |||
* externally allocated memory will trigger global garbage | * externally allocated memory will trigger global garbage | |||
* collections more often than otherwise in an attempt to garbage | * collections more often than otherwise in an attempt to garbage | |||
skipping to change at line 2280 | skipping to change at line 2287 | |||
* It should generally not be necessary to dispose v8 before exiting | * It should generally not be necessary to dispose v8 before exiting | |||
* a process, this should happen automatically. It is only necessary | * a process, this should happen automatically. It is only necessary | |||
* to use if the process needs the resources taken up by v8. | * to use if the process needs the resources taken up by v8. | |||
*/ | */ | |||
static bool Dispose(); | static bool Dispose(); | |||
/** | /** | |||
* Optional notification that the embedder is idle. | * Optional notification that the embedder is idle. | |||
* V8 uses the notification to reduce memory footprint. | * V8 uses the notification to reduce memory footprint. | |||
* This call can be used repeatedly if the embedder remains idle. | * This call can be used repeatedly if the embedder remains idle. | |||
* \param is_high_priority tells whether the embedder is high priority. | ||||
* Returns true if the embedder should stop calling IdleNotification | * Returns true if the embedder should stop calling IdleNotification | |||
* until real work has been done. This indicates that V8 has done | * until real work has been done. This indicates that V8 has done | |||
* as much cleanup as it will be able to do. | * as much cleanup as it will be able to do. | |||
*/ | */ | |||
static bool IdleNotification(bool is_high_priority); | static bool IdleNotification(); | |||
/** | /** | |||
* Optional notification that the system is running low on memory. | * Optional notification that the system is running low on memory. | |||
* V8 uses these notifications to attempt to free memory. | * V8 uses these notifications to attempt to free memory. | |||
*/ | */ | |||
static void LowMemoryNotification(); | static void LowMemoryNotification(); | |||
private: | private: | |||
V8(); | V8(); | |||
skipping to change at line 2781 | skipping to change at line 2787 | |||
} | } | |||
bool Arguments::IsConstructCall() const { | bool Arguments::IsConstructCall() const { | |||
return is_construct_call_; | return is_construct_call_; | |||
} | } | |||
int Arguments::Length() const { | int Arguments::Length() const { | |||
return length_; | return length_; | |||
} | } | |||
Local<Value> AccessorInfo::Data() const { | ||||
return data_; | ||||
} | ||||
Local<Object> AccessorInfo::This() const { | ||||
return self_; | ||||
} | ||||
Local<Object> AccessorInfo::Holder() const { | ||||
return holder_; | ||||
} | ||||
template <class T> | template <class T> | |||
Local<T> HandleScope::Close(Handle<T> value) { | Local<T> HandleScope::Close(Handle<T> value) { | |||
internal::Object** before = reinterpret_cast<internal::Object**>(*value); | internal::Object** before = reinterpret_cast<internal::Object**>(*value); | |||
internal::Object** after = RawClose(before); | internal::Object** after = RawClose(before); | |||
return Local<T>(reinterpret_cast<T*>(after)); | return Local<T>(reinterpret_cast<T*>(after)); | |||
} | } | |||
Handle<Value> ScriptOrigin::ResourceName() const { | Handle<Value> ScriptOrigin::ResourceName() const { | |||
return resource_name_; | return resource_name_; | |||
} | } | |||
skipping to change at line 2970 | skipping to change at line 2964 | |||
return static_cast<Function*>(value); | return static_cast<Function*>(value); | |||
} | } | |||
External* External::Cast(v8::Value* value) { | External* External::Cast(v8::Value* value) { | |||
#ifdef V8_ENABLE_CHECKS | #ifdef V8_ENABLE_CHECKS | |||
CheckCast(value); | CheckCast(value); | |||
#endif | #endif | |||
return static_cast<External*>(value); | return static_cast<External*>(value); | |||
} | } | |||
Local<Value> AccessorInfo::Data() const { | ||||
return Local<Value>(reinterpret_cast<Value*>(&args_[-3])); | ||||
} | ||||
Local<Object> AccessorInfo::This() const { | ||||
return Local<Object>(reinterpret_cast<Object*>(&args_[0])); | ||||
} | ||||
Local<Object> AccessorInfo::Holder() const { | ||||
return Local<Object>(reinterpret_cast<Object*>(&args_[-1])); | ||||
} | ||||
/** | /** | |||
* \example shell.cc | * \example shell.cc | |||
* A simple shell that takes a list of expressions on the | * A simple shell that takes a list of expressions on the | |||
* command-line and executes them. | * command-line and executes them. | |||
*/ | */ | |||
/** | /** | |||
* \example process.cc | * \example process.cc | |||
*/ | */ | |||
End of changes. 12 change blocks. | ||||
26 lines changed or deleted | 35 lines changed or added | |||