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

Side by Side Diff: src/platform-win32.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: 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
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 142
143 double ceiling(double x) { 143 double ceiling(double x) {
144 return ceil(x); 144 return ceil(x);
145 } 145 }
146 146
147 147
148 static Mutex* limit_mutex = NULL; 148 static Mutex* limit_mutex = NULL;
149 149
150 #if defined(V8_TARGET_ARCH_IA32) 150 #if defined(V8_TARGET_ARCH_IA32)
151 static OS::MemCopyFunction memcopy_function = NULL; 151 static void MemMoveWrapper(void* dest, const void* src, size_t size) {
152 memmove(dest, src, size);
153 }
154
155 // Initialize to library version so we can call this at any time during startup.
156 static OS::MemMoveFunction memmove_function = &MemMoveWrapper;
Michael Starzinger 2013/04/16 09:41:42 nit: Add an empty newline after "memmove_function"
Jakob Kummerow 2013/04/16 12:29:42 Done.
152 // Defined in codegen-ia32.cc. 157 // Defined in codegen-ia32.cc.
153 OS::MemCopyFunction CreateMemCopyFunction(); 158 OS::MemMoveFunction CreateMemMoveFunction();
154 159
155 // Copy memory area to disjoint memory area. 160 // Copy memory area to disjoint memory area.
156 void OS::MemCopy(void* dest, const void* src, size_t size) { 161 void OS::MemMove(void* dest, const void* src, size_t size) {
157 // Note: here we rely on dependent reads being ordered. This is true 162 // Note: here we rely on dependent reads being ordered. This is true
158 // on all architectures we currently support. 163 // on all architectures we currently support.
159 (*memcopy_function)(dest, src, size); 164 (*memmove_function)(dest, src, size);
160 #ifdef DEBUG
161 CHECK_EQ(0, memcmp(dest, src, size));
162 #endif
163 } 165 }
166
164 #endif // V8_TARGET_ARCH_IA32 167 #endif // V8_TARGET_ARCH_IA32
165 168
166 #ifdef _WIN64 169 #ifdef _WIN64
167 typedef double (*ModuloFunction)(double, double); 170 typedef double (*ModuloFunction)(double, double);
168 static ModuloFunction modulo_function = NULL; 171 static ModuloFunction modulo_function = NULL;
169 // Defined in codegen-x64.cc. 172 // Defined in codegen-x64.cc.
170 ModuloFunction CreateModuloFunction(); 173 ModuloFunction CreateModuloFunction();
171 174
172 void init_modulo_function() { 175 void init_modulo_function() {
173 modulo_function = CreateModuloFunction(); 176 modulo_function = CreateModuloFunction();
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 // saving is in effect at the given time. 572 // saving is in effect at the given time.
570 return InDST() ? dst_tz_name_ : std_tz_name_; 573 return InDST() ? dst_tz_name_ : std_tz_name_;
571 } 574 }
572 575
573 576
574 void OS::PostSetUp() { 577 void OS::PostSetUp() {
575 // Math functions depend on CPU features therefore they are initialized after 578 // Math functions depend on CPU features therefore they are initialized after
576 // CPU. 579 // CPU.
577 MathSetup(); 580 MathSetup();
578 #if defined(V8_TARGET_ARCH_IA32) 581 #if defined(V8_TARGET_ARCH_IA32)
579 memcopy_function = CreateMemCopyFunction(); 582 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction();
583 if (generated_memmove != NULL) {
584 memmove_function = generated_memmove;
585 }
580 #endif 586 #endif
581 } 587 }
582 588
583 589
584 // Returns the accumulated user time for thread. 590 // Returns the accumulated user time for thread.
585 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { 591 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
586 FILETIME dummy; 592 FILETIME dummy;
587 uint64_t usertime; 593 uint64_t usertime;
588 594
589 // Get the amount of time that the thread has executed in user mode. 595 // Get the amount of time that the thread has executed in user mode.
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 // Open a physical file 1061 // Open a physical file
1056 HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, 1062 HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
1057 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL); 1063 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL);
1058 if (file == NULL) return NULL; 1064 if (file == NULL) return NULL;
1059 // Create a file mapping for the physical file 1065 // Create a file mapping for the physical file
1060 HANDLE file_mapping = CreateFileMapping(file, NULL, 1066 HANDLE file_mapping = CreateFileMapping(file, NULL,
1061 PAGE_READWRITE, 0, static_cast<DWORD>(size), NULL); 1067 PAGE_READWRITE, 0, static_cast<DWORD>(size), NULL);
1062 if (file_mapping == NULL) return NULL; 1068 if (file_mapping == NULL) return NULL;
1063 // Map a view of the file into memory 1069 // Map a view of the file into memory
1064 void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size); 1070 void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
1065 if (memory) memmove(memory, initial, size); 1071 if (memory) OS::MemMove(memory, initial, size);
1066 return new Win32MemoryMappedFile(file, file_mapping, memory, size); 1072 return new Win32MemoryMappedFile(file, file_mapping, memory, size);
1067 } 1073 }
1068 1074
1069 1075
1070 Win32MemoryMappedFile::~Win32MemoryMappedFile() { 1076 Win32MemoryMappedFile::~Win32MemoryMappedFile() {
1071 if (memory_ != NULL) 1077 if (memory_ != NULL)
1072 UnmapViewOfFile(memory_); 1078 UnmapViewOfFile(memory_);
1073 CloseHandle(file_mapping_); 1079 CloseHandle(file_mapping_);
1074 CloseHandle(file_); 1080 CloseHandle(file_);
1075 } 1081 }
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
2175 2181
2176 2182
2177 void Sampler::Stop() { 2183 void Sampler::Stop() {
2178 ASSERT(IsActive()); 2184 ASSERT(IsActive());
2179 SamplerThread::RemoveActiveSampler(this); 2185 SamplerThread::RemoveActiveSampler(this);
2180 SetActive(false); 2186 SetActive(false);
2181 } 2187 }
2182 2188
2183 2189
2184 } } // namespace v8::internal 2190 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698