(VM::abort_errnum, VM::abort_errno): Likewise.
* src/vm/vm.hpp (VM): Likewise.
* src/vm/os.cpp (os::abort): New function.
(os::abort_errnum, os::abort_errno): Likewise.
* src/vm/os.hpp (os): Likewise.
* src/mm/gc-boehm.cpp,
src/threads/posix/condition-posix.hpp,
src/threads/posix/mutex-posix.hpp,
src/threads/posix/thread-posix.hpp,
src/vm/assertion.cpp,
src/vm/exceptions.cpp,
src/vm/jit/optimizing/bytecode_escape.c,
src/vm/primitive.cpp,
src/vm/properties.cpp,
src/vm/string.cpp,
src/vm/suck.cpp: Related changes.
--HG--
branch : twisti
extra : transplant_source : %16%D8%F5%82%F2%E8%C1%DA%0D%A7T%A3%14%DA%EFgZ%98%98%CE
if (in_gc_out_of_memory) {
/* this is all we can do... */
- VM::get_current()->abort("gc_out_of_memory: out of memory");
+ os::abort("gc_out_of_memory: out of memory");
}
in_gc_out_of_memory = true;
#include <pthread.h>
#include <time.h>
-#include "vm/vm.hpp"
#ifdef __cplusplus
};
+// Includes.
+#include "vm/os.hpp"
+
+
/**
* Initialize a POSIX condition variable.
*/
result = pthread_cond_init(&_cond, NULL);
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Condition::Condition(): pthread_cond_init failed");
+ os::abort_errnum(result, "Condition::Condition(): pthread_cond_init failed");
}
}
result = pthread_cond_destroy(&_cond);
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Condition::~Condition(): pthread_cond_destroy failed");
+ os::abort_errnum(result, "Condition::~Condition(): pthread_cond_destroy failed");
}
}
result = pthread_cond_broadcast(&_cond);
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Condition::broadcast(): pthread_cond_broadcast failed");
+ os::abort_errnum(result, "Condition::broadcast(): pthread_cond_broadcast failed");
}
}
result = pthread_cond_signal(&_cond);
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Condition::signal(): pthread_cond_signal failed");
+ os::abort_errnum(result, "Condition::signal(): pthread_cond_signal failed");
}
}
result = pthread_cond_wait(&_cond, &(mutex->_mutex));
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Condition::wait(): pthread_cond_wait failed");
+ os::abort_errnum(result, "Condition::wait(): pthread_cond_wait failed");
}
}
// Includes.
-#include "vm/vm.hpp"
+#include "vm/os.hpp"
#ifdef __cplusplus
int result = pthread_mutexattr_init(&_attr);
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Mutex::Mutex(): pthread_mutexattr_init failed");
+ os::abort_errnum(result, "Mutex::Mutex(): pthread_mutexattr_init failed");
}
result = pthread_mutexattr_settype(&_attr, PTHREAD_MUTEX_RECURSIVE);
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Mutex::Mutex(): pthread_mutexattr_settype failed");
+ os::abort_errnum(result, "Mutex::Mutex(): pthread_mutexattr_settype failed");
}
result = pthread_mutex_init(&_mutex, &_attr);
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Mutex::Mutex(): pthread_mutex_init failed");
+ os::abort_errnum(result, "Mutex::Mutex(): pthread_mutex_init failed");
}
}
int result = pthread_mutexattr_destroy(&_attr);
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Mutex::~Mutex(): pthread_mutexattr_destroy failed");
+ os::abort_errnum(result, "Mutex::~Mutex(): pthread_mutexattr_destroy failed");
}
result = pthread_mutex_destroy(&_mutex);
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Mutex::~Mutex(): pthread_mutex_destroy failed");
+ os::abort_errnum(result, "Mutex::~Mutex(): pthread_mutex_destroy failed");
}
}
int result = pthread_mutex_lock(&_mutex);
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Mutex::lock(): pthread_mutex_lock failed");
+ os::abort_errnum(result, "Mutex::lock(): pthread_mutex_lock failed");
}
}
int result = pthread_mutex_unlock(&_mutex);
if (result != 0) {
- VM::get_current()->abort_errnum(result, "Mutex::unlock: pthread_mutex_unlock failed");
+ os::abort_errnum(result, "Mutex::unlock: pthread_mutex_unlock failed");
}
}
#include "threads/condition.hpp"
#include "threads/mutex.hpp"
+#include "toolbox/list.h"
+
+#include "vm/global.h"
+
/* threadobject ****************************************************************
#include "vm/assertion.hpp"
#include "vm/global.h"
#include "vm/os.hpp"
-#include "vm/vm.hpp"
/* -ea/-da options ************************************************************/
buf = os::strdup(name);
if (buf == NULL) {
- VM::get_current()->abort_errno("assertion_ea_da: strdup failed");
+ os::abort_errno("assertion_ea_da: strdup failed");
}
if ((len > 2) && (strcmp(name + (len - 3), "...") == 0)) {
log_finish();
- VM::get_current()->abort("Aborting...");
+ os::abort("Aborting...");
}
false);
if (m == NULL)
- VM::get_current()->abort("exceptions_print_stacktrace: printStackTrace()V not found");
+ os::abort("exceptions_print_stacktrace: printStackTrace()V not found");
/* Print message. */
#include "vm/references.h"
#include "vm/resolve.h"
-#include "vm/jit/ir/bytecode.hpp"
+#include "vm/jit/ir/bytecode.h"
#include "vm/jit/optimizing/escape.h"
#include <assert.h>
#include "vm/vm.hpp"
+/**
+ * Prints an error message and aborts the VM.
+ *
+ * @param text Error message to print.
+ */
+void os::abort(const char* text, ...)
+{
+ va_list ap;
+
+ // Print the log message.
+ log_start();
+
+ va_start(ap, text);
+ log_vprint(text, ap);
+ va_end(ap);
+
+ log_finish();
+
+ // Print a backtrace.
+ os::print_backtrace();
+
+ // Now abort the VM.
+ os::abort();
+}
+
+
+/**
+ * Prints an error message, appends ":" plus the strerror-message of
+ * errnum and aborts the VM.
+ *
+ * @param errnum Error number.
+ * @param text Error message to print.
+ */
+void os::abort_errnum(int errnum, const char* text, ...)
+{
+ va_list ap;
+
+ // Print the log message.
+ log_start();
+
+ va_start(ap, text);
+ log_vprint(text, ap);
+ va_end(ap);
+
+ // Print the strerror-message of errnum.
+ log_print(": %s", os::strerror(errnum));
+
+ log_finish();
+
+ // Print a backtrace.
+ os::print_backtrace();
+
+ // Now abort the VM.
+ os::abort();
+}
+
+
+/**
+ * Equal to abort_errnum, but uses errno to get the error number.
+ *
+ * @param text Error message to print.
+ */
+void os::abort_errno(const char* text, ...)
+{
+ va_list ap;
+
+ va_start(ap, text);
+ abort_errnum(errno, text, ap);
+ va_end(ap);
+}
+
+
/**
* Maps anonymous memory, even on systems not defining
* MAP_ANON(YMOUS).
fd = open("/dev/zero", O_RDONLY, 0);
if (fd == -1)
- VM::get_current()->abort_errno("os::mmap_anonymous: open failed");
+ os::abort_errno("os::mmap_anonymous: open failed");
p = mmap(addr, len, prot, flags, fd, 0);
#endif
#else
if (p == (void *) -1)
#endif
- VM::get_current()->abort_errno("os::mmap_anonymous: mmap failed");
+ os::abort_errno("os::mmap_anonymous: mmap failed");
return p;
}
static inline char* strerror(int errnum);
// Convenience functions.
+ static void abort(const char* text, ...);
+ static void abort_errnum(int errnum, const char* text, ...);
+ static void abort_errno(const char* text, ...);
static void* mmap_anonymous(void *addr, size_t len, int prot, int flags);
static void print_backtrace();
static int processors_online();
#include "vm/globals.hpp"
#include "vm/javaobjects.hpp"
#include "vm/options.h"
+#include "vm/os.hpp"
#include "vm/primitive.hpp"
#include "vm/utf8.h"
-#include "vm/vm.hpp"
/* primitivetype_table *********************************************************
break;
default:
o = NULL;
- VM::get_current()->abort("primitive_box: invalid primitive type %d", type);
+ os::abort("primitive_box: invalid primitive type %d", type);
}
return o;
value.a = h;
break;
default:
- VM::get_current()->abort("Primitive::unbox: invalid primitive type %d", type);
+ os::abort("Primitive::unbox: invalid primitive type %d", type);
}
return value;
p = MNEW(char, 4096);
if (os::readlink("/proc/self/exe", p, 4095) == -1)
- VM::get_current()->abort_errno("readlink failed");
+ os::abort_errno("readlink failed");
/* We have a path like:
#include "vm/statistics.h"
#include "vm/string.hpp"
#include "vm/utf8.h"
-#include "vm/vm.hpp"
/* global variables ***********************************************************/
if (js.is_null() || (js.get_value() == NULL)) {
/* error in hashtable found */
- VM::get_current()->abort("stringtable_update: invalid literalstring in hashtable");
+ os::abort("stringtable_update: invalid literalstring in hashtable");
}
a = LLNI_UNWRAP(js.get_value());
}
#else
- VM::get_current()->abort("suck_add: zip/jar files not supported");
+ os::abort("suck_add: zip/jar files not supported");
#endif
}
else {
/* Install the exit handler. */
if (atexit(vm_exit_handler))
- VM::get_current()->abort("atexit failed: %s\n", strerror(errno));
+ os::abort("atexit failed: %s\n", strerror(errno));
/* Set some options. */
/* install architecture dependent signal handlers */
if (!signal_init())
- VM::get_current()->abort("vm_create: signal_init failed");
+ os::abort("vm_create: signal_init failed");
#if defined(ENABLE_INTRP)
/* Allocate main thread stack on the Java heap. */
/* AFTER: threads_preinit */
if (!string_init())
- VM::get_current()->abort("vm_create: string_init failed");
+ os::abort("vm_create: string_init failed");
/* AFTER: threads_preinit */
/* AFTER: thread_preinit */
if (!suck_init())
- VM::get_current()->abort("vm_create: suck_init failed");
+ os::abort("vm_create: suck_init failed");
suck_add_from_property("java.endorsed.dirs");
(must be done _after_ threads_preinit) */
if (!classcache_init())
- VM::get_current()->abort("vm_create: classcache_init failed");
+ os::abort("vm_create: classcache_init failed");
/* Initialize the code memory management. */
/* AFTER: threads_preinit */
threads_preinit) */
if (!finalizer_init())
- VM::get_current()->abort("vm_create: finalizer_init failed");
+ os::abort("vm_create: finalizer_init failed");
/* Initialize the JIT compiler. */
#endif
if (!builtin_init())
- VM::get_current()->abort("vm_create: builtin_init failed");
+ os::abort("vm_create: builtin_init failed");
/* Initialize the native subsystem. */
/* BEFORE: threads_init */
if (!native_init())
- VM::get_current()->abort("vm_create: native_init failed");
+ os::abort("vm_create: native_init failed");
/* Register the native methods implemented in the VM. */
/* BEFORE: threads_init */
(e.g. NewGlobalRef). */
if (!jni_init())
- VM::get_current()->abort("vm_create: jni_init failed");
+ os::abort("vm_create: jni_init failed");
#endif
#if defined(ENABLE_JNI) || defined(ENABLE_HANDLES)
/* BEFORE: threads_init */
if (!localref_table_init())
- VM::get_current()->abort("vm_create: localref_table_init failed");
+ os::abort("vm_create: localref_table_init failed");
#endif
/* Iinitialize some important system classes. */
/* initialize profiling */
if (!profile_init())
- VM::get_current()->abort("vm_create: profile_init failed");
+ os::abort("vm_create: profile_init failed");
#endif
#if defined(ENABLE_THREADS)
/* initialize recompilation */
if (!recompile_init())
- VM::get_current()->abort("vm_create: recompile_init failed");
+ os::abort("vm_create: recompile_init failed");
/* start the signal handler thread */
if (threads_pthreads_implementation_nptl)
#endif
if (!signal_start_thread())
- VM::get_current()->abort("vm_create: signal_start_thread failed");
+ os::abort("vm_create: signal_start_thread failed");
/* finally, start the finalizer thread */
if (!finalizer_start_thread())
- VM::get_current()->abort("vm_create: finalizer_start_thread failed");
+ os::abort("vm_create: finalizer_start_thread failed");
# if !defined(NDEBUG)
/* start the memory profiling thread */
if (opt_ProfileMemoryUsage || opt_ProfileGCMemoryUsage)
if (!memory_start_thread())
- VM::get_current()->abort("vm_create: memory_start_thread failed");
+ os::abort("vm_create: memory_start_thread failed");
# endif
/* start the recompilation thread (must be done before the
profiling thread) */
if (!recompile_start_thread())
- VM::get_current()->abort("vm_create: recompile_start_thread failed");
+ os::abort("vm_create: recompile_start_thread failed");
# if defined(ENABLE_PROFILING)
/* start the profile sampling thread */
/* if (opt_prof) */
/* if (!profile_start_thread()) */
-/* VM::get_current()->abort("vm_create: profile_start_thread failed"); */
+/* os::abort("vm_create: profile_start_thread failed"); */
# endif
#endif
the application's main method exits. */
if (!thread_detach_current_thread())
- VM::get_current()->abort("vm_run: Could not detach main thread.");
+ os::abort("vm_run: Could not detach main thread.");
#endif
/* Destroy the JavaVM. */
}
-/**
- * Prints an error message and aborts the VM.
- *
- * @param text Error message to print.
- */
-void VM::abort(const char* text, ...)
-{
- va_list ap;
-
- // Print the log message.
- log_start();
-
- va_start(ap, text);
- log_vprint(text, ap);
- va_end(ap);
-
- log_finish();
-
- // Print a backtrace.
- os::print_backtrace();
-
- // Now abort the VM.
- os::abort();
-}
-
-
-/**
- * Prints an error message, appends ":" plus the strerror-message of
- * errnum and aborts the VM.
- *
- * @param errnum Error number.
- * @param text Error message to print.
- */
-void VM::abort_errnum(int errnum, const char* text, ...)
-{
- va_list ap;
-
- // Print the log message.
- log_start();
-
- va_start(ap, text);
- log_vprint(text, ap);
- va_end(ap);
-
- // Print the strerror-message of errnum.
- log_print(": %s", os::strerror(errnum));
-
- log_finish();
-
- // Print a backtrace.
- os::print_backtrace();
-
- // Now abort the VM.
- os::abort();
-}
-
-
-/**
- * Equal to VM::abort_errnum, but uses errno to get the error number.
- *
- * @param text Error message to print.
- */
-void VM::abort_errno(const char* text, ...)
-{
- va_list ap;
-
- va_start(ap, text);
- abort_errnum(errno, text, ap);
- va_end(ap);
-}
-
-
/* vm_abort_disassemble ********************************************************
Prints an error message, disassemble the given code range (if
pc = disassinstr((u1*) pc);
#endif
- VM::get_current()->abort("Aborting...");
+ os::abort("Aborting...");
}
}
if (m == NULL)
- VM::get_current()->abort("vm_compile_method: java.lang.NoSuchMethodException: %s.%s",
+ os::abort("vm_compile_method: java.lang.NoSuchMethodException: %s.%s",
opt_method, opt_signature ? opt_signature : "");
jit_compile(m);
break;
default:
- VM::get_current()->abort("vm_call_method_objectarray: invalid return type %d", m->parseddesc->returntype.primitivetype);
+ os::abort("vm_call_method_objectarray: invalid return type %d", m->parseddesc->returntype.primitivetype);
}
/* enter the nativeworld again */
va_list ap;
va_start(ap, text);
- VM::get_current()->abort(text, ap);
+ os::abort(text, ap);
va_end(ap);
}
va_list ap;
va_start(ap, text);
- VM::get_current()->abort_errnum(errnum, text, ap);
+ os::abort_errnum(errnum, text, ap);
va_end(ap);
}
va_list ap;
va_start(ap, text);
- VM::get_current()->abort_errno(text, ap);
+ os::abort_errno(text, ap);
va_end(ap);
}
int64_t get_starttime() { return _starttime; }
Properties& get_properties() { return _properties; }
-
- // Instance functions.
- void abort(const char* text, ...);
- void abort_errnum(int errnum, const char* text, ...);
- void abort_errno(const char* text, ...);
};
#else