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

Side by Side Diff: src/platform-win32.cc

Issue 302563004: Move OS::MemCopy and OS::MemMove out of platform to utils (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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/platform-posix.cc ('k') | src/preparse-data.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 // Platform-specific code for Win32. 5 // Platform-specific code for Win32.
6 6
7 // Secure API functions are not available using MinGW with msvcrt.dll 7 // Secure API functions are not available using MinGW with msvcrt.dll
8 // on Windows XP. Make sure MINGW_HAS_SECURE_API is not defined to 8 // on Windows XP. Make sure MINGW_HAS_SECURE_API is not defined to
9 // disable definition of secure API functions in standard headers that 9 // disable definition of secure API functions in standard headers that
10 // would conflict with our own implementation. 10 // would conflict with our own implementation.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 #endif // __MINGW32__ 100 #endif // __MINGW32__
101 101
102 namespace v8 { 102 namespace v8 {
103 namespace internal { 103 namespace internal {
104 104
105 intptr_t OS::MaxVirtualMemory() { 105 intptr_t OS::MaxVirtualMemory() {
106 return 0; 106 return 0;
107 } 107 }
108 108
109 109
110 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
111 static void MemMoveWrapper(void* dest, const void* src, size_t size) {
112 memmove(dest, src, size);
113 }
114
115
116 // Initialize to library version so we can call this at any time during startup.
117 static OS::MemMoveFunction memmove_function = &MemMoveWrapper;
118
119 // Defined in codegen-ia32.cc.
120 OS::MemMoveFunction CreateMemMoveFunction();
121
122 // Copy memory area to disjoint memory area.
123 void OS::MemMove(void* dest, const void* src, size_t size) {
124 if (size == 0) return;
125 // Note: here we rely on dependent reads being ordered. This is true
126 // on all architectures we currently support.
127 (*memmove_function)(dest, src, size);
128 }
129
130 #endif // V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
131
132
133 class TimezoneCache { 110 class TimezoneCache {
134 public: 111 public:
135 TimezoneCache() : initialized_(false) { } 112 TimezoneCache() : initialized_(false) { }
136 113
137 void Clear() { 114 void Clear() {
138 initialized_ = false; 115 initialized_ = false;
139 } 116 }
140 117
141 // Initialize timezone information. The timezone information is obtained from 118 // Initialize timezone information. The timezone information is obtained from
142 // windows. If we cannot get the timezone information we fall back to CET. 119 // windows. If we cannot get the timezone information we fall back to CET.
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 422
446 // Returns a string identifying the current timezone for the 423 // Returns a string identifying the current timezone for the
447 // timestamp taking into account daylight saving. 424 // timestamp taking into account daylight saving.
448 char* Win32Time::LocalTimezone(TimezoneCache* cache) { 425 char* Win32Time::LocalTimezone(TimezoneCache* cache) {
449 // Return the standard or DST time zone name based on whether daylight 426 // Return the standard or DST time zone name based on whether daylight
450 // saving is in effect at the given time. 427 // saving is in effect at the given time.
451 return InDST(cache) ? cache->dst_tz_name_ : cache->std_tz_name_; 428 return InDST(cache) ? cache->dst_tz_name_ : cache->std_tz_name_;
452 } 429 }
453 430
454 431
455 void OS::PostSetUp() {
456 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
457 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction();
458 if (generated_memmove != NULL) {
459 memmove_function = generated_memmove;
460 }
461 #endif
462 }
463
464
465 // Returns the accumulated user time for thread. 432 // Returns the accumulated user time for thread.
466 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { 433 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
467 FILETIME dummy; 434 FILETIME dummy;
468 uint64_t usertime; 435 uint64_t usertime;
469 436
470 // Get the amount of time that the thread has executed in user mode. 437 // Get the amount of time that the thread has executed in user mode.
471 if (!GetThreadTimes(GetCurrentThread(), &dummy, &dummy, &dummy, 438 if (!GetThreadTimes(GetCurrentThread(), &dummy, &dummy, &dummy,
472 reinterpret_cast<FILETIME*>(&usertime))) return -1; 439 reinterpret_cast<FILETIME*>(&usertime))) return -1;
473 440
474 // Adjust the resolution to micro-seconds. 441 // Adjust the resolution to micro-seconds.
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 // Open a physical file 873 // Open a physical file
907 HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, 874 HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
908 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL); 875 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL);
909 if (file == NULL) return NULL; 876 if (file == NULL) return NULL;
910 // Create a file mapping for the physical file 877 // Create a file mapping for the physical file
911 HANDLE file_mapping = CreateFileMapping(file, NULL, 878 HANDLE file_mapping = CreateFileMapping(file, NULL,
912 PAGE_READWRITE, 0, static_cast<DWORD>(size), NULL); 879 PAGE_READWRITE, 0, static_cast<DWORD>(size), NULL);
913 if (file_mapping == NULL) return NULL; 880 if (file_mapping == NULL) return NULL;
914 // Map a view of the file into memory 881 // Map a view of the file into memory
915 void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size); 882 void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
916 if (memory) OS::MemMove(memory, initial, size); 883 if (memory) MemMove(memory, initial, size);
917 return new Win32MemoryMappedFile(file, file_mapping, memory, size); 884 return new Win32MemoryMappedFile(file, file_mapping, memory, size);
918 } 885 }
919 886
920 887
921 Win32MemoryMappedFile::~Win32MemoryMappedFile() { 888 Win32MemoryMappedFile::~Win32MemoryMappedFile() {
922 if (memory_ != NULL) 889 if (memory_ != NULL)
923 UnmapViewOfFile(memory_); 890 UnmapViewOfFile(memory_);
924 CloseHandle(file_mapping_); 891 CloseHandle(file_mapping_);
925 CloseHandle(file_); 892 CloseHandle(file_);
926 } 893 }
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 ASSERT(result); 1389 ASSERT(result);
1423 } 1390 }
1424 1391
1425 1392
1426 1393
1427 void Thread::YieldCPU() { 1394 void Thread::YieldCPU() {
1428 Sleep(0); 1395 Sleep(0);
1429 } 1396 }
1430 1397
1431 } } // namespace v8::internal 1398 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-posix.cc ('k') | src/preparse-data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698