summaryrefslogtreecommitdiff
path: root/deps/v8/src/v8.cc
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-04-14 10:34:17 -0700
committerRyan Dahl <ry@tinyclouds.org>2010-04-14 10:34:27 -0700
commit41ef1717e096a9e1761efa0df97c395f59c51f16 (patch)
tree7e854284ef8ce5189a63074857a408b6eea5a9cb /deps/v8/src/v8.cc
parent760bba55186eba039ca00e532f7813d2aea450a2 (diff)
downloadnode-new-41ef1717e096a9e1761efa0df97c395f59c51f16.tar.gz
Upgrade V8 to 2.2.3.1
Diffstat (limited to 'deps/v8/src/v8.cc')
-rw-r--r--deps/v8/src/v8.cc34
1 files changed, 27 insertions, 7 deletions
diff --git a/deps/v8/src/v8.cc b/deps/v8/src/v8.cc
index 5af200348b..7219d630ce 100644
--- a/deps/v8/src/v8.cc
+++ b/deps/v8/src/v8.cc
@@ -60,6 +60,8 @@ bool V8::Initialize(Deserializer* des) {
// Enable logging before setting up the heap
Logger::Setup();
+ CpuProfiler::Setup();
+
// Setup the platform OS support.
OS::Setup();
@@ -148,6 +150,9 @@ void V8::TearDown() {
Top::TearDown();
Heap::TearDown();
+
+ CpuProfiler::TearDown();
+
Logger::TearDown();
is_running_ = false;
@@ -191,14 +196,29 @@ bool V8::IdleNotification() {
return Heap::IdleNotification();
}
-static const uint32_t kRandomPositiveSmiMax = 0x3fffffff;
-Smi* V8::RandomPositiveSmi() {
- uint32_t random = Random();
- ASSERT(static_cast<uint32_t>(Smi::kMaxValue) >= kRandomPositiveSmiMax);
- // kRandomPositiveSmiMax must match the value being divided
- // by in math.js.
- return Smi::FromInt(random & kRandomPositiveSmiMax);
+// Use a union type to avoid type-aliasing optimizations in GCC.
+typedef union {
+ double double_value;
+ uint64_t uint64_t_value;
+} double_int_union;
+
+
+Object* V8::FillHeapNumberWithRandom(Object* heap_number) {
+ uint64_t random_bits = Random();
+ // Make a double* from address (heap_number + sizeof(double)).
+ double_int_union* r = reinterpret_cast<double_int_union*>(
+ reinterpret_cast<char*>(heap_number) +
+ HeapNumber::kValueOffset - kHeapObjectTag);
+ // Convert 32 random bits to 0.(32 random bits) in a double
+ // by computing:
+ // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
+ const double binary_million = 1048576.0;
+ r->double_value = binary_million;
+ r->uint64_t_value |= random_bits;
+ r->double_value -= binary_million;
+
+ return heap_number;
}
} } // namespace v8::internal