v8.h | v8.h | |||
---|---|---|---|---|
skipping to change at line 1068 | skipping to change at line 1068 | |||
// UTF-8 encoded characters. | // UTF-8 encoded characters. | |||
V8EXPORT int WriteUtf8(char* buffer, | V8EXPORT int WriteUtf8(char* buffer, | |||
int length = -1, | int length = -1, | |||
int* nchars_ref = NULL, | int* nchars_ref = NULL, | |||
int options = NO_OPTIONS) const; | int options = NO_OPTIONS) const; | |||
/** | /** | |||
* A zero length string. | * A zero length string. | |||
*/ | */ | |||
V8EXPORT static v8::Local<v8::String> Empty(); | V8EXPORT static v8::Local<v8::String> Empty(); | |||
inline static v8::Local<v8::String> Empty(Isolate* isolate); | ||||
/** | /** | |||
* Returns true if the string is external | * Returns true if the string is external | |||
*/ | */ | |||
V8EXPORT bool IsExternal() const; | V8EXPORT bool IsExternal() const; | |||
/** | /** | |||
* Returns true if the string is both external and ASCII | * Returns true if the string is both external and ASCII | |||
*/ | */ | |||
V8EXPORT bool IsExternalAscii() const; | V8EXPORT bool IsExternalAscii() const; | |||
skipping to change at line 2506 | skipping to change at line 2507 | |||
} | } | |||
}; | }; | |||
// --- Statics --- | // --- Statics --- | |||
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(); | |||
inline Handle<Primitive> Undefined(Isolate* isolate); | ||||
inline Handle<Primitive> Null(Isolate* isolate); | ||||
inline Handle<Boolean> True(Isolate* isolate); | ||||
inline Handle<Boolean> False(Isolate* isolate); | ||||
/** | /** | |||
* A set of constraints that specifies the limits of the runtime's memory u se. | * A set of constraints that specifies the limits of the runtime's memory u se. | |||
* You must set the heap size before initializing the VM - the size cannot be | * You must set the heap size before initializing the VM - the size cannot be | |||
* adjusted after the VM is initialized. | * adjusted after the VM is initialized. | |||
* | * | |||
* If you are using threads then you should hold the V8::Locker lock while | * 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 | * setting the stack limit and you must set a non-default stack limit separ ately | |||
* for each thread. | * for each thread. | |||
*/ | */ | |||
class V8EXPORT ResourceConstraints { | class V8EXPORT ResourceConstraints { | |||
skipping to change at line 2747 | skipping to change at line 2753 | |||
/** | /** | |||
* Disposes the isolate. The isolate must not be entered by any | * Disposes the isolate. The isolate must not be entered by any | |||
* thread to be disposable. | * thread to be disposable. | |||
*/ | */ | |||
void Dispose(); | void Dispose(); | |||
/** | /** | |||
* Associate embedder-specific data with the isolate | * Associate embedder-specific data with the isolate | |||
*/ | */ | |||
void SetData(void* data); | inline void SetData(void* data); | |||
/** | /** | |||
* Retrive embedder-specific data from the isolate. | * Retrieve embedder-specific data from the isolate. | |||
* Returns NULL if SetData has never been called. | * Returns NULL if SetData has never been called. | |||
*/ | */ | |||
void* GetData(); | inline void* GetData(); | |||
private: | private: | |||
Isolate(); | Isolate(); | |||
Isolate(const Isolate&); | Isolate(const Isolate&); | |||
~Isolate(); | ~Isolate(); | |||
Isolate& operator=(const Isolate&); | Isolate& operator=(const Isolate&); | |||
void* operator new(size_t size); | void* operator new(size_t size); | |||
void operator delete(void*, size_t); | void operator delete(void*, size_t); | |||
}; | }; | |||
skipping to change at line 3791 | skipping to change at line 3797 | |||
kSmiTagSize + kSmiShiftSize - kPointerAlignment; | kSmiTagSize + kSmiShiftSize - kPointerAlignment; | |||
}; | }; | |||
typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; | typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; | |||
const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; | const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; | |||
const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; | const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; | |||
const uintptr_t kEncodablePointerMask = | const uintptr_t kEncodablePointerMask = | |||
PlatformSmiTagging::kEncodablePointerMask; | PlatformSmiTagging::kEncodablePointerMask; | |||
const int kPointerToSmiShift = PlatformSmiTagging::kPointerToSmiShift; | const int kPointerToSmiShift = PlatformSmiTagging::kPointerToSmiShift; | |||
template <size_t ptr_size> struct InternalConstants; | ||||
// Internal constants for 32-bit systems. | ||||
template <> struct InternalConstants<4> { | ||||
static const int kStringResourceOffset = 3 * kApiPointerSize; | ||||
}; | ||||
// Internal constants for 64-bit systems. | ||||
template <> struct InternalConstants<8> { | ||||
static const int kStringResourceOffset = 3 * kApiPointerSize; | ||||
}; | ||||
/** | /** | |||
* This class exports constants and functionality from within v8 that | * This class exports constants and functionality from within v8 that | |||
* is necessary to implement inline functions in the v8 api. Don't | * is necessary to implement inline functions in the v8 api. Don't | |||
* depend on functions and constants defined here. | * depend on functions and constants defined here. | |||
*/ | */ | |||
class Internals { | class Internals { | |||
public: | public: | |||
// These values match non-compiler-dependent values defined within | // These values match non-compiler-dependent values defined within | |||
// the implementation of v8. | // the implementation of v8. | |||
static const int kHeapObjectMapOffset = 0; | static const int kHeapObjectMapOffset = 0; | |||
static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSi ze; | static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSi ze; | |||
static const int kStringResourceOffset = | static const int kStringResourceOffset = 3 * kApiPointerSize; | |||
InternalConstants<kApiPointerSize>::kStringResourceOffset; | ||||
static const int kOddballKindOffset = 3 * kApiPointerSize; | static const int kOddballKindOffset = 3 * kApiPointerSize; | |||
static const int kForeignAddressOffset = kApiPointerSize; | static const int kForeignAddressOffset = kApiPointerSize; | |||
static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | |||
static const int kFullStringRepresentationMask = 0x07; | static const int kFullStringRepresentationMask = 0x07; | |||
static const int kExternalTwoByteRepresentationTag = 0x02; | static const int kExternalTwoByteRepresentationTag = 0x02; | |||
static const int kIsolateStateOffset = 0; | ||||
static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; | ||||
static const int kIsolateRootsOffset = 3 * kApiPointerSize; | ||||
static const int kUndefinedValueRootIndex = 5; | ||||
static const int kNullValueRootIndex = 7; | ||||
static const int kTrueValueRootIndex = 8; | ||||
static const int kFalseValueRootIndex = 9; | ||||
static const int kEmptySymbolRootIndex = 128; | ||||
static const int kJSObjectType = 0xaa; | static const int kJSObjectType = 0xaa; | |||
static const int kFirstNonstringType = 0x80; | static const int kFirstNonstringType = 0x80; | |||
static const int kOddballType = 0x82; | static const int kOddballType = 0x82; | |||
static const int kForeignType = 0x85; | static const int kForeignType = 0x85; | |||
static const int kUndefinedOddballKind = 5; | static const int kUndefinedOddballKind = 5; | |||
static const int kNullOddballKind = 3; | static const int kNullOddballKind = 3; | |||
static inline bool HasHeapObjectTag(internal::Object* value) { | static inline bool HasHeapObjectTag(internal::Object* value) { | |||
return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == | return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == | |||
skipping to change at line 3875 | skipping to change at line 3877 | |||
} else { | } else { | |||
return NULL; | return NULL; | |||
} | } | |||
} | } | |||
static inline bool IsExternalTwoByteString(int instance_type) { | static inline bool IsExternalTwoByteString(int instance_type) { | |||
int representation = (instance_type & kFullStringRepresentationMask); | int representation = (instance_type & kFullStringRepresentationMask); | |||
return representation == kExternalTwoByteRepresentationTag; | return representation == kExternalTwoByteRepresentationTag; | |||
} | } | |||
static inline bool IsInitialized(v8::Isolate* isolate) { | ||||
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffs | ||||
et; | ||||
return *reinterpret_cast<int*>(addr) == 1; | ||||
} | ||||
static inline void SetEmbedderData(v8::Isolate* isolate, void* data) { | ||||
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | ||||
kIsolateEmbedderDataOffset; | ||||
*reinterpret_cast<void**>(addr) = data; | ||||
} | ||||
static inline void* GetEmbedderData(v8::Isolate* isolate) { | ||||
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | ||||
kIsolateEmbedderDataOffset; | ||||
return *reinterpret_cast<void**>(addr); | ||||
} | ||||
static inline internal::Object** GetRoot(v8::Isolate* isolate, int index) | ||||
{ | ||||
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffs | ||||
et; | ||||
return reinterpret_cast<internal::Object**>(addr + index * kApiPointerS | ||||
ize); | ||||
} | ||||
template <typename T> | template <typename T> | |||
static inline T ReadField(Object* ptr, int offset) { | static inline T ReadField(Object* ptr, int offset) { | |||
uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectT ag; | uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectT ag; | |||
return *reinterpret_cast<T*>(addr); | return *reinterpret_cast<T*>(addr); | |||
} | } | |||
static inline bool CanCastToHeapObject(void* o) { return false; } | static inline bool CanCastToHeapObject(void* o) { return false; } | |||
static inline bool CanCastToHeapObject(Context* o) { return true; } | static inline bool CanCastToHeapObject(Context* o) { return true; } | |||
static inline bool CanCastToHeapObject(String* o) { return true; } | static inline bool CanCastToHeapObject(String* o) { return true; } | |||
static inline bool CanCastToHeapObject(Object* o) { return true; } | static inline bool CanCastToHeapObject(Object* o) { return true; } | |||
skipping to change at line 4091 | skipping to change at line 4115 | |||
return SlowGetPointerFromInternalField(index); | return SlowGetPointerFromInternalField(index); | |||
} | } | |||
String* String::Cast(v8::Value* value) { | String* String::Cast(v8::Value* value) { | |||
#ifdef V8_ENABLE_CHECKS | #ifdef V8_ENABLE_CHECKS | |||
CheckCast(value); | CheckCast(value); | |||
#endif | #endif | |||
return static_cast<String*>(value); | return static_cast<String*>(value); | |||
} | } | |||
Local<String> String::Empty(Isolate* isolate) { | ||||
typedef internal::Object* S; | ||||
typedef internal::Internals I; | ||||
if (!I::IsInitialized(isolate)) return Empty(); | ||||
S* slot = I::GetRoot(isolate, I::kEmptySymbolRootIndex); | ||||
return Local<String>(reinterpret_cast<String*>(slot)); | ||||
} | ||||
String::ExternalStringResource* String::GetExternalStringResource() const { | String::ExternalStringResource* String::GetExternalStringResource() const { | |||
typedef internal::Object O; | typedef internal::Object O; | |||
typedef internal::Internals I; | typedef internal::Internals I; | |||
O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); | O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); | |||
String::ExternalStringResource* result; | String::ExternalStringResource* result; | |||
if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { | if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { | |||
void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); | void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); | |||
result = reinterpret_cast<String::ExternalStringResource*>(value); | result = reinterpret_cast<String::ExternalStringResource*>(value); | |||
} else { | } else { | |||
result = NULL; | result = NULL; | |||
skipping to change at line 4251 | skipping to change at line 4283 | |||
} | } | |||
Local<Object> AccessorInfo::This() const { | Local<Object> AccessorInfo::This() const { | |||
return Local<Object>(reinterpret_cast<Object*>(&args_[0])); | return Local<Object>(reinterpret_cast<Object*>(&args_[0])); | |||
} | } | |||
Local<Object> AccessorInfo::Holder() const { | Local<Object> AccessorInfo::Holder() const { | |||
return Local<Object>(reinterpret_cast<Object*>(&args_[-1])); | return Local<Object>(reinterpret_cast<Object*>(&args_[-1])); | |||
} | } | |||
Handle<Primitive> Undefined(Isolate* isolate) { | ||||
typedef internal::Object* S; | ||||
typedef internal::Internals I; | ||||
if (!I::IsInitialized(isolate)) return Undefined(); | ||||
S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); | ||||
return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); | ||||
} | ||||
Handle<Primitive> Null(Isolate* isolate) { | ||||
typedef internal::Object* S; | ||||
typedef internal::Internals I; | ||||
if (!I::IsInitialized(isolate)) return Null(); | ||||
S* slot = I::GetRoot(isolate, I::kNullValueRootIndex); | ||||
return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); | ||||
} | ||||
Handle<Boolean> True(Isolate* isolate) { | ||||
typedef internal::Object* S; | ||||
typedef internal::Internals I; | ||||
if (!I::IsInitialized(isolate)) return True(); | ||||
S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex); | ||||
return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); | ||||
} | ||||
Handle<Boolean> False(Isolate* isolate) { | ||||
typedef internal::Object* S; | ||||
typedef internal::Internals I; | ||||
if (!I::IsInitialized(isolate)) return False(); | ||||
S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); | ||||
return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); | ||||
} | ||||
void Isolate::SetData(void* data) { | ||||
typedef internal::Internals I; | ||||
I::SetEmbedderData(this, data); | ||||
} | ||||
void* Isolate::GetData() { | ||||
typedef internal::Internals I; | ||||
return I::GetEmbedderData(this); | ||||
} | ||||
/** | /** | |||
* \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. 11 change blocks. | ||||
17 lines changed or deleted | 95 lines changed or added | |||