* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ #ifndef OS_WINDOWS_VM_INTERFACESUPPORT_WINDOWS_HPP #define OS_WINDOWS_VM_INTERFACESUPPORT_WINDOWS_HPP // Contains inlined functions for class InterfaceSupport static inline void serialize_memory(JavaThread *thread) { // due to chained nature of SEH handlers we have to be sure // that our handler is always last handler before an attempt to write // into serialization page - it can fault if we access this page // right in the middle of protect/unprotect sequence by remote // membar logic. // __try/__except are very lightweight operations (only several // instructions not affecting control flow directly on x86) // so we can use it here, on very time critical path __try { os::write_memory_serialize_page(thread); } __except (os::win32:: serialize_fault_filter((_EXCEPTION_POINTERS*)_exception_info())) {} } #endif // OS_WINDOWS_VM_INTERFACESUPPORT_WINDOWS_HPP
__declspec(dllexport) int WINAPI Win32Main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { HRESULT hr; // seed the random number generator with the current time // (GetTickCount may be semi-predictable on server startup, so we add the // clock time to shake things up a bit) srand(GetTickCount() + (int)time(NULL)); // mmf why is this done? // shift the stack locals and the heap by a random amount. char* pzSpacer = new char[4 * (int)random(21, 256)]; pzSpacer[0] = *(char*)_alloca(4 * (int)random(1, 256)); __try { do { #ifdef SRVLOG InitializeDebugf(); #endif InitializeLogchat(); // mmf BreakOnError(hr = Window::StaticInitialize()); // BUILD_DX9 - KGJV use runtime dynamic instead at preprocessor level if (g_papp->IsBuildDX9()) { BreakOnError(hr = g_papp->Initialize(lpszCmdLine)); } else { // Don't throw an error, if the user selects cancel it can return E_FAIL. hr = g_papp->Initialize(lpszCmdLine); } // BUILD_DX9 // // Win32App::Initialize() return S_FALSE if this is a command line app and // we shouldn't run the message loop // if (SUCCEEDED(hr) && S_FALSE != hr) { Window::MessageLoop(); } g_papp->Terminate(); Window::StaticTerminate(); #ifdef SRVLOG TerminateDebugf(); #endif TerminateLogchat(); // mmf } while (false); } __except (g_papp->OnException(_exception_code(), (ExceptionData*)_exception_info())){ } delete pzSpacer; return 0; }