diff options
| author | Ben Murdoch <benm@google.com> | 2011-05-16 14:20:40 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2011-05-18 16:35:26 +0100 |
| commit | b8e0da25ee8efac3bb05cd6b2730aafbd96119f4 (patch) | |
| tree | c5ef7652343a7e4b55601fa0a4c94cf46ba09585 /include | |
| parent | 086aeeaae12517475c22695a200be45495516549 (diff) | |
| download | android_external_v8-b8e0da25ee8efac3bb05cd6b2730aafbd96119f4.tar.gz android_external_v8-b8e0da25ee8efac3bb05cd6b2730aafbd96119f4.tar.bz2 android_external_v8-b8e0da25ee8efac3bb05cd6b2730aafbd96119f4.zip | |
Update V8 to r6387 as required by WebKit r76408
Change-Id: Icfc5385b0996bd592f8b1ac8cbb44767ee09f1f6
Diffstat (limited to 'include')
| -rw-r--r-- | include/v8.h | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/include/v8.h b/include/v8.h index 883bfad9..7d18107d 100644 --- a/include/v8.h +++ b/include/v8.h @@ -2515,6 +2515,7 @@ class V8EXPORT HeapStatistics { size_t total_heap_size() { return total_heap_size_; } size_t total_heap_size_executable() { return total_heap_size_executable_; } size_t used_heap_size() { return used_heap_size_; } + size_t heap_size_limit() { return heap_size_limit_; } private: void set_total_heap_size(size_t size) { total_heap_size_ = size; } @@ -2522,10 +2523,12 @@ class V8EXPORT HeapStatistics { total_heap_size_executable_ = size; } void set_used_heap_size(size_t size) { used_heap_size_ = size; } + void set_heap_size_limit(size_t size) { heap_size_limit_ = size; } size_t total_heap_size_; size_t total_heap_size_executable_; size_t used_heap_size_; + size_t heap_size_limit_; friend class V8; }; @@ -3350,10 +3353,10 @@ const int kSmiTag = 0; const int kSmiTagSize = 1; const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; -template <size_t ptr_size> struct SmiConstants; +template <size_t ptr_size> struct SmiTagging; // Smi constants for 32-bit systems. -template <> struct SmiConstants<4> { +template <> struct SmiTagging<4> { static const int kSmiShiftSize = 0; static const int kSmiValueSize = 31; static inline int SmiToInt(internal::Object* value) { @@ -3361,10 +3364,15 @@ template <> struct SmiConstants<4> { // Throw away top 32 bits and shift down (requires >> to be sign extending). return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits; } + + // For 32-bit systems any 2 bytes aligned pointer can be encoded as smi + // with a plain reinterpret_cast. + static const intptr_t kEncodablePointerMask = 0x1; + static const int kPointerToSmiShift = 0; }; // Smi constants for 64-bit systems. -template <> struct SmiConstants<8> { +template <> struct SmiTagging<8> { static const int kSmiShiftSize = 31; static const int kSmiValueSize = 32; static inline int SmiToInt(internal::Object* value) { @@ -3372,10 +3380,26 @@ template <> struct SmiConstants<8> { // Shift down and throw away top 32 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 platforms. + static const int kPointerAlignment = 3; + + static const intptr_t kEncodablePointerMask = + ~(intptr_t(0xffffffff) << kPointerAlignment); + + static const int kPointerToSmiShift = + kSmiTagSize + kSmiShiftSize - kPointerAlignment; }; -const int kSmiShiftSize = SmiConstants<kApiPointerSize>::kSmiShiftSize; -const int kSmiValueSize = SmiConstants<kApiPointerSize>::kSmiValueSize; +typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; +const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; +const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; +const intptr_t kEncodablePointerMask = + PlatformSmiTagging::kEncodablePointerMask; +const int kPointerToSmiShift = PlatformSmiTagging::kPointerToSmiShift; template <size_t ptr_size> struct InternalConstants; @@ -3423,7 +3447,7 @@ class Internals { } static inline int SmiValue(internal::Object* value) { - return SmiConstants<kApiPointerSize>::SmiToInt(value); + return PlatformSmiTagging::SmiToInt(value); } static inline int GetInstanceType(internal::Object* obj) { @@ -3432,9 +3456,14 @@ class Internals { return ReadField<uint8_t>(map, kMapInstanceTypeOffset); } + static inline void* GetExternalPointerFromSmi(internal::Object* value) { + const intptr_t address = reinterpret_cast<intptr_t>(value); + return reinterpret_cast<void*>(address >> kPointerToSmiShift); + } + static inline void* GetExternalPointer(internal::Object* obj) { if (HasSmiTag(obj)) { - return obj; + return GetExternalPointerFromSmi(obj); } else if (GetInstanceType(obj) == kProxyType) { return ReadField<void*>(obj, kProxyProxyOffset); } else { |
