Thu, 20 Nov 2008 16:56:09 -0800
6684579: SoftReference processing can be made more efficient
Summary: For current soft-ref clearing policies, we can decide at marking time if a soft-reference will definitely not be cleared, postponing the decision of whether it will definitely be cleared to the final reference processing phase. This can be especially beneficial in the case of concurrent collectors where the marking is usually concurrent but reference processing is usually not.
Reviewed-by: jmasa
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | // assertions |
duke@435 | 26 | #ifdef ASSERT |
duke@435 | 27 | // Turn this off by default: |
duke@435 | 28 | //#define USE_REPEATED_ASSERTS |
duke@435 | 29 | #ifdef USE_REPEATED_ASSERTS |
duke@435 | 30 | #define assert(p,msg) \ |
duke@435 | 31 | { for (int __i = 0; __i < AssertRepeat; __i++) { \ |
duke@435 | 32 | if (!(p)) { \ |
duke@435 | 33 | report_assertion_failure(__FILE__, __LINE__, \ |
duke@435 | 34 | "assert(" XSTR(p) ",\"" msg "\")");\ |
duke@435 | 35 | BREAKPOINT; \ |
duke@435 | 36 | } \ |
duke@435 | 37 | } \ |
duke@435 | 38 | } |
duke@435 | 39 | #else |
duke@435 | 40 | #define assert(p,msg) \ |
duke@435 | 41 | if (!(p)) { \ |
duke@435 | 42 | report_assertion_failure(__FILE__, __LINE__, \ |
duke@435 | 43 | "assert(" XSTR(p) ",\"" msg "\")");\ |
duke@435 | 44 | BREAKPOINT; \ |
duke@435 | 45 | } |
duke@435 | 46 | #endif |
duke@435 | 47 | |
duke@435 | 48 | // This version of assert is for use with checking return status from |
duke@435 | 49 | // library calls that return actual error values eg. EINVAL, |
duke@435 | 50 | // ENOMEM etc, rather than returning -1 and setting errno. |
duke@435 | 51 | // When the status is not what is expected it is very useful to know |
duke@435 | 52 | // what status was actually returned, so we pass the status variable as |
duke@435 | 53 | // an extra arg and use strerror to convert it to a meaningful string |
duke@435 | 54 | // like "Invalid argument", "out of memory" etc |
duke@435 | 55 | #define assert_status(p, status, msg) \ |
duke@435 | 56 | do { \ |
duke@435 | 57 | if (!(p)) { \ |
duke@435 | 58 | char buf[128]; \ |
duke@435 | 59 | snprintf(buf, 127, \ |
duke@435 | 60 | "assert_status(" XSTR(p) ", error: %s(%d), \"" msg "\")" , \ |
duke@435 | 61 | strerror((status)), (status)); \ |
duke@435 | 62 | report_assertion_failure(__FILE__, __LINE__, buf); \ |
duke@435 | 63 | BREAKPOINT; \ |
duke@435 | 64 | } \ |
duke@435 | 65 | } while (0) |
duke@435 | 66 | |
duke@435 | 67 | // Another version of assert where the message is not a string literal |
duke@435 | 68 | // The boolean condition is not printed out because cpp doesn't like it. |
duke@435 | 69 | #define assert_msg(p, msg) \ |
duke@435 | 70 | if (!(p)) { \ |
duke@435 | 71 | report_assertion_failure(__FILE__, __LINE__, msg); \ |
duke@435 | 72 | BREAKPOINT; \ |
duke@435 | 73 | } |
duke@435 | 74 | |
duke@435 | 75 | // Do not assert this condition if there's already another error reported. |
duke@435 | 76 | #define assert_if_no_error(cond,msg) assert((cond) || is_error_reported(), msg) |
duke@435 | 77 | #else |
duke@435 | 78 | #define assert(p,msg) |
duke@435 | 79 | #define assert_status(p,status,msg) |
duke@435 | 80 | #define assert_if_no_error(cond,msg) |
duke@435 | 81 | #define assert_msg(cond,msg) |
duke@435 | 82 | #endif |
duke@435 | 83 | |
duke@435 | 84 | |
duke@435 | 85 | // fatals |
duke@435 | 86 | #define fatal(m) { report_fatal(__FILE__, __LINE__, m ); BREAKPOINT; } |
duke@435 | 87 | #define fatal1(m,x1) { report_fatal_vararg(__FILE__, __LINE__, m, x1 ); BREAKPOINT; } |
duke@435 | 88 | #define fatal2(m,x1,x2) { report_fatal_vararg(__FILE__, __LINE__, m, x1, x2 ); BREAKPOINT; } |
duke@435 | 89 | #define fatal3(m,x1,x2,x3) { report_fatal_vararg(__FILE__, __LINE__, m, x1, x2, x3 ); BREAKPOINT; } |
duke@435 | 90 | #define fatal4(m,x1,x2,x3,x4) { report_fatal_vararg(__FILE__, __LINE__, m, x1, x2, x3, x4 ); BREAKPOINT; } |
duke@435 | 91 | |
duke@435 | 92 | // out of memory |
duke@435 | 93 | #define vm_exit_out_of_memory(s,m) { report_vm_out_of_memory(__FILE__, __LINE__, s, m ); BREAKPOINT; } |
duke@435 | 94 | #define vm_exit_out_of_memory1(s,m,x1) { report_vm_out_of_memory_vararg(__FILE__, __LINE__, s, m, x1 ); BREAKPOINT; } |
duke@435 | 95 | #define vm_exit_out_of_memory2(s,m,x1,x2) { report_vm_out_of_memory_vararg(__FILE__, __LINE__, s, m, x1, x2 ); BREAKPOINT; } |
duke@435 | 96 | #define vm_exit_out_of_memory3(s,m,x1,x2,x3) { report_vm_out_of_memory_vararg(__FILE__, __LINE__, s, m, x1, x2, x3 ); BREAKPOINT; } |
duke@435 | 97 | #define vm_exit_out_of_memory4(s,m,x1,x2,x3,x4) { report_vm_out_of_memory_vararg(__FILE__, __LINE__, s, m, x1, x2, x3, x4); BREAKPOINT; } |
duke@435 | 98 | |
duke@435 | 99 | // guarantee is like assert except it's always executed -- use it for |
duke@435 | 100 | // cheap tests that catch errors that would otherwise be hard to find |
duke@435 | 101 | // guarantee is also used for Verify options. |
duke@435 | 102 | #define guarantee(b,msg) { if (!(b)) fatal("guarantee(" XSTR(b) ",\"" msg "\")"); } |
duke@435 | 103 | |
duke@435 | 104 | #define ShouldNotCallThis() { report_should_not_call (__FILE__, __LINE__); BREAKPOINT; } |
duke@435 | 105 | #define ShouldNotReachHere() { report_should_not_reach_here (__FILE__, __LINE__); BREAKPOINT; } |
duke@435 | 106 | #define Unimplemented() { report_unimplemented (__FILE__, __LINE__); BREAKPOINT; } |
duke@435 | 107 | #define Untested(msg) { report_untested (__FILE__, __LINE__, msg); BREAKPOINT; } |
duke@435 | 108 | |
duke@435 | 109 | // error reporting helper functions |
duke@435 | 110 | void report_assertion_failure(const char* file_name, int line_no, const char* message); |
duke@435 | 111 | void report_fatal_vararg(const char* file_name, int line_no, const char* format, ...); |
duke@435 | 112 | void report_fatal(const char* file_name, int line_no, const char* message); |
duke@435 | 113 | void report_vm_out_of_memory_vararg(const char* file_name, int line_no, size_t size, const char* format, ...); |
duke@435 | 114 | void report_vm_out_of_memory(const char* file_name, int line_no, size_t size, const char* message); |
duke@435 | 115 | void report_should_not_call(const char* file_name, int line_no); |
duke@435 | 116 | void report_should_not_reach_here(const char* file_name, int line_no); |
duke@435 | 117 | void report_unimplemented(const char* file_name, int line_no); |
duke@435 | 118 | void report_untested(const char* file_name, int line_no, const char* msg); |
duke@435 | 119 | void warning(const char* format, ...); |
duke@435 | 120 | |
duke@435 | 121 | // out of memory reporting |
duke@435 | 122 | void report_java_out_of_memory(const char* message); |
duke@435 | 123 | |
duke@435 | 124 | // Support for self-destruct |
duke@435 | 125 | bool is_error_reported(); |
duke@435 | 126 | void set_error_reported(); |
duke@435 | 127 | |
duke@435 | 128 | void pd_ps(frame f); |
duke@435 | 129 | void pd_obfuscate_location(char *buf, size_t buflen); |