v8.h | v8.h | |||
---|---|---|---|---|
skipping to change at line 3208 | skipping to change at line 3208 | |||
* can be stopped by returning kAbort as function result. EndOfStream | * can be stopped by returning kAbort as function result. EndOfStream | |||
* will not be called in case writing was aborted. | * will not be called in case writing was aborted. | |||
*/ | */ | |||
virtual WriteResult WriteAsciiChunk(char* data, int size) = 0; | virtual WriteResult WriteAsciiChunk(char* data, int size) = 0; | |||
}; | }; | |||
// --- I m p l e m e n t a t i o n --- | // --- I m p l e m e n t a t i o n --- | |||
namespace internal { | namespace internal { | |||
const int kPointerSize = sizeof(void*); // NOLINT | static const int kApiPointerSize = sizeof(void*); // NOLINT | |||
const int kIntSize = sizeof(int); // NOLINT | static const int kApiIntSize = sizeof(int); // NOLINT | |||
// Tag information for HeapObject. | // Tag information for HeapObject. | |||
const int kHeapObjectTag = 1; | const int kHeapObjectTag = 1; | |||
const int kHeapObjectTagSize = 2; | const int kHeapObjectTagSize = 2; | |||
const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1; | const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1; | |||
// Tag information for Smi. | // Tag information for Smi. | |||
const int kSmiTag = 0; | const int kSmiTag = 0; | |||
const int kSmiTagSize = 1; | const int kSmiTagSize = 1; | |||
const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; | const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; | |||
skipping to change at line 3245 | skipping to change at line 3245 | |||
template <> struct SmiConstants<8> { | template <> struct SmiConstants<8> { | |||
static const int kSmiShiftSize = 31; | static const int kSmiShiftSize = 31; | |||
static const int kSmiValueSize = 32; | static const int kSmiValueSize = 32; | |||
static inline int SmiToInt(internal::Object* value) { | static inline int SmiToInt(internal::Object* value) { | |||
int shift_bits = kSmiTagSize + kSmiShiftSize; | int shift_bits = kSmiTagSize + kSmiShiftSize; | |||
// Shift down and throw away top 32 bits. | // Shift down and throw away top 32 bits. | |||
return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits ); | return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits ); | |||
} | } | |||
}; | }; | |||
const int kSmiShiftSize = SmiConstants<kPointerSize>::kSmiShiftSize; | const int kSmiShiftSize = SmiConstants<kApiPointerSize>::kSmiShiftSize; | |||
const int kSmiValueSize = SmiConstants<kPointerSize>::kSmiValueSize; | const int kSmiValueSize = SmiConstants<kApiPointerSize>::kSmiValueSize; | |||
template <size_t ptr_size> struct InternalConstants; | template <size_t ptr_size> struct InternalConstants; | |||
// Internal constants for 32-bit systems. | // Internal constants for 32-bit systems. | |||
template <> struct InternalConstants<4> { | template <> struct InternalConstants<4> { | |||
static const int kStringResourceOffset = 3 * kPointerSize; | static const int kStringResourceOffset = 3 * kApiPointerSize; | |||
}; | }; | |||
// Internal constants for 64-bit systems. | // Internal constants for 64-bit systems. | |||
template <> struct InternalConstants<8> { | template <> struct InternalConstants<8> { | |||
static const int kStringResourceOffset = 3 * kPointerSize; | 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 = kPointerSize + kIntSize; | static const int kMapInstanceTypeOffset = kApiPointerSize + kApiIntSize; | |||
static const int kStringResourceOffset = | static const int kStringResourceOffset = | |||
InternalConstants<kPointerSize>::kStringResourceOffset; | InternalConstants<kApiPointerSize>::kStringResourceOffset; | |||
static const int kProxyProxyOffset = kPointerSize; | static const int kProxyProxyOffset = kApiPointerSize; | |||
static const int kJSObjectHeaderSize = 3 * kPointerSize; | 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 kJSObjectType = 0x9f; | static const int kJSObjectType = 0x9f; | |||
static const int kFirstNonstringType = 0x80; | static const int kFirstNonstringType = 0x80; | |||
static const int kProxyType = 0x85; | static const int kProxyType = 0x85; | |||
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) == | |||
kHeapObjectTag); | kHeapObjectTag); | |||
} | } | |||
static inline bool HasSmiTag(internal::Object* value) { | static inline bool HasSmiTag(internal::Object* value) { | |||
return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag); | return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag); | |||
} | } | |||
static inline int SmiValue(internal::Object* value) { | static inline int SmiValue(internal::Object* value) { | |||
return SmiConstants<kPointerSize>::SmiToInt(value); | return SmiConstants<kApiPointerSize>::SmiToInt(value); | |||
} | } | |||
static inline int GetInstanceType(internal::Object* obj) { | static inline int GetInstanceType(internal::Object* obj) { | |||
typedef internal::Object O; | typedef internal::Object O; | |||
O* map = ReadField<O*>(obj, kHeapObjectMapOffset); | O* map = ReadField<O*>(obj, kHeapObjectMapOffset); | |||
return ReadField<uint8_t>(map, kMapInstanceTypeOffset); | return ReadField<uint8_t>(map, kMapInstanceTypeOffset); | |||
} | } | |||
static inline void* GetExternalPointer(internal::Object* obj) { | static inline void* GetExternalPointer(internal::Object* obj) { | |||
if (HasSmiTag(obj)) { | if (HasSmiTag(obj)) { | |||
skipping to change at line 3462 | skipping to change at line 3462 | |||
} | } | |||
Local<Value> Object::UncheckedGetInternalField(int index) { | Local<Value> Object::UncheckedGetInternalField(int index) { | |||
typedef internal::Object O; | typedef internal::Object O; | |||
typedef internal::Internals I; | typedef internal::Internals I; | |||
O* obj = *reinterpret_cast<O**>(this); | O* obj = *reinterpret_cast<O**>(this); | |||
if (I::GetInstanceType(obj) == I::kJSObjectType) { | if (I::GetInstanceType(obj) == I::kJSObjectType) { | |||
// If the object is a plain JSObject, which is the common case, | // If the object is a plain JSObject, which is the common case, | |||
// we know where to find the internal fields and can return the | // we know where to find the internal fields and can return the | |||
// value directly. | // value directly. | |||
int offset = I::kJSObjectHeaderSize + (internal::kPointerSize * index); | int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde x); | |||
O* value = I::ReadField<O*>(obj, offset); | O* value = I::ReadField<O*>(obj, offset); | |||
O** result = HandleScope::CreateHandle(value); | O** result = HandleScope::CreateHandle(value); | |||
return Local<Value>(reinterpret_cast<Value*>(result)); | return Local<Value>(reinterpret_cast<Value*>(result)); | |||
} else { | } else { | |||
return Local<Value>(); | return Local<Value>(); | |||
} | } | |||
} | } | |||
void* External::Unwrap(Handle<v8::Value> obj) { | void* External::Unwrap(Handle<v8::Value> obj) { | |||
#ifdef V8_ENABLE_CHECKS | #ifdef V8_ENABLE_CHECKS | |||
skipping to change at line 3495 | skipping to change at line 3495 | |||
void* Object::GetPointerFromInternalField(int index) { | void* Object::GetPointerFromInternalField(int index) { | |||
typedef internal::Object O; | typedef internal::Object O; | |||
typedef internal::Internals I; | typedef internal::Internals I; | |||
O* obj = *reinterpret_cast<O**>(this); | O* obj = *reinterpret_cast<O**>(this); | |||
if (I::GetInstanceType(obj) == I::kJSObjectType) { | if (I::GetInstanceType(obj) == I::kJSObjectType) { | |||
// If the object is a plain JSObject, which is the common case, | // If the object is a plain JSObject, which is the common case, | |||
// we know where to find the internal fields and can return the | // we know where to find the internal fields and can return the | |||
// value directly. | // value directly. | |||
int offset = I::kJSObjectHeaderSize + (internal::kPointerSize * index); | int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde x); | |||
O* value = I::ReadField<O*>(obj, offset); | O* value = I::ReadField<O*>(obj, offset); | |||
return I::GetExternalPointer(value); | return I::GetExternalPointer(value); | |||
} | } | |||
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); | |||
End of changes. 10 change blocks. | ||||
13 lines changed or deleted | 13 lines changed or added | |||