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

Side by Side Diff: src/utils.cc

Issue 1480883002: Initialize fast memmove methods in the Isolate's ctor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 | « src/utils.h ('k') | src/v8.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/utils.h" 5 #include "src/utils.h"
6 6
7 #include <stdarg.h> 7 #include <stdarg.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include "src/base/functional.h" 10 #include "src/base/functional.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 361 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
362 static void MemMoveWrapper(void* dest, const void* src, size_t size) { 362 static void MemMoveWrapper(void* dest, const void* src, size_t size) {
363 memmove(dest, src, size); 363 memmove(dest, src, size);
364 } 364 }
365 365
366 366
367 // Initialize to library version so we can call this at any time during startup. 367 // Initialize to library version so we can call this at any time during startup.
368 static MemMoveFunction memmove_function = &MemMoveWrapper; 368 static MemMoveFunction memmove_function = &MemMoveWrapper;
369 369
370 // Defined in codegen-ia32.cc. 370 // Defined in codegen-ia32.cc.
371 MemMoveFunction CreateMemMoveFunction(); 371 MemMoveFunction CreateMemMoveFunction(Isolate* isolate);
372 372
373 // Copy memory area to disjoint memory area. 373 // Copy memory area to disjoint memory area.
374 void MemMove(void* dest, const void* src, size_t size) { 374 void MemMove(void* dest, const void* src, size_t size) {
375 if (size == 0) return; 375 if (size == 0) return;
376 // Note: here we rely on dependent reads being ordered. This is true 376 // Note: here we rely on dependent reads being ordered. This is true
377 // on all architectures we currently support. 377 // on all architectures we currently support.
378 (*memmove_function)(dest, src, size); 378 (*memmove_function)(dest, src, size);
379 } 379 }
380 380
381 #elif V8_OS_POSIX && V8_HOST_ARCH_ARM 381 #elif V8_OS_POSIX && V8_HOST_ARCH_ARM
382 void MemCopyUint16Uint8Wrapper(uint16_t* dest, const uint8_t* src, 382 void MemCopyUint16Uint8Wrapper(uint16_t* dest, const uint8_t* src,
383 size_t chars) { 383 size_t chars) {
384 uint16_t* limit = dest + chars; 384 uint16_t* limit = dest + chars;
385 while (dest < limit) { 385 while (dest < limit) {
386 *dest++ = static_cast<uint16_t>(*src++); 386 *dest++ = static_cast<uint16_t>(*src++);
387 } 387 }
388 } 388 }
389 389
390 390
391 MemCopyUint8Function memcopy_uint8_function = &MemCopyUint8Wrapper; 391 MemCopyUint8Function memcopy_uint8_function = &MemCopyUint8Wrapper;
392 MemCopyUint16Uint8Function memcopy_uint16_uint8_function = 392 MemCopyUint16Uint8Function memcopy_uint16_uint8_function =
393 &MemCopyUint16Uint8Wrapper; 393 &MemCopyUint16Uint8Wrapper;
394 // Defined in codegen-arm.cc. 394 // Defined in codegen-arm.cc.
395 MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub); 395 MemCopyUint8Function CreateMemCopyUint8Function(Isolate* isolate,
396 MemCopyUint8Function stub);
396 MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( 397 MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
397 MemCopyUint16Uint8Function stub); 398 Isolate* isolate, MemCopyUint16Uint8Function stub);
398 399
399 #elif V8_OS_POSIX && V8_HOST_ARCH_MIPS 400 #elif V8_OS_POSIX && V8_HOST_ARCH_MIPS
400 MemCopyUint8Function memcopy_uint8_function = &MemCopyUint8Wrapper; 401 MemCopyUint8Function memcopy_uint8_function = &MemCopyUint8Wrapper;
401 // Defined in codegen-mips.cc. 402 // Defined in codegen-mips.cc.
402 MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub); 403 MemCopyUint8Function CreateMemCopyUint8Function(Isolate* isolate,
404 MemCopyUint8Function stub);
403 #endif 405 #endif
404 406
405 407
406 void init_memcopy_functions() { 408 static bool g_memcopy_functions_initialized = false;
409
410
411 void init_memcopy_functions(Isolate* isolate) {
412 if (g_memcopy_functions_initialized) return;
413 g_memcopy_functions_initialized = true;
407 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 414 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
408 MemMoveFunction generated_memmove = CreateMemMoveFunction(); 415 MemMoveFunction generated_memmove = CreateMemMoveFunction(isolate);
409 if (generated_memmove != NULL) { 416 if (generated_memmove != NULL) {
410 memmove_function = generated_memmove; 417 memmove_function = generated_memmove;
411 } 418 }
412 #elif V8_OS_POSIX && V8_HOST_ARCH_ARM 419 #elif V8_OS_POSIX && V8_HOST_ARCH_ARM
413 memcopy_uint8_function = CreateMemCopyUint8Function(&MemCopyUint8Wrapper); 420 memcopy_uint8_function =
421 CreateMemCopyUint8Function(isolate, &MemCopyUint8Wrapper);
414 memcopy_uint16_uint8_function = 422 memcopy_uint16_uint8_function =
415 CreateMemCopyUint16Uint8Function(&MemCopyUint16Uint8Wrapper); 423 CreateMemCopyUint16Uint8Function(isolate, &MemCopyUint16Uint8Wrapper);
416 #elif V8_OS_POSIX && V8_HOST_ARCH_MIPS 424 #elif V8_OS_POSIX && V8_HOST_ARCH_MIPS
417 memcopy_uint8_function = CreateMemCopyUint8Function(&MemCopyUint8Wrapper); 425 memcopy_uint8_function =
426 CreateMemCopyUint8Function(isolate, &MemCopyUint8Wrapper);
418 #endif 427 #endif
419 } 428 }
420 429
421 430
422 bool DoubleToBoolean(double d) { 431 bool DoubleToBoolean(double d) {
423 // NaN, +0, and -0 should return the false object 432 // NaN, +0, and -0 should return the false object
424 #if V8_TARGET_LITTLE_ENDIAN 433 #if V8_TARGET_LITTLE_ENDIAN
425 union IeeeDoubleLittleEndianArchType u; 434 union IeeeDoubleLittleEndianArchType u;
426 #else 435 #else
427 union IeeeDoubleBigEndianArchType u; 436 union IeeeDoubleBigEndianArchType u;
428 #endif 437 #endif
429 u.d = d; 438 u.d = d;
430 if (u.bits.exp == 2047) { 439 if (u.bits.exp == 2047) {
431 // Detect NaN for IEEE double precision floating point. 440 // Detect NaN for IEEE double precision floating point.
432 if ((u.bits.man_low | u.bits.man_high) != 0) return false; 441 if ((u.bits.man_low | u.bits.man_high) != 0) return false;
433 } 442 }
434 if (u.bits.exp == 0) { 443 if (u.bits.exp == 0) {
435 // Detect +0, and -0 for IEEE double precision floating point. 444 // Detect +0, and -0 for IEEE double precision floating point.
436 if ((u.bits.man_low | u.bits.man_high) == 0) return false; 445 if ((u.bits.man_low | u.bits.man_high) == 0) return false;
437 } 446 }
438 return true; 447 return true;
439 } 448 }
440 449
441 450
442 } // namespace internal 451 } // namespace internal
443 } // namespace v8 452 } // namespace v8
OLDNEW
« no previous file with comments | « src/utils.h ('k') | src/v8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698