| 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 |
| 329 // Initialize to library version so we can call this at any time during startup. | 330 // Initialize to library version so we can call this at any time during startup. |
| 330 static OS::MemMoveFunction memmove_function = &MemMoveWrapper; | 331 static OS::MemMoveFunction memmove_function = &MemMoveWrapper; |
| 331 | 332 |
| 332 // Defined in codegen-ia32.cc. | 333 // Defined in codegen-ia32.cc. |
| 333 OS::MemMoveFunction CreateMemMoveFunction(); | 334 OS::MemMoveFunction CreateMemMoveFunction(); |
| 334 | 335 |
| 335 // Copy memory area. No restrictions. | 336 // Copy memory area. No restrictions. |
| 336 void OS::MemMove(void* dest, const void* src, size_t size) { | 337 void OS::MemMove(void* dest, const void* src, size_t size) { |
| 337 if (size == 0) return; | 338 if (size == 0) return; |
| 338 // Note: here we rely on dependent reads being ordered. This is true | 339 // Note: here we rely on dependent reads being ordered. This is true |
| 339 // on all architectures we currently support. | 340 // on all architectures we currently support. |
| 340 (*memmove_function)(dest, src, size); | 341 (*memmove_function)(dest, src, size); |
| 341 } | 342 } |
| 342 | 343 |
| 343 #endif // V8_TARGET_ARCH_IA32 | 344 #endif // V8_TARGET_ARCH_IA32 |
| 344 | 345 |
| 345 | 346 |
| 346 void POSIXPostSetUp() { | 347 void POSIXPostSetUp() { |
| 347 #if defined(V8_TARGET_ARCH_IA32) | 348 #if V8_TARGET_ARCH_IA32 |
| 348 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); | 349 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); |
| 349 if (generated_memmove != NULL) { | 350 if (generated_memmove != NULL) { |
| 350 memmove_function = generated_memmove; | 351 memmove_function = generated_memmove; |
| 351 } | 352 } |
| 352 #endif | 353 #endif |
| 353 init_fast_sin_function(); | 354 init_fast_sin_function(); |
| 354 init_fast_cos_function(); | 355 init_fast_cos_function(); |
| 355 init_fast_tan_function(); | 356 init_fast_tan_function(); |
| 356 init_fast_log_function(); | 357 init_fast_log_function(); |
| 357 // fast_exp is initialized lazily. | 358 // fast_exp is initialized lazily. |
| 358 init_fast_sqrt_function(); | 359 init_fast_sqrt_function(); |
| 359 } | 360 } |
| 360 | 361 |
| 362 |
| 361 // ---------------------------------------------------------------------------- | 363 // ---------------------------------------------------------------------------- |
| 362 // POSIX string support. | 364 // POSIX string support. |
| 363 // | 365 // |
| 364 | 366 |
| 365 char* OS::StrChr(char* str, int c) { | 367 char* OS::StrChr(char* str, int c) { |
| 366 return strchr(str, c); | 368 return strchr(str, c); |
| 367 } | 369 } |
| 368 | 370 |
| 369 | 371 |
| 370 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { | 372 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 return ntohl(value); | 566 return ntohl(value); |
| 565 } | 567 } |
| 566 | 568 |
| 567 | 569 |
| 568 Socket* OS::CreateSocket() { | 570 Socket* OS::CreateSocket() { |
| 569 return new POSIXSocket(); | 571 return new POSIXSocket(); |
| 570 } | 572 } |
| 571 | 573 |
| 572 | 574 |
| 573 } } // namespace v8::internal | 575 } } // namespace v8::internal |
| OLD | NEW |