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

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

Issue 297303004: Revert 21502 - "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
110 class TimezoneCache { 133 class TimezoneCache {
111 public: 134 public:
112 TimezoneCache() : initialized_(false) { } 135 TimezoneCache() : initialized_(false) { }
113 136
114 void Clear() { 137 void Clear() {
115 initialized_ = false; 138 initialized_ = false;
116 } 139 }
117 140
118 // Initialize timezone information. The timezone information is obtained from 141 // Initialize timezone information. The timezone information is obtained from
119 // windows. If we cannot get the timezone information we fall back to CET. 142 // 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
422 445
423 // Returns a string identifying the current timezone for the 446 // Returns a string identifying the current timezone for the
424 // timestamp taking into account daylight saving. 447 // timestamp taking into account daylight saving.
425 char* Win32Time::LocalTimezone(TimezoneCache* cache) { 448 char* Win32Time::LocalTimezone(TimezoneCache* cache) {
426 // Return the standard or DST time zone name based on whether daylight 449 // Return the standard or DST time zone name based on whether daylight
427 // saving is in effect at the given time. 450 // saving is in effect at the given time.
428 return InDST(cache) ? cache->dst_tz_name_ : cache->std_tz_name_; 451 return InDST(cache) ? cache->dst_tz_name_ : cache->std_tz_name_;
429 } 452 }
430 453
431 454
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
432 // Returns the accumulated user time for thread. 465 // Returns the accumulated user time for thread.
433 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { 466 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
434 FILETIME dummy; 467 FILETIME dummy;
435 uint64_t usertime; 468 uint64_t usertime;
436 469
437 // Get the amount of time that the thread has executed in user mode. 470 // Get the amount of time that the thread has executed in user mode.
438 if (!GetThreadTimes(GetCurrentThread(), &dummy, &dummy, &dummy, 471 if (!GetThreadTimes(GetCurrentThread(), &dummy, &dummy, &dummy,
439 reinterpret_cast<FILETIME*>(&usertime))) return -1; 472 reinterpret_cast<FILETIME*>(&usertime))) return -1;
440 473
441 // Adjust the resolution to micro-seconds. 474 // Adjust the resolution to micro-seconds.
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 // Open a physical file 906 // Open a physical file
874 HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, 907 HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
875 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL); 908 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL);
876 if (file == NULL) return NULL; 909 if (file == NULL) return NULL;
877 // Create a file mapping for the physical file 910 // Create a file mapping for the physical file
878 HANDLE file_mapping = CreateFileMapping(file, NULL, 911 HANDLE file_mapping = CreateFileMapping(file, NULL,
879 PAGE_READWRITE, 0, static_cast<DWORD>(size), NULL); 912 PAGE_READWRITE, 0, static_cast<DWORD>(size), NULL);
880 if (file_mapping == NULL) return NULL; 913 if (file_mapping == NULL) return NULL;
881 // Map a view of the file into memory 914 // Map a view of the file into memory
882 void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size); 915 void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
883 if (memory) MemMove(memory, initial, size); 916 if (memory) OS::MemMove(memory, initial, size);
884 return new Win32MemoryMappedFile(file, file_mapping, memory, size); 917 return new Win32MemoryMappedFile(file, file_mapping, memory, size);
885 } 918 }
886 919
887 920
888 Win32MemoryMappedFile::~Win32MemoryMappedFile() { 921 Win32MemoryMappedFile::~Win32MemoryMappedFile() {
889 if (memory_ != NULL) 922 if (memory_ != NULL)
890 UnmapViewOfFile(memory_); 923 UnmapViewOfFile(memory_);
891 CloseHandle(file_mapping_); 924 CloseHandle(file_mapping_);
892 CloseHandle(file_); 925 CloseHandle(file_);
893 } 926 }
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 ASSERT(result); 1429 ASSERT(result);
1397 } 1430 }
1398 1431
1399 1432
1400 1433
1401 void Thread::YieldCPU() { 1434 void Thread::YieldCPU() {
1402 Sleep(0); 1435 Sleep(0);
1403 } 1436 }
1404 1437
1405 } } // namespace v8::internal 1438 } } // 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