Index: src/v8.cc |
diff --git a/src/v8.cc b/src/v8.cc |
index 3f8e6cdeae055286b7014fbf13d36a1a8a1ee7b4..3c70ee96b0b57146ad44776c164b990911fc8a8b 100644 |
--- a/src/v8.cc |
+++ b/src/v8.cc |
@@ -178,11 +178,14 @@ bool V8::IdleNotification() { |
return Heap::IdleNotification(); |
} |
+static const uint32_t kRandomPositiveSmiMax = 0x3fffffff; |
Smi* V8::RandomPositiveSmi() { |
uint32_t random = Random(); |
- ASSERT(IsPowerOf2(Smi::kMaxValue + 1)); |
- return Smi::FromInt(random & Smi::kMaxValue); |
+ ASSERT(static_cast<uint32_t>(Smi::kMaxValue) >= kRandomPositiveSmiMax); |
+ // kRandomPositiveSmiMax must match the value being divided |
+ // by in math.js. |
+ return Smi::FromInt(random & kRandomPositiveSmiMax); |
} |
} } // namespace v8::internal |