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

Side by Side Diff: src/utils.h

Issue 1530005: Refactor word copying logic. (Closed)
Patch Set: Assert added and param renamed Created 10 years, 8 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 | « src/heap-inl.h ('k') | 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 #else 590 #else
591 for (int i = 0; i < counter; i++) { 591 for (int i = 0; i < counter; i++) {
592 dest[i] = value; 592 dest[i] = value;
593 } 593 }
594 #endif 594 #endif
595 595
596 #undef STOS 596 #undef STOS
597 } 597 }
598 598
599 599
600 // Copies data from |src| to |dst|. The data spans MUST not overlap.
601 inline void CopyWords(Object** dst, Object** src, int num_words) {
602 ASSERT(Min(dst, src) + num_words <= Max(dst, src));
603 // Use block copying memcpy if the segment we're copying is
604 // enough to justify the extra call/setup overhead.
605 static const int kBlockCopyLimit = 16;
606
607 if (num_words >= kBlockCopyLimit) {
608 memcpy(dst, src, num_words * kPointerSize);
609 } else {
610 int remaining = num_words;
611 do {
612 remaining--;
613 *dst++ = *src++;
614 } while (remaining > 0);
615 }
616 }
617
618
600 // Calculate 10^exponent. 619 // Calculate 10^exponent.
601 int TenToThe(int exponent); 620 int TenToThe(int exponent);
602 621
603 622
604 // The type-based aliasing rule allows the compiler to assume that pointers of 623 // The type-based aliasing rule allows the compiler to assume that pointers of
605 // different types (for some definition of different) never alias each other. 624 // different types (for some definition of different) never alias each other.
606 // Thus the following code does not work: 625 // Thus the following code does not work:
607 // 626 //
608 // float f = foo(); 627 // float f = foo();
609 // int fbits = *(int*)(&f); 628 // int fbits = *(int*)(&f);
(...skipping 23 matching lines...) Expand all
633 652
634 Dest dest; 653 Dest dest;
635 memcpy(&dest, &source, sizeof(dest)); 654 memcpy(&dest, &source, sizeof(dest));
636 return dest; 655 return dest;
637 } 656 }
638 657
639 658
640 } } // namespace v8::internal 659 } } // namespace v8::internal
641 660
642 #endif // V8_UTILS_H_ 661 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « src/heap-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698