Mercurial > hg > truffle
comparison src/os/solaris/vm/perfMemory_solaris.cpp @ 11198:1e6d5dec4a4e
Merge.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 05 Aug 2013 13:20:06 +0200 |
parents | 1f4355cee9a2 |
children | 2c2a99f6cf83 |
comparison
equal
deleted
inserted
replaced
11197:3479ab380552 | 11198:1e6d5dec4a4e |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
60 if (mapAddress == NULL) { | 60 if (mapAddress == NULL) { |
61 return NULL; | 61 return NULL; |
62 } | 62 } |
63 | 63 |
64 // commit memory | 64 // commit memory |
65 if (!os::commit_memory(mapAddress, size)) { | 65 if (!os::commit_memory(mapAddress, size, !ExecMem)) { |
66 if (PrintMiscellaneous && Verbose) { | 66 if (PrintMiscellaneous && Verbose) { |
67 warning("Could not commit PerfData memory\n"); | 67 warning("Could not commit PerfData memory\n"); |
68 } | 68 } |
69 os::release_memory(mapAddress, size); | 69 os::release_memory(mapAddress, size); |
70 return NULL; | 70 return NULL; |
120 } | 120 } |
121 remaining -= (size_t)result; | 121 remaining -= (size_t)result; |
122 addr += result; | 122 addr += result; |
123 } | 123 } |
124 | 124 |
125 RESTARTABLE(::close(fd), result); | 125 result = ::close(fd); |
126 if (PrintMiscellaneous && Verbose) { | 126 if (PrintMiscellaneous && Verbose) { |
127 if (result == OS_ERR) { | 127 if (result == OS_ERR) { |
128 warning("Could not close %s: %s\n", destfile, strerror(errno)); | 128 warning("Could not close %s: %s\n", destfile, strerror(errno)); |
129 } | 129 } |
130 } | 130 } |
435 } | 435 } |
436 remaining-=result; | 436 remaining-=result; |
437 addr+=result; | 437 addr+=result; |
438 } | 438 } |
439 | 439 |
440 RESTARTABLE(::close(fd), result); | 440 ::close(fd); |
441 | 441 |
442 // get the user name for the effective user id of the process | 442 // get the user name for the effective user id of the process |
443 char* user_name = get_user_name(psinfo.pr_euid); | 443 char* user_name = get_user_name(psinfo.pr_euid); |
444 | 444 |
445 return user_name; | 445 return user_name; |
667 RESTARTABLE(::ftruncate(fd, (off_t)size), result); | 667 RESTARTABLE(::ftruncate(fd, (off_t)size), result); |
668 if (result == OS_ERR) { | 668 if (result == OS_ERR) { |
669 if (PrintMiscellaneous && Verbose) { | 669 if (PrintMiscellaneous && Verbose) { |
670 warning("could not set shared memory file size: %s\n", strerror(errno)); | 670 warning("could not set shared memory file size: %s\n", strerror(errno)); |
671 } | 671 } |
672 RESTARTABLE(::close(fd), result); | 672 ::close(fd); |
673 return -1; | 673 return -1; |
674 } | 674 } |
675 | 675 |
676 return fd; | 676 return fd; |
677 } | 677 } |
747 return NULL; | 747 return NULL; |
748 } | 748 } |
749 | 749 |
750 mapAddress = (char*)::mmap((char*)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); | 750 mapAddress = (char*)::mmap((char*)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); |
751 | 751 |
752 // attempt to close the file - restart it if it was interrupted, | 752 result = ::close(fd); |
753 // but ignore other failures | |
754 RESTARTABLE(::close(fd), result); | |
755 assert(result != OS_ERR, "could not close file"); | 753 assert(result != OS_ERR, "could not close file"); |
756 | 754 |
757 if (mapAddress == MAP_FAILED) { | 755 if (mapAddress == MAP_FAILED) { |
758 if (PrintMiscellaneous && Verbose) { | 756 if (PrintMiscellaneous && Verbose) { |
759 warning("mmap failed - %s\n", strerror(errno)); | 757 warning("mmap failed - %s\n", strerror(errno)); |
768 | 766 |
769 // clear the shared memory region | 767 // clear the shared memory region |
770 (void)::memset((void*) mapAddress, 0, size); | 768 (void)::memset((void*) mapAddress, 0, size); |
771 | 769 |
772 // it does not go through os api, the operation has to record from here | 770 // it does not go through os api, the operation has to record from here |
773 MemTracker::record_virtual_memory_reserve((address)mapAddress, size, CURRENT_PC); | 771 MemTracker::record_virtual_memory_reserve((address)mapAddress, size, mtInternal, CURRENT_PC); |
774 MemTracker::record_virtual_memory_type((address)mapAddress, mtInternal); | |
775 | 772 |
776 return mapAddress; | 773 return mapAddress; |
777 } | 774 } |
778 | 775 |
779 // release a named shared memory region | 776 // release a named shared memory region |
920 | 917 |
921 assert(size > 0, "unexpected size <= 0"); | 918 assert(size > 0, "unexpected size <= 0"); |
922 | 919 |
923 mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0); | 920 mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0); |
924 | 921 |
925 // attempt to close the file - restart if it gets interrupted, | 922 result = ::close(fd); |
926 // but ignore other failures | |
927 RESTARTABLE(::close(fd), result); | |
928 assert(result != OS_ERR, "could not close file"); | 923 assert(result != OS_ERR, "could not close file"); |
929 | 924 |
930 if (mapAddress == MAP_FAILED) { | 925 if (mapAddress == MAP_FAILED) { |
931 if (PrintMiscellaneous && Verbose) { | 926 if (PrintMiscellaneous && Verbose) { |
932 warning("mmap failed: %s\n", strerror(errno)); | 927 warning("mmap failed: %s\n", strerror(errno)); |
934 THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), | 929 THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), |
935 "Could not map PerfMemory"); | 930 "Could not map PerfMemory"); |
936 } | 931 } |
937 | 932 |
938 // it does not go through os api, the operation has to record from here | 933 // it does not go through os api, the operation has to record from here |
939 MemTracker::record_virtual_memory_reserve((address)mapAddress, size, CURRENT_PC); | 934 MemTracker::record_virtual_memory_reserve((address)mapAddress, size, mtInternal, CURRENT_PC); |
940 MemTracker::record_virtual_memory_type((address)mapAddress, mtInternal); | |
941 | 935 |
942 *addr = mapAddress; | 936 *addr = mapAddress; |
943 *sizep = size; | 937 *sizep = size; |
944 | 938 |
945 if (PerfTraceMemOps) { | 939 if (PerfTraceMemOps) { |