Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: src/v8.cc

Issue 9617011: MIPS: avoid alignment issues in FillHeapNumberWithRandom. (Closed)
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 uint64_t random_bits = Random(context); 226 uint64_t random_bits = Random(context);
227 #ifdef V8_HOST_ARCH_MIPS
Yang 2012/03/06 17:38:38 We have a flag called V8_TARGET_CAN_READ_UNALIGNED
Erik Corry 2012/03/07 08:25:53 I agree with this.
228 // Copy the value to a local variable to avoid alignment issues.
229 double_int_union num;
230 double_int_union* r = #
231 memcpy(r, heap_number + HeapNumber::kValueOffset - kHeapObjectTag,
232 sizeof(num));
233 #else
227 // Make a double* from address (heap_number + sizeof(double)). 234 // Make a double* from address (heap_number + sizeof(double)).
228 double_int_union* r = reinterpret_cast<double_int_union*>( 235 double_int_union* r = reinterpret_cast<double_int_union*>(
229 reinterpret_cast<char*>(heap_number) + 236 reinterpret_cast<char*>(heap_number) +
230 HeapNumber::kValueOffset - kHeapObjectTag); 237 HeapNumber::kValueOffset - kHeapObjectTag);
238 #endif
239
231 // Convert 32 random bits to 0.(32 random bits) in a double 240 // Convert 32 random bits to 0.(32 random bits) in a double
232 // by computing: 241 // by computing:
233 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). 242 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
234 const double binary_million = 1048576.0; 243 const double binary_million = 1048576.0;
235 r->double_value = binary_million; 244 r->double_value = binary_million;
236 r->uint64_t_value |= random_bits; 245 r->uint64_t_value |= random_bits;
237 r->double_value -= binary_million; 246 r->double_value -= binary_million;
238 247
248 #ifdef V8_HOST_ARCH_MIPS
249 memcpy(heap_number + HeapNumber::kValueOffset - kHeapObjectTag, r,
250 sizeof(num));
251 #endif
252
239 return heap_number; 253 return heap_number;
240 } 254 }
241 255
242 256
243 void V8::InitializeOncePerProcess() { 257 void V8::InitializeOncePerProcess() {
244 ScopedLock lock(init_once_mutex); 258 ScopedLock lock(init_once_mutex);
245 if (init_once_called) return; 259 if (init_once_called) return;
246 init_once_called = true; 260 init_once_called = true;
247 261
248 // Set up the platform OS support. 262 // Set up the platform OS support.
(...skipping 15 matching lines...) Expand all
264 ElementsAccessor::InitializeOncePerProcess(); 278 ElementsAccessor::InitializeOncePerProcess();
265 279
266 if (FLAG_stress_compaction) { 280 if (FLAG_stress_compaction) {
267 FLAG_force_marking_deque_overflows = true; 281 FLAG_force_marking_deque_overflows = true;
268 FLAG_gc_global = true; 282 FLAG_gc_global = true;
269 FLAG_max_new_space_size = (1 << (kPageSizeBits - 10)) * 2; 283 FLAG_max_new_space_size = (1 << (kPageSizeBits - 10)) * 2;
270 } 284 }
271 } 285 }
272 286
273 } } // namespace v8::internal 287 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698