< prev index next >

src/os/windows/vm/perfMemory_windows.cpp

Print this page


   1 /*
   2  * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/vmSymbols.hpp"

  27 #include "memory/allocation.inline.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "os_windows.inline.hpp"
  31 #include "runtime/handles.inline.hpp"
  32 #include "runtime/os.hpp"
  33 #include "runtime/perfMemory.hpp"
  34 #include "services/memTracker.hpp"
  35 #include "utilities/exceptions.hpp"
  36 
  37 #include <windows.h>
  38 #include <sys/types.h>
  39 #include <sys/stat.h>
  40 #include <errno.h>
  41 #include <lmcons.h>
  42 
  43 typedef BOOL (WINAPI *SetSecurityDescriptorControlFnPtr)(
  44    IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  45    IN SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
  46    IN SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet);


1678     if (PrintMiscellaneous && Verbose) {
1679       warning("MapViewOfFile failed, lasterror = %d\n", GetLastError());
1680     }
1681     CloseHandle(fmh);
1682     THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(),
1683               "Could not map PerfMemory");
1684   }
1685 
1686   // it does not go through os api, the operation has to record from here
1687   MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, size,
1688     CURRENT_PC, mtInternal);
1689 
1690 
1691   *addrp = (char*)mapAddress;
1692   *sizep = size;
1693 
1694   // File mapping object can be closed at this time without
1695   // invalidating the mapped view of the file
1696   CloseHandle(fmh);
1697 
1698   if (PerfTraceMemOps) {
1699     tty->print("mapped " SIZE_FORMAT " bytes for vmid %d at "
1700                INTPTR_FORMAT "\n", size, vmid, mapAddress);
1701   }
1702 }
1703 
1704 // this method unmaps the the mapped view of the the
1705 // file mapping object.
1706 //
1707 static void remove_file_mapping(char* addr) {
1708 
1709   // the file mapping object was closed in open_file_mapping()
1710   // after the file map view was created. We only need to
1711   // unmap the file view here.
1712   UnmapViewOfFile(addr);
1713 }
1714 
1715 // create the PerfData memory region in shared memory.
1716 static char* create_shared_memory(size_t size) {
1717 
1718   return mapping_create_shared(size);
1719 }
1720 
1721 // release a named, shared memory region


   1 /*
   2  * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/vmSymbols.hpp"
  27 #include "logging/log.hpp"
  28 #include "memory/allocation.inline.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "os_windows.inline.hpp"
  32 #include "runtime/handles.inline.hpp"
  33 #include "runtime/os.hpp"
  34 #include "runtime/perfMemory.hpp"
  35 #include "services/memTracker.hpp"
  36 #include "utilities/exceptions.hpp"
  37 
  38 #include <windows.h>
  39 #include <sys/types.h>
  40 #include <sys/stat.h>
  41 #include <errno.h>
  42 #include <lmcons.h>
  43 
  44 typedef BOOL (WINAPI *SetSecurityDescriptorControlFnPtr)(
  45    IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  46    IN SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
  47    IN SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet);


1679     if (PrintMiscellaneous && Verbose) {
1680       warning("MapViewOfFile failed, lasterror = %d\n", GetLastError());
1681     }
1682     CloseHandle(fmh);
1683     THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(),
1684               "Could not map PerfMemory");
1685   }
1686 
1687   // it does not go through os api, the operation has to record from here
1688   MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, size,
1689     CURRENT_PC, mtInternal);
1690 
1691 
1692   *addrp = (char*)mapAddress;
1693   *sizep = size;
1694 
1695   // File mapping object can be closed at this time without
1696   // invalidating the mapped view of the file
1697   CloseHandle(fmh);
1698 
1699   log_debug(perf, memops)("mapped " SIZE_FORMAT " bytes for vmid %d at "

1700                           INTPTR_FORMAT "\n", size, vmid, mapAddress);

1701 }
1702 
1703 // this method unmaps the the mapped view of the the
1704 // file mapping object.
1705 //
1706 static void remove_file_mapping(char* addr) {
1707 
1708   // the file mapping object was closed in open_file_mapping()
1709   // after the file map view was created. We only need to
1710   // unmap the file view here.
1711   UnmapViewOfFile(addr);
1712 }
1713 
1714 // create the PerfData memory region in shared memory.
1715 static char* create_shared_memory(size_t size) {
1716 
1717   return mapping_create_shared(size);
1718 }
1719 
1720 // release a named, shared memory region


< prev index next >