Revision: 23550
Author: [email protected]
Date: Mon Sep 1 10:24:04 2014 UTC
Log: 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.
[email protected], [email protected]
Review URL: https://codereview.chromium.org/527603002
https://code.google.com/p/v8/source/detail?r=23550
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/compiler/change-lowering.cc
/branches/bleeding_edge/test/compiler-unittests/change-lowering-unittest.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Mon Aug 25 15:17:06 2014 UTC
+++ /branches/bleeding_edge/include/v8.h Mon Sep 1 10:24:04 2014 UTC
@@ -5606,8 +5606,9 @@
// 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 @@
// 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.
=======================================
--- /branches/bleeding_edge/src/compiler/change-lowering.cc Fri Aug 29
06:42:41 2014 UTC
+++ /branches/bleeding_edge/src/compiler/change-lowering.cc Mon Sep 1
10:24:04 2014 UTC
@@ -50,28 +50,16 @@
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<int>(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);
}
=======================================
---
/branches/bleeding_edge/test/compiler-unittests/change-lowering-unittest.cc
Wed Aug 27 14:47:50 2014 UTC
+++
/branches/bleeding_edge/test/compiler-unittests/change-lowering-unittest.cc
Mon Sep 1 10:24:04 2014 UTC
@@ -59,24 +59,12 @@
}
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) {
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.