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

Side by Side Diff: src/heap.cc

Issue 13932006: Replace OS::MemCopy with OS::MemMove (just as fast but more flexible). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/global-handles.h ('k') | src/heap-inl.h » ('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 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 681
682 682
683 void Heap::MoveElements(FixedArray* array, 683 void Heap::MoveElements(FixedArray* array,
684 int dst_index, 684 int dst_index,
685 int src_index, 685 int src_index,
686 int len) { 686 int len) {
687 if (len == 0) return; 687 if (len == 0) return;
688 688
689 ASSERT(array->map() != HEAP->fixed_cow_array_map()); 689 ASSERT(array->map() != HEAP->fixed_cow_array_map());
690 Object** dst_objects = array->data_start() + dst_index; 690 Object** dst_objects = array->data_start() + dst_index;
691 memmove(dst_objects, 691 OS::MemMove(dst_objects,
692 array->data_start() + src_index, 692 array->data_start() + src_index,
693 len * kPointerSize); 693 len * kPointerSize);
694 if (!InNewSpace(array)) { 694 if (!InNewSpace(array)) {
695 for (int i = 0; i < len; i++) { 695 for (int i = 0; i < len; i++) {
696 // TODO(hpayer): check store buffer for entries 696 // TODO(hpayer): check store buffer for entries
697 if (InNewSpace(dst_objects[i])) { 697 if (InNewSpace(dst_objects[i])) {
698 RecordWrite(array->address(), array->OffsetOfElementAt(dst_index + i)); 698 RecordWrite(array->address(), array->OffsetOfElementAt(dst_index + i));
699 } 699 }
700 } 700 }
701 } 701 }
702 incremental_marking()->RecordWrites(array); 702 incremental_marking()->RecordWrites(array);
703 } 703 }
(...skipping 4254 matching lines...) Expand 10 before | Expand all | Expand 10 after
4958 default: return NULL; // No match found. 4958 default: return NULL; // No match found.
4959 } 4959 }
4960 } 4960 }
4961 4961
4962 4962
4963 static inline void WriteOneByteData(Vector<const char> vector, 4963 static inline void WriteOneByteData(Vector<const char> vector,
4964 uint8_t* chars, 4964 uint8_t* chars,
4965 int len) { 4965 int len) {
4966 // Only works for ascii. 4966 // Only works for ascii.
4967 ASSERT(vector.length() == len); 4967 ASSERT(vector.length() == len);
4968 memcpy(chars, vector.start(), len); 4968 OS::MemCopy(chars, vector.start(), len);
4969 } 4969 }
4970 4970
4971 static inline void WriteTwoByteData(Vector<const char> vector, 4971 static inline void WriteTwoByteData(Vector<const char> vector,
4972 uint16_t* chars, 4972 uint16_t* chars,
4973 int len) { 4973 int len) {
4974 const uint8_t* stream = reinterpret_cast<const uint8_t*>(vector.start()); 4974 const uint8_t* stream = reinterpret_cast<const uint8_t*>(vector.start());
4975 unsigned stream_length = vector.length(); 4975 unsigned stream_length = vector.length();
4976 while (stream_length != 0) { 4976 while (stream_length != 0) {
4977 unsigned consumed = 0; 4977 unsigned consumed = 0;
4978 uint32_t c = unibrow::Utf8::ValueOf(stream, stream_length, &consumed); 4978 uint32_t c = unibrow::Utf8::ValueOf(stream, stream_length, &consumed);
(...skipping 2855 matching lines...) Expand 10 before | Expand all | Expand 10 after
7834 static_cast<int>(object_counts_[index])); \ 7834 static_cast<int>(object_counts_[index])); \
7835 counters->count_of_FIXED_ARRAY_##name()->Decrement( \ 7835 counters->count_of_FIXED_ARRAY_##name()->Decrement( \
7836 static_cast<int>(object_counts_last_time_[index])); \ 7836 static_cast<int>(object_counts_last_time_[index])); \
7837 counters->size_of_FIXED_ARRAY_##name()->Increment( \ 7837 counters->size_of_FIXED_ARRAY_##name()->Increment( \
7838 static_cast<int>(object_sizes_[index])); \ 7838 static_cast<int>(object_sizes_[index])); \
7839 counters->size_of_FIXED_ARRAY_##name()->Decrement( \ 7839 counters->size_of_FIXED_ARRAY_##name()->Decrement( \
7840 static_cast<int>(object_sizes_last_time_[index])); 7840 static_cast<int>(object_sizes_last_time_[index]));
7841 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) 7841 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7842 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7842 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7843 7843
7844 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7844 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7845 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7845 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7846 ClearObjectStats(); 7846 ClearObjectStats();
7847 } 7847 }
7848 7848
7849 } } // namespace v8::internal 7849 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/global-handles.h ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698