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

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

Issue 328993003: Drop dependency on Isolate* from platform.h (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 6 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-solaris.cc ('k') | no next file » | 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 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 // application is closed. 1051 // application is closed.
1052 } 1052 }
1053 1053
1054 #undef DBGHELP_FUNCTION_LIST 1054 #undef DBGHELP_FUNCTION_LIST
1055 #undef TLHELP32_FUNCTION_LIST 1055 #undef TLHELP32_FUNCTION_LIST
1056 #undef DLL_FUNC_VAR 1056 #undef DLL_FUNC_VAR
1057 #undef DLL_FUNC_TYPE 1057 #undef DLL_FUNC_TYPE
1058 1058
1059 1059
1060 // Load the symbols for generating stack traces. 1060 // Load the symbols for generating stack traces.
1061 static bool LoadSymbols(Isolate* isolate, HANDLE process_handle) { 1061 static std::vector<OS::SharedLibraryAddress> LoadSymbols(
1062 HANDLE process_handle) {
1063 static std::vector<OS::SharedLibraryAddress> result;
1064
1062 static bool symbols_loaded = false; 1065 static bool symbols_loaded = false;
1063 1066
1064 if (symbols_loaded) return true; 1067 if (symbols_loaded) return result;
1065 1068
1066 BOOL ok; 1069 BOOL ok;
1067 1070
1068 // Initialize the symbol engine. 1071 // Initialize the symbol engine.
1069 ok = _SymInitialize(process_handle, // hProcess 1072 ok = _SymInitialize(process_handle, // hProcess
1070 NULL, // UserSearchPath 1073 NULL, // UserSearchPath
1071 false); // fInvadeProcess 1074 false); // fInvadeProcess
1072 if (!ok) return false; 1075 if (!ok) return result;
1073 1076
1074 DWORD options = _SymGetOptions(); 1077 DWORD options = _SymGetOptions();
1075 options |= SYMOPT_LOAD_LINES; 1078 options |= SYMOPT_LOAD_LINES;
1076 options |= SYMOPT_FAIL_CRITICAL_ERRORS; 1079 options |= SYMOPT_FAIL_CRITICAL_ERRORS;
1077 options = _SymSetOptions(options); 1080 options = _SymSetOptions(options);
1078 1081
1079 char buf[OS::kStackWalkMaxNameLen] = {0}; 1082 char buf[OS::kStackWalkMaxNameLen] = {0};
1080 ok = _SymGetSearchPath(process_handle, buf, OS::kStackWalkMaxNameLen); 1083 ok = _SymGetSearchPath(process_handle, buf, OS::kStackWalkMaxNameLen);
1081 if (!ok) { 1084 if (!ok) {
1082 int err = GetLastError(); 1085 int err = GetLastError();
1083 PrintF("%d\n", err); 1086 PrintF("%d\n", err);
1084 return false; 1087 return result;
1085 } 1088 }
1086 1089
1087 HANDLE snapshot = _CreateToolhelp32Snapshot( 1090 HANDLE snapshot = _CreateToolhelp32Snapshot(
1088 TH32CS_SNAPMODULE, // dwFlags 1091 TH32CS_SNAPMODULE, // dwFlags
1089 GetCurrentProcessId()); // th32ProcessId 1092 GetCurrentProcessId()); // th32ProcessId
1090 if (snapshot == INVALID_HANDLE_VALUE) return false; 1093 if (snapshot == INVALID_HANDLE_VALUE) return result;
1091 MODULEENTRY32W module_entry; 1094 MODULEENTRY32W module_entry;
1092 module_entry.dwSize = sizeof(module_entry); // Set the size of the structure. 1095 module_entry.dwSize = sizeof(module_entry); // Set the size of the structure.
1093 BOOL cont = _Module32FirstW(snapshot, &module_entry); 1096 BOOL cont = _Module32FirstW(snapshot, &module_entry);
1094 while (cont) { 1097 while (cont) {
1095 DWORD64 base; 1098 DWORD64 base;
1096 // NOTE the SymLoadModule64 function has the peculiarity of accepting a 1099 // NOTE the SymLoadModule64 function has the peculiarity of accepting a
1097 // both unicode and ASCII strings even though the parameter is PSTR. 1100 // both unicode and ASCII strings even though the parameter is PSTR.
1098 base = _SymLoadModule64( 1101 base = _SymLoadModule64(
1099 process_handle, // hProcess 1102 process_handle, // hProcess
1100 0, // hFile 1103 0, // hFile
1101 reinterpret_cast<PSTR>(module_entry.szExePath), // ImageName 1104 reinterpret_cast<PSTR>(module_entry.szExePath), // ImageName
1102 reinterpret_cast<PSTR>(module_entry.szModule), // ModuleName 1105 reinterpret_cast<PSTR>(module_entry.szModule), // ModuleName
1103 reinterpret_cast<DWORD64>(module_entry.modBaseAddr), // BaseOfDll 1106 reinterpret_cast<DWORD64>(module_entry.modBaseAddr), // BaseOfDll
1104 module_entry.modBaseSize); // SizeOfDll 1107 module_entry.modBaseSize); // SizeOfDll
1105 if (base == 0) { 1108 if (base == 0) {
1106 int err = GetLastError(); 1109 int err = GetLastError();
1107 if (err != ERROR_MOD_NOT_FOUND && 1110 if (err != ERROR_MOD_NOT_FOUND &&
1108 err != ERROR_INVALID_HANDLE) return false; 1111 err != ERROR_INVALID_HANDLE) {
1112 result.clear();
1113 return result;
1114 }
1109 } 1115 }
1110 LOG(isolate, 1116 int lib_name_length = WideCharToMultiByte(
1111 SharedLibraryEvent( 1117 CP_UTF8, 0, module_entry.szExePath, -1, NULL, 0, NULL, NULL);
1112 module_entry.szExePath, 1118 std::string lib_name(lib_name_length, 0);
1113 reinterpret_cast<unsigned int>(module_entry.modBaseAddr), 1119 WideCharToMultiByte(CP_UTF8, 0, module_entry.szExePath, -1, &lib_name[0],
1114 reinterpret_cast<unsigned int>(module_entry.modBaseAddr + 1120 lib_name_length, NULL, NULL);
1115 module_entry.modBaseSize))); 1121 result.push_back(OS::SharedLibraryAddress(
1122 lib_name, reinterpret_cast<unsigned int>(module_entry.modBaseAddr),
1123 reinterpret_cast<unsigned int>(module_entry.modBaseAddr +
1124 module_entry.modBaseSize)));
1116 cont = _Module32NextW(snapshot, &module_entry); 1125 cont = _Module32NextW(snapshot, &module_entry);
1117 } 1126 }
1118 CloseHandle(snapshot); 1127 CloseHandle(snapshot);
1119 1128
1120 symbols_loaded = true; 1129 symbols_loaded = true;
1121 return true; 1130 return result;
1122 } 1131 }
1123 1132
1124 1133
1125 void OS::LogSharedLibraryAddresses(Isolate* isolate) { 1134 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
1126 // SharedLibraryEvents are logged when loading symbol information. 1135 // SharedLibraryEvents are logged when loading symbol information.
1127 // Only the shared libraries loaded at the time of the call to 1136 // Only the shared libraries loaded at the time of the call to
1128 // LogSharedLibraryAddresses are logged. DLLs loaded after 1137 // GetSharedLibraryAddresses are logged. DLLs loaded after
1129 // initialization are not accounted for. 1138 // initialization are not accounted for.
1130 if (!LoadDbgHelpAndTlHelp32()) return; 1139 if (!LoadDbgHelpAndTlHelp32()) return std::vector<OS::SharedLibraryAddress>();
1131 HANDLE process_handle = GetCurrentProcess(); 1140 HANDLE process_handle = GetCurrentProcess();
1132 LoadSymbols(isolate, process_handle); 1141 return LoadSymbols(process_handle);
1133 } 1142 }
1134 1143
1135 1144
1136 void OS::SignalCodeMovingGC() { 1145 void OS::SignalCodeMovingGC() {
1137 } 1146 }
1138 1147
1139 1148
1140 uint64_t OS::TotalPhysicalMemory() { 1149 uint64_t OS::TotalPhysicalMemory() {
1141 MEMORYSTATUSEX memory_info; 1150 MEMORYSTATUSEX memory_info;
1142 memory_info.dwLength = sizeof(memory_info); 1151 memory_info.dwLength = sizeof(memory_info);
1143 if (!GlobalMemoryStatusEx(&memory_info)) { 1152 if (!GlobalMemoryStatusEx(&memory_info)) {
1144 UNREACHABLE(); 1153 UNREACHABLE();
1145 return 0; 1154 return 0;
1146 } 1155 }
1147 1156
1148 return static_cast<uint64_t>(memory_info.ullTotalPhys); 1157 return static_cast<uint64_t>(memory_info.ullTotalPhys);
1149 } 1158 }
1150 1159
1151 1160
1152 #else // __MINGW32__ 1161 #else // __MINGW32__
1153 void OS::LogSharedLibraryAddresses(Isolate* isolate) { } 1162 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
1163 return std::vector<OS::SharedLibraryAddress>();
1164 }
1165
1166
1154 void OS::SignalCodeMovingGC() { } 1167 void OS::SignalCodeMovingGC() { }
1155 #endif // __MINGW32__ 1168 #endif // __MINGW32__
1156 1169
1157 1170
1158 int OS::NumberOfProcessorsOnline() { 1171 int OS::NumberOfProcessorsOnline() {
1159 SYSTEM_INFO info; 1172 SYSTEM_INFO info;
1160 GetSystemInfo(&info); 1173 GetSystemInfo(&info);
1161 return info.dwNumberOfProcessors; 1174 return info.dwNumberOfProcessors;
1162 } 1175 }
1163 1176
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 ASSERT(result); 1401 ASSERT(result);
1389 } 1402 }
1390 1403
1391 1404
1392 1405
1393 void Thread::YieldCPU() { 1406 void Thread::YieldCPU() {
1394 Sleep(0); 1407 Sleep(0);
1395 } 1408 }
1396 1409
1397 } } // namespace v8::internal 1410 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-solaris.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698