Commit f4516c8b authored by lrn@chromium.org's avatar lrn@chromium.org

Remove dependency on V8_TARGET_ARCH in v8.h

Review URL: http://codereview.chromium.org/287004


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3080 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0f5210e9
...@@ -2727,21 +2727,37 @@ const int kHeapObjectTag = 1; ...@@ -2727,21 +2727,37 @@ 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;
#ifdef V8_TARGET_ARCH_X64
// 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;
const int kSmiShiftSize = 31;
const int kSmiValueSize = 32; template <size_t ptr_size> struct SmiConstants;
#else
// Tag information for Smi. // Smi constants for 32-bit systems.
const int kSmiTag = 0; template <> struct SmiConstants<4> {
const int kSmiTagSize = 1; static const int kSmiShiftSize = 0;
const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; static const int kSmiValueSize = 31;
const int kSmiShiftSize = 0; static inline int SmiToInt(internal::Object* value) {
const int kSmiValueSize = 31; int shift_bits = kSmiTagSize + kSmiShiftSize;
#endif // Throw away top 32 bits and shift down (requires >> to be sign extending).
return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
}
};
// Smi constants for 64-bit systems.
template <> struct SmiConstants<8> {
static const int kSmiShiftSize = 31;
static const int kSmiValueSize = 32;
static inline int SmiToInt(internal::Object* value) {
int shift_bits = kSmiTagSize + kSmiShiftSize;
// Shift down and throw away top 32 bits.
return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
}
};
const int kSmiShiftSize = SmiConstants<sizeof(void*)>::kSmiShiftSize;
const int kSmiValueSize = SmiConstants<sizeof(void*)>::kSmiValueSize;
/** /**
* This class exports constants and functionality from within v8 that * This class exports constants and functionality from within v8 that
...@@ -2777,15 +2793,7 @@ class Internals { ...@@ -2777,15 +2793,7 @@ class Internals {
} }
static inline int SmiValue(internal::Object* value) { static inline int SmiValue(internal::Object* value) {
#ifdef V8_TARGET_ARCH_X64 return SmiConstants<sizeof(void*)>::SmiToInt(value);
int shift_bits = kSmiTagSize + kSmiShiftSize;
// Shift down and throw away top 32 bits.
return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
#else
int shift_bits = kSmiTagSize + kSmiShiftSize;
// Throw away top 32 bits and shift down (requires >> to be sign extending).
return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
#endif
} }
static inline int GetInstanceType(internal::Object* obj) { static inline int GetInstanceType(internal::Object* obj) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment