| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 // Use a union type to avoid type-aliasing optimizations in GCC. | 217 // Use a union type to avoid type-aliasing optimizations in GCC. |
| 218 typedef union { | 218 typedef union { |
| 219 double double_value; | 219 double double_value; |
| 220 uint64_t uint64_t_value; | 220 uint64_t uint64_t_value; |
| 221 } double_int_union; | 221 } double_int_union; |
| 222 | 222 |
| 223 | 223 |
| 224 Object* V8::FillHeapNumberWithRandom(Object* heap_number, | 224 Object* V8::FillHeapNumberWithRandom(Object* heap_number, |
| 225 Context* context) { | 225 Context* context) { |
| 226 double_int_union r; |
| 226 uint64_t random_bits = Random(context); | 227 uint64_t random_bits = Random(context); |
| 227 // Make a double* from address (heap_number + sizeof(double)). | |
| 228 double_int_union* r = reinterpret_cast<double_int_union*>( | |
| 229 reinterpret_cast<char*>(heap_number) + | |
| 230 HeapNumber::kValueOffset - kHeapObjectTag); | |
| 231 // Convert 32 random bits to 0.(32 random bits) in a double | 228 // Convert 32 random bits to 0.(32 random bits) in a double |
| 232 // by computing: | 229 // by computing: |
| 233 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | 230 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). |
| 234 const double binary_million = 1048576.0; | 231 static const double binary_million = 1048576.0; |
| 235 r->double_value = binary_million; | 232 r.double_value = binary_million; |
| 236 r->uint64_t_value |= random_bits; | 233 r.uint64_t_value |= random_bits; |
| 237 r->double_value -= binary_million; | 234 r.double_value -= binary_million; |
| 238 | 235 |
| 236 HeapNumber::cast(heap_number)->set_value(r.double_value); |
| 239 return heap_number; | 237 return heap_number; |
| 240 } | 238 } |
| 241 | 239 |
| 242 | 240 |
| 243 void V8::InitializeOncePerProcess() { | 241 void V8::InitializeOncePerProcess() { |
| 244 ScopedLock lock(init_once_mutex); | 242 ScopedLock lock(init_once_mutex); |
| 245 if (init_once_called) return; | 243 if (init_once_called) return; |
| 246 init_once_called = true; | 244 init_once_called = true; |
| 247 | 245 |
| 248 // Set up the platform OS support. | 246 // Set up the platform OS support. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 264 ElementsAccessor::InitializeOncePerProcess(); | 262 ElementsAccessor::InitializeOncePerProcess(); |
| 265 | 263 |
| 266 if (FLAG_stress_compaction) { | 264 if (FLAG_stress_compaction) { |
| 267 FLAG_force_marking_deque_overflows = true; | 265 FLAG_force_marking_deque_overflows = true; |
| 268 FLAG_gc_global = true; | 266 FLAG_gc_global = true; |
| 269 FLAG_max_new_space_size = (1 << (kPageSizeBits - 10)) * 2; | 267 FLAG_max_new_space_size = (1 << (kPageSizeBits - 10)) * 2; |
| 270 } | 268 } |
| 271 } | 269 } |
| 272 | 270 |
| 273 } } // namespace v8::internal | 271 } } // namespace v8::internal |
| OLD | NEW |