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

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

Issue 7353017: 2011-07-13: Version 3.4.12 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 5 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-tls.h ('k') | src/profile-generator.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 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 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 return NULL; 733 return NULL;
734 } 734 }
735 } 735 }
736 736
737 737
738 bool OS::Remove(const char* path) { 738 bool OS::Remove(const char* path) {
739 return (DeleteFileA(path) != 0); 739 return (DeleteFileA(path) != 0);
740 } 740 }
741 741
742 742
743 FILE* OS::OpenTemporaryFile() {
744 // tmpfile_s tries to use the root dir, don't use it.
745 char tempPathBuffer[MAX_PATH];
746 DWORD path_result = 0;
747 path_result = GetTempPathA(MAX_PATH, tempPathBuffer);
748 if (path_result > MAX_PATH || path_result == 0) return NULL;
749 UINT name_result = 0;
750 char tempNameBuffer[MAX_PATH];
751 name_result = GetTempFileNameA(tempPathBuffer, "", 0, tempNameBuffer);
752 if (name_result == 0) return NULL;
753 FILE* result = FOpen(tempNameBuffer, "w+"); // Same mode as tmpfile uses.
754 if (result != NULL) {
755 Remove(tempNameBuffer); // Delete on close.
756 }
757 return result;
758 }
759
760
743 // Open log file in binary mode to avoid /n -> /r/n conversion. 761 // Open log file in binary mode to avoid /n -> /r/n conversion.
744 const char* const OS::LogFileOpenMode = "wb"; 762 const char* const OS::LogFileOpenMode = "wb";
745 763
746 764
747 // Print (debug) message to console. 765 // Print (debug) message to console.
748 void OS::Print(const char* format, ...) { 766 void OS::Print(const char* format, ...) {
749 va_list args; 767 va_list args;
750 va_start(args, format); 768 va_start(args, format);
751 VPrint(format, args); 769 VPrint(format, args);
752 va_end(args); 770 va_end(args);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 } 950 }
933 951
934 952
935 void OS::Free(void* address, const size_t size) { 953 void OS::Free(void* address, const size_t size) {
936 // TODO(1240712): VirtualFree has a return value which is ignored here. 954 // TODO(1240712): VirtualFree has a return value which is ignored here.
937 VirtualFree(address, 0, MEM_RELEASE); 955 VirtualFree(address, 0, MEM_RELEASE);
938 USE(size); 956 USE(size);
939 } 957 }
940 958
941 959
942 #ifdef ENABLE_HEAP_PROTECTION
943
944 void OS::Protect(void* address, size_t size) {
945 // TODO(1240712): VirtualProtect has a return value which is ignored here.
946 DWORD old_protect;
947 VirtualProtect(address, size, PAGE_READONLY, &old_protect);
948 }
949
950
951 void OS::Unprotect(void* address, size_t size, bool is_executable) {
952 // TODO(1240712): VirtualProtect has a return value which is ignored here.
953 DWORD new_protect = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
954 DWORD old_protect;
955 VirtualProtect(address, size, new_protect, &old_protect);
956 }
957
958 #endif
959
960
961 void OS::Sleep(int milliseconds) { 960 void OS::Sleep(int milliseconds) {
962 ::Sleep(milliseconds); 961 ::Sleep(milliseconds);
963 } 962 }
964 963
965 964
966 void OS::Abort() { 965 void OS::Abort() {
967 if (!IsDebuggerPresent()) { 966 if (!IsDebuggerPresent()) {
968 #ifdef _MSC_VER 967 #ifdef _MSC_VER
969 // Make the MSVCRT do a silent abort. 968 // Make the MSVCRT do a silent abort.
970 _set_abort_behavior(0, _WRITE_ABORT_MSG); 969 _set_abort_behavior(0, _WRITE_ABORT_MSG);
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 uint32_t Socket::NToH(uint32_t value) { 1850 uint32_t Socket::NToH(uint32_t value) {
1852 return ntohl(value); 1851 return ntohl(value);
1853 } 1852 }
1854 1853
1855 1854
1856 Socket* OS::CreateSocket() { 1855 Socket* OS::CreateSocket() {
1857 return new Win32Socket(); 1856 return new Win32Socket();
1858 } 1857 }
1859 1858
1860 1859
1861 #ifdef ENABLE_LOGGING_AND_PROFILING
1862
1863 // ---------------------------------------------------------------------------- 1860 // ----------------------------------------------------------------------------
1864 // Win32 profiler support. 1861 // Win32 profiler support.
1865 1862
1866 class Sampler::PlatformData : public Malloced { 1863 class Sampler::PlatformData : public Malloced {
1867 public: 1864 public:
1868 // Get a handle to the calling thread. This is the thread that we are 1865 // Get a handle to the calling thread. This is the thread that we are
1869 // going to profile. We need to make a copy of the handle because we are 1866 // going to profile. We need to make a copy of the handle because we are
1870 // going to use it in the sampler thread. Using GetThreadHandle() will 1867 // going to use it in the sampler thread. Using GetThreadHandle() will
1871 // not work in this case. We're using OpenThread because DuplicateHandle 1868 // not work in this case. We're using OpenThread because DuplicateHandle
1872 // for some reason doesn't work in Chrome's sandbox. 1869 // for some reason doesn't work in Chrome's sandbox.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 SamplerThread::AddActiveSampler(this); 2024 SamplerThread::AddActiveSampler(this);
2028 } 2025 }
2029 2026
2030 2027
2031 void Sampler::Stop() { 2028 void Sampler::Stop() {
2032 ASSERT(IsActive()); 2029 ASSERT(IsActive());
2033 SamplerThread::RemoveActiveSampler(this); 2030 SamplerThread::RemoveActiveSampler(this);
2034 SetActive(false); 2031 SetActive(false);
2035 } 2032 }
2036 2033
2037 #endif // ENABLE_LOGGING_AND_PROFILING
2038 2034
2039 } } // namespace v8::internal 2035 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-tls.h ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698