From: bmeurer@chromium.org Date: Mon, 1 Sep 2014 10:24:04 +0000 (+0000) Subject: Use the "enum hack" to fix the SmiTagging constants. X-Git-Tag: upstream/4.7.83~7254 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=40da0e5ee62b07196f7dad19066be28202bfb12c;p=platform%2Fupstream%2Fv8.git Use the "enum hack" to fix the SmiTagging constants. The "enum hack" (see Item 2 of "Effective C++") is the only known portable way to define constant integral values within template classes. Fixes the weird work-arounds required for certain GCC versions. R=jarin@chromium.org, rossberg@chromium.org Review URL: https://codereview.chromium.org/527603002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23550 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/include/v8.h b/include/v8.h index cbe8edd..e3cd10f 100644 --- a/include/v8.h +++ b/include/v8.h @@ -5606,8 +5606,9 @@ V8_INLINE internal::Object* IntToSmi(int value) { // Smi constants for 32-bit systems. template <> struct SmiTagging<4> { - static const int kSmiShiftSize = 0; - static const int kSmiValueSize = 31; + enum { kSmiShiftSize = 0, kSmiValueSize = 31 }; + static int SmiShiftSize() { return kSmiShiftSize; } + static int SmiValueSize() { return kSmiValueSize; } V8_INLINE static int SmiToInt(const internal::Object* value) { int shift_bits = kSmiTagSize + kSmiShiftSize; // Throw away top 32 bits and shift down (requires >> to be sign extending). @@ -5634,8 +5635,9 @@ template <> struct SmiTagging<4> { // Smi constants for 64-bit systems. template <> struct SmiTagging<8> { - static const int kSmiShiftSize = 31; - static const int kSmiValueSize = 32; + enum { kSmiShiftSize = 31, kSmiValueSize = 32 }; + static int SmiShiftSize() { return kSmiShiftSize; } + static int SmiValueSize() { return kSmiValueSize; } V8_INLINE static int SmiToInt(const internal::Object* value) { int shift_bits = kSmiTagSize + kSmiShiftSize; // Shift down and throw away top 32 bits. diff --git a/src/compiler/change-lowering.cc b/src/compiler/change-lowering.cc index c2805bb..e9fd740 100644 --- a/src/compiler/change-lowering.cc +++ b/src/compiler/change-lowering.cc @@ -50,28 +50,16 @@ Node* ChangeLowering::HeapNumberValueIndexConstant() { Node* ChangeLowering::SmiMaxValueConstant() { - // TODO(turbofan): Work-around for weird GCC 4.6 linker issue: - // src/compiler/change-lowering.cc:46: undefined reference to - // `v8::internal::SmiTagging<4u>::kSmiValueSize' - // src/compiler/change-lowering.cc:46: undefined reference to - // `v8::internal::SmiTagging<8u>::kSmiValueSize' - STATIC_ASSERT(SmiTagging<4>::kSmiValueSize == 31); - STATIC_ASSERT(SmiTagging<8>::kSmiValueSize == 32); - const int smi_value_size = machine()->is64() ? 32 : 31; + const int smi_value_size = machine()->is32() ? SmiTagging<4>::SmiValueSize() + : SmiTagging<8>::SmiValueSize(); return jsgraph()->Int32Constant( -(static_cast(0xffffffffu << (smi_value_size - 1)) + 1)); } Node* ChangeLowering::SmiShiftBitsConstant() { - // TODO(turbofan): Work-around for weird GCC 4.6 linker issue: - // src/compiler/change-lowering.cc:46: undefined reference to - // `v8::internal::SmiTagging<4u>::kSmiShiftSize' - // src/compiler/change-lowering.cc:46: undefined reference to - // `v8::internal::SmiTagging<8u>::kSmiShiftSize' - STATIC_ASSERT(SmiTagging<4>::kSmiShiftSize == 0); - STATIC_ASSERT(SmiTagging<8>::kSmiShiftSize == 31); - const int smi_shift_size = machine()->is64() ? 31 : 0; + const int smi_shift_size = machine()->is32() ? SmiTagging<4>::SmiShiftSize() + : SmiTagging<8>::SmiShiftSize(); return jsgraph()->Int32Constant(smi_shift_size + kSmiTagSize); } diff --git a/test/compiler-unittests/change-lowering-unittest.cc b/test/compiler-unittests/change-lowering-unittest.cc index 4ea125a..2e705d2 100644 --- a/test/compiler-unittests/change-lowering-unittest.cc +++ b/test/compiler-unittests/change-lowering-unittest.cc @@ -59,24 +59,12 @@ class ChangeLoweringTest : public GraphTest { } int SmiShiftAmount() const { return kSmiTagSize + SmiShiftSize(); } int SmiShiftSize() const { - // TODO(turbofan): Work-around for weird GCC 4.6 linker issue: - // src/compiler/change-lowering.cc:46: undefined reference to - // `v8::internal::SmiTagging<4u>::kSmiShiftSize' - // src/compiler/change-lowering.cc:46: undefined reference to - // `v8::internal::SmiTagging<8u>::kSmiShiftSize' - STATIC_ASSERT(SmiTagging<4>::kSmiShiftSize == 0); - STATIC_ASSERT(SmiTagging<8>::kSmiShiftSize == 31); - return Is32() ? 0 : 31; + return Is32() ? SmiTagging<4>::SmiShiftSize() + : SmiTagging<8>::SmiShiftSize(); } int SmiValueSize() const { - // TODO(turbofan): Work-around for weird GCC 4.6 linker issue: - // src/compiler/change-lowering.cc:46: undefined reference to - // `v8::internal::SmiTagging<4u>::kSmiValueSize' - // src/compiler/change-lowering.cc:46: undefined reference to - // `v8::internal::SmiTagging<8u>::kSmiValueSize' - STATIC_ASSERT(SmiTagging<4>::kSmiValueSize == 31); - STATIC_ASSERT(SmiTagging<8>::kSmiValueSize == 32); - return Is32() ? 31 : 32; + return Is32() ? SmiTagging<4>::SmiValueSize() + : SmiTagging<8>::SmiValueSize(); } Node* Parameter(int32_t index = 0) {