1 /* |
1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 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. |
226 void report_fatal(const char* file, int line, const char* message) |
226 void report_fatal(const char* file, int line, const char* message) |
227 { |
227 { |
228 report_vm_error(file, line, "fatal error", message); |
228 report_vm_error(file, line, "fatal error", message); |
229 } |
229 } |
230 |
230 |
231 // Used by report_vm_out_of_memory to detect recursion. |
|
232 static jint _exiting_out_of_mem = 0; |
|
233 |
|
234 void report_vm_out_of_memory(const char* file, int line, size_t size, |
231 void report_vm_out_of_memory(const char* file, int line, size_t size, |
235 const char* message) { |
232 const char* message) { |
236 if (Debugging) return; |
233 if (Debugging) return; |
237 |
234 |
238 // We try to gather additional information for the first out of memory |
235 Thread* thread = ThreadLocalStorage::get_thread_slow(); |
239 // error only; gathering additional data might cause an allocation and a |
236 VMError(thread, file, line, size, message).report_and_die(); |
240 // recursive out_of_memory condition. |
237 |
241 |
238 // The UseOSErrorReporting option in report_and_die() may allow a return |
242 const jint exiting = 1; |
239 // to here. If so then we'll have to figure out how to handle it. |
243 // If we succeed in changing the value, we're the first one in. |
240 guarantee(false, "report_and_die() should not return here"); |
244 bool first_time_here = Atomic::xchg(exiting, &_exiting_out_of_mem) != exiting; |
|
245 |
|
246 if (first_time_here) { |
|
247 Thread* thread = ThreadLocalStorage::get_thread_slow(); |
|
248 VMError(thread, file, line, size, message).report_and_die(); |
|
249 } |
|
250 |
|
251 // Dump core and abort |
|
252 vm_abort(true); |
|
253 } |
241 } |
254 |
242 |
255 void report_should_not_call(const char* file, int line) { |
243 void report_should_not_call(const char* file, int line) { |
256 report_vm_error(file, line, "ShouldNotCall()"); |
244 report_vm_error(file, line, "ShouldNotCall()"); |
257 } |
245 } |