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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // TODO(bradchen): restore randomization once Native Client gets | 98 // TODO(bradchen): restore randomization once Native Client gets |
99 // smarter about using mmap address hints. | 99 // smarter about using mmap address hints. |
100 // See http://code.google.com/p/nativeclient/issues/3341 | 100 // See http://code.google.com/p/nativeclient/issues/3341 |
101 return NULL; | 101 return NULL; |
102 #endif | 102 #endif |
103 Isolate* isolate = Isolate::UncheckedCurrent(); | 103 Isolate* isolate = Isolate::UncheckedCurrent(); |
104 // Note that the current isolate isn't set up in a call path via | 104 // Note that the current isolate isn't set up in a call path via |
105 // CpuFeatures::Probe. We don't care about randomization in this case because | 105 // CpuFeatures::Probe. We don't care about randomization in this case because |
106 // the code page is immediately freed. | 106 // the code page is immediately freed. |
107 if (isolate != NULL) { | 107 if (isolate != NULL) { |
108 #ifdef V8_TARGET_ARCH_X64 | 108 #if V8_TARGET_ARCH_X64 |
109 uint64_t rnd1 = V8::RandomPrivate(isolate); | 109 uint64_t rnd1 = V8::RandomPrivate(isolate); |
110 uint64_t rnd2 = V8::RandomPrivate(isolate); | 110 uint64_t rnd2 = V8::RandomPrivate(isolate); |
111 uint64_t raw_addr = (rnd1 << 32) ^ rnd2; | 111 uint64_t raw_addr = (rnd1 << 32) ^ rnd2; |
112 // Currently available CPUs have 48 bits of virtual addressing. Truncate | 112 // Currently available CPUs have 48 bits of virtual addressing. Truncate |
113 // the hint address to 46 bits to give the kernel a fighting chance of | 113 // the hint address to 46 bits to give the kernel a fighting chance of |
114 // fulfilling our placement request. | 114 // fulfilling our placement request. |
115 raw_addr &= V8_UINT64_C(0x3ffffffff000); | 115 raw_addr &= V8_UINT64_C(0x3ffffffff000); |
116 #else | 116 #else |
117 uint32_t raw_addr = V8::RandomPrivate(isolate); | 117 uint32_t raw_addr = V8::RandomPrivate(isolate); |
118 // The range 0x20000000 - 0x60000000 is relatively unpopulated across a | 118 // The range 0x20000000 - 0x60000000 is relatively unpopulated across a |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // If the length is zero, the assignment fails. | 314 // If the length is zero, the assignment fails. |
315 if (str.length() > 0) | 315 if (str.length() > 0) |
316 str[str.length() - 1] = '\0'; | 316 str[str.length() - 1] = '\0'; |
317 return -1; | 317 return -1; |
318 } else { | 318 } else { |
319 return n; | 319 return n; |
320 } | 320 } |
321 } | 321 } |
322 | 322 |
323 | 323 |
324 #if defined(V8_TARGET_ARCH_IA32) | 324 #if V8_TARGET_ARCH_IA32 |
325 static void MemMoveWrapper(void* dest, const void* src, size_t size) { | 325 static void MemMoveWrapper(void* dest, const void* src, size_t size) { |
326 memmove(dest, src, size); | 326 memmove(dest, src, size); |
327 } | 327 } |
328 | 328 |
329 // Initialize to library version so we can call this at any time during startup. | 329 // Initialize to library version so we can call this at any time during startup. |
330 static OS::MemMoveFunction memmove_function = &MemMoveWrapper; | 330 static OS::MemMoveFunction memmove_function = &MemMoveWrapper; |
331 | 331 |
332 // Defined in codegen-ia32.cc. | 332 // Defined in codegen-ia32.cc. |
333 OS::MemMoveFunction CreateMemMoveFunction(); | 333 OS::MemMoveFunction CreateMemMoveFunction(); |
334 | 334 |
335 // Copy memory area. No restrictions. | 335 // Copy memory area. No restrictions. |
336 void OS::MemMove(void* dest, const void* src, size_t size) { | 336 void OS::MemMove(void* dest, const void* src, size_t size) { |
337 if (size == 0) return; | 337 if (size == 0) return; |
338 // Note: here we rely on dependent reads being ordered. This is true | 338 // Note: here we rely on dependent reads being ordered. This is true |
339 // on all architectures we currently support. | 339 // on all architectures we currently support. |
340 (*memmove_function)(dest, src, size); | 340 (*memmove_function)(dest, src, size); |
341 } | 341 } |
342 | 342 |
343 #endif // V8_TARGET_ARCH_IA32 | 343 #endif // V8_TARGET_ARCH_IA32 |
344 | 344 |
345 | 345 |
346 void POSIXPostSetUp() { | 346 void POSIXPostSetUp() { |
347 #if defined(V8_TARGET_ARCH_IA32) | 347 #if V8_TARGET_ARCH_IA32 |
348 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); | 348 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); |
349 if (generated_memmove != NULL) { | 349 if (generated_memmove != NULL) { |
350 memmove_function = generated_memmove; | 350 memmove_function = generated_memmove; |
351 } | 351 } |
352 #endif | 352 #endif |
353 init_fast_sin_function(); | 353 init_fast_sin_function(); |
354 init_fast_cos_function(); | 354 init_fast_cos_function(); |
355 init_fast_tan_function(); | 355 init_fast_tan_function(); |
356 init_fast_log_function(); | 356 init_fast_log_function(); |
357 // fast_exp is initialized lazily. | 357 // fast_exp is initialized lazily. |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 return ntohl(value); | 564 return ntohl(value); |
565 } | 565 } |
566 | 566 |
567 | 567 |
568 Socket* OS::CreateSocket() { | 568 Socket* OS::CreateSocket() { |
569 return new POSIXSocket(); | 569 return new POSIXSocket(); |
570 } | 570 } |
571 | 571 |
572 | 572 |
573 } } // namespace v8::internal | 573 } } // namespace v8::internal |
OLD | NEW |