Reviewers: danno,

Message:
Addressed danno's comment on https://codereview.chromium.org/21014003/. This
part could be separated from that big CL.

Description:
Introduce SmiValuesAre31Bits and SmiValuesAre32Bits global predicate functions

Please review this at https://codereview.chromium.org/22350005/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M include/v8.h
  M src/hydrogen-instructions.h
  M src/hydrogen-instructions.cc
  M src/ic.cc
  M src/x64/macro-assembler-x64.cc
  M test/cctest/test-api.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 24ee60f1bb4dcec1934b5d1a486f41bc734dd2f0..ee5aff685f91d68ccf1c1a3734fb85bee0bb9eac 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -5450,6 +5450,9 @@ template <> struct SmiTagging<8> {
 };

 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging;
+V8_INLINE(static bool SmiValuesAre31Bits()) { return kApiPointerSize == 4; } +V8_INLINE(static bool SmiValuesAre32Bits()) { return kApiPointerSize == 8; }
+
 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;

Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 997b7c2fda9b29455d03faac59c5a49a60d18d5c..26539cc2cfa624dbdaa597794a594a50a616d5f5 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -2421,7 +2421,7 @@ static void PrepareConstant(Handle<Object> object) {

 void HConstant::Initialize(Representation r) {
   if (r.IsNone()) {
-    if (has_smi_value_ && kSmiValueSize == 31) {
+    if (has_smi_value_ && SmiValuesAre31Bits()) {
       r = Representation::Smi();
     } else if (has_int32_value_) {
       r = Representation::Integer32();
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index f977a750d946a6b24d657b08229fc4a238c368b2..f7166a900d72e0456fae40db9204e5bb1fe91cf9 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -3267,7 +3267,7 @@ class HConstant: public HTemplateInstruction<0> {
   }

   virtual Representation KnownOptimalRepresentation() {
-    if (HasSmiValue() && kSmiValueSize == 31) return Representation::Smi();
+ if (HasSmiValue() && SmiValuesAre31Bits()) return Representation::Smi();
     if (HasInteger32Value()) return Representation::Integer32();
     if (HasNumberValue()) return Representation::Double();
     if (HasExternalReferenceValue()) return Representation::External();
@@ -5696,7 +5696,7 @@ class ArrayInstructionInterface {
   virtual ~ArrayInstructionInterface() { };

   static Representation KeyedAccessIndexRequirement(Representation r) {
-    return r.IsInteger32() || kSmiValueSize != 31
+    return r.IsInteger32() || SmiValuesAre32Bits()
         ? Representation::Integer32() : Representation::Smi();
   }
 };
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index 3c22580c2c7e2b36d851444304435e6f433d4a17..bff5221563d18770268bd96db9b9197fce1992bb 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -2593,7 +2593,7 @@ static BinaryOpIC::TypeInfo TypeInfoFromValue(Handle<Object> value,
   v8::internal::TypeInfo type = v8::internal::TypeInfo::FromValue(value);
   if (type.IsSmi()) return BinaryOpIC::SMI;
   if (type.IsInteger32()) {
-    if (kSmiValueSize == 32) return BinaryOpIC::SMI;
+    if (SmiValuesAre32Bits()) return BinaryOpIC::SMI;
     return BinaryOpIC::INT32;
   }
   if (type.IsNumber()) return BinaryOpIC::NUMBER;
@@ -2605,7 +2605,7 @@ static BinaryOpIC::TypeInfo TypeInfoFromValue(Handle<Object> value,
         op == Token::SAR ||
         op == Token::SHL ||
         op == Token::SHR) {
-      if (kSmiValueSize == 32) return BinaryOpIC::SMI;
+      if (SmiValuesAre32Bits()) return BinaryOpIC::SMI;
       return BinaryOpIC::INT32;
     }
     return BinaryOpIC::ODDBALL;
@@ -2683,7 +2683,7 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) {
       if (op == Token::DIV ||
           op == Token::MUL ||
           op == Token::SHR ||
-          kSmiValueSize == 32) {
+          SmiValuesAre32Bits()) {
         // Arithmetic on two Smi inputs has yielded a heap number.
         // That is the only way to get here from the Smi stub.
         // With 32-bit Smis, all overflows give heap numbers, but with
Index: src/x64/macro-assembler-x64.cc
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index 9c9b1620e586ce5872bbc46de2eaf515266716a0..76e0d6b37bd88ef9788e8f1e2e34b4f29c082ae8 100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -992,7 +992,7 @@ bool MacroAssembler::IsUnsafeInt(const int x) {

 void MacroAssembler::SafeMove(Register dst, Smi* src) {
   ASSERT(!dst.is(kScratchRegister));
-  ASSERT(kSmiValueSize == 32);  // JIT cookie can be converted to Smi.
+  ASSERT(SmiValuesAre32Bits());  // JIT cookie can be converted to Smi.
   if (IsUnsafeInt(src->value()) && jit_cookie() != 0) {
     Move(dst, Smi::FromInt(src->value() ^ jit_cookie()));
     Move(kScratchRegister, Smi::FromInt(jit_cookie()));
@@ -1004,7 +1004,7 @@ void MacroAssembler::SafeMove(Register dst, Smi* src) {


 void MacroAssembler::SafePush(Smi* src) {
-  ASSERT(kSmiValueSize == 32);  // JIT cookie can be converted to Smi.
+  ASSERT(SmiValuesAre32Bits());  // JIT cookie can be converted to Smi.
   if (IsUnsafeInt(src->value()) && jit_cookie() != 0) {
     Push(Smi::FromInt(src->value() ^ jit_cookie()));
     Move(kScratchRegister, Smi::FromInt(jit_cookie()));
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 3be500814533e45ee0b6273f45577438fa35019f..9714b1da34f2df94a357b3b1d865e5848f4bd15b 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -1360,7 +1360,7 @@ THREADED_TEST(BigSmiInteger) {

   int32_t value = i::Smi::kMaxValue;
   // We cannot add one to a Smi::kMaxValue without wrapping.
-  if (i::kSmiValueSize < 32) {
+  if (i::SmiValuesAre31Bits()) {
     CHECK(i::Smi::IsValid(value));
     CHECK(!i::Smi::IsValid(value + 1));

@@ -1379,7 +1379,7 @@ THREADED_TEST(BigInteger) {
   v8::Isolate* isolate = v8::Isolate::GetCurrent();

   // We cannot add one to a Smi::kMaxValue without wrapping.
-  if (i::kSmiValueSize < 32) {
+  if (i::SmiValuesAre31Bits()) {
     // The casts allow this to compile, even if Smi::kMaxValue is 2^31-1.
     // The code will not be run in that case, due to the "if" guard.
     int32_t value =


--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to