v8-profiler.h | v8-profiler.h | |||
---|---|---|---|---|
skipping to change at line 240 | skipping to change at line 240 | |||
* HeapGraphNode represents a node in a heap graph. | * HeapGraphNode represents a node in a heap graph. | |||
*/ | */ | |||
class V8EXPORT HeapGraphNode { | class V8EXPORT HeapGraphNode { | |||
public: | public: | |||
enum Type { | enum Type { | |||
kInternal = 0, // Internal node, a virtual one, for housekeeping. | kInternal = 0, // Internal node, a virtual one, for housekeeping. | |||
kArray = 1, // An array of elements. | kArray = 1, // An array of elements. | |||
kString = 2, // A string. | kString = 2, // A string. | |||
kObject = 3, // A JS object (except for arrays and strings). | kObject = 3, // A JS object (except for arrays and strings). | |||
kCode = 4, // Compiled code. | kCode = 4, // Compiled code. | |||
kClosure = 5 // Function closure. | kClosure = 5, // Function closure. | |||
kRegExp = 6, // RegExp. | ||||
kHeapNumber = 7 // Number stored in the heap. | ||||
}; | }; | |||
/** Returns node type (see HeapGraphNode::Type). */ | /** Returns node type (see HeapGraphNode::Type). */ | |||
Type GetType() const; | Type GetType() const; | |||
/** | /** | |||
* Returns node name. Depending on node's type this can be the name | * Returns node name. Depending on node's type this can be the name | |||
* of the constructor (for objects), the name of the function (for | * of the constructor (for objects), the name of the function (for | |||
* closures), string value, or an empty string (for compiled code). | * closures), string value, or an empty string (for compiled code). | |||
*/ | */ | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 3 lines changed or added | |||
v8.h | v8.h | |||
---|---|---|---|---|
skipping to change at line 3222 | skipping to change at line 3222 | |||
// 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; | |||
template <size_t ptr_size> struct SmiTagging; | template <size_t ptr_size> struct SmiConstants; | |||
// Smi constants for 32-bit systems. | // Smi constants for 32-bit systems. | |||
template <> struct SmiTagging<4> { | template <> struct SmiConstants<4> { | |||
static const int kSmiShiftSize = 0; | static const int kSmiShiftSize = 0; | |||
static const int kSmiValueSize = 31; | static const int kSmiValueSize = 31; | |||
static inline int SmiToInt(internal::Object* value) { | static inline int SmiToInt(internal::Object* value) { | |||
int shift_bits = kSmiTagSize + kSmiShiftSize; | int shift_bits = kSmiTagSize + kSmiShiftSize; | |||
// Throw away top 32 bits and shift down (requires >> to be sign extend ing). | // Throw away top 32 bits and shift down (requires >> to be sign extend ing). | |||
return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bit s; | return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bit s; | |||
} | } | |||
// For 32-bit systems any 2 bytes aligned pointer can be encoded as smi | ||||
// with a plain reinterpret_cast. | ||||
static const uintptr_t kEncodablePointerMask = 0x1; | ||||
static const int kPointerToSmiShift = 0; | ||||
}; | }; | |||
// Smi constants for 64-bit systems. | // Smi constants for 64-bit systems. | |||
template <> struct SmiTagging<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 ); | |||
} | } | |||
// To maximize the range of pointers that can be encoded | ||||
// in the available 32 bits, we require them to be 8 bytes aligned. | ||||
// This gives 2 ^ (32 + 3) = 32G address space covered. | ||||
// It might be not enough to cover stack allocated objects on some platfo | ||||
rms. | ||||
static const int kPointerAlignment = 3; | ||||
static const uintptr_t kEncodablePointerMask = | ||||
~(uintptr_t(0xffffffff) << kPointerAlignment); | ||||
static const int kPointerToSmiShift = | ||||
kSmiTagSize + kSmiShiftSize - kPointerAlignment; | ||||
}; | }; | |||
typedef SmiTagging<sizeof(void*)> PlatformSmiTagging; | const int kSmiShiftSize = SmiConstants<sizeof(void*)>::kSmiShiftSize; | |||
const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; | const int kSmiValueSize = SmiConstants<sizeof(void*)>::kSmiValueSize; | |||
const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; | ||||
const uintptr_t kEncodablePointerMask = | ||||
PlatformSmiTagging::kEncodablePointerMask; | ||||
const int kPointerToSmiShift = PlatformSmiTagging::kPointerToSmiShift; | ||||
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 * sizeof(void*); | static const int kStringResourceOffset = 3 * sizeof(void*); | |||
}; | }; | |||
// Internal constants for 64-bit systems. | // Internal constants for 64-bit systems. | |||
template <> struct InternalConstants<8> { | template <> struct InternalConstants<8> { | |||
skipping to change at line 3316 | skipping to change at line 3295 | |||
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 PlatformSmiTagging::SmiToInt(value); | return SmiConstants<sizeof(void*)>::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* GetExternalPointerFromSmi(internal::Object* value) { | ||||
const uintptr_t address = reinterpret_cast<uintptr_t>(value); | ||||
return reinterpret_cast<void*>(address >> kPointerToSmiShift); | ||||
} | ||||
static inline void* GetExternalPointer(internal::Object* obj) { | static inline void* GetExternalPointer(internal::Object* obj) { | |||
if (HasSmiTag(obj)) { | if (HasSmiTag(obj)) { | |||
return GetExternalPointerFromSmi(obj); | return obj; | |||
} else if (GetInstanceType(obj) == kProxyType) { | } else if (GetInstanceType(obj) == kProxyType) { | |||
return ReadField<void*>(obj, kProxyProxyOffset); | return ReadField<void*>(obj, kProxyProxyOffset); | |||
} 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; | |||
End of changes. 9 change blocks. | ||||
34 lines changed or deleted | 7 lines changed or added | |||