merged volatile memory barriers
[cacao.git] / src / native / vm / nativevm.cpp
index 837b4a0b76338fd5c9ba7760948fc5755ca01bdb..6ad36aa861aa5ef988b8d0217ae86e7cec0d270b 100644 (file)
@@ -43,6 +43,8 @@
 
 # include "native/vm/openjdk/hpi.hpp"
 
+# include "toolbox/sequence.hpp"
+
 # include "vm/globals.hpp"
 # include "vm/properties.hpp"
 # include "vm/utf8.h"
@@ -100,25 +102,20 @@ void nativevm_preinit(void)
        Properties& properties = vm->get_properties();
        const char* boot_library_path = properties.get("sun.boot.library.path");
 
-       size_t len =
-               os::strlen(boot_library_path) +
-               os::strlen("/libjava.so") +
-               os::strlen("0");
-
-       char* p = MNEW(char, len);
+       // Use sequence builder to assemble library path.
+       SequenceBuilder sb;
 
-       os::strcpy(p, boot_library_path);
-       os::strcat(p, "/libjava.so");
+       sb.cat(boot_library_path);
+       sb.cat("/libjava.so");
 
-       utf* u = utf_new_char(p);
+       // XXX This should actually be sb.export_symbol()
+       utf* u = utf_new_char(sb.c_str());
 
        NativeLibrary nl(u);
        void* handle = nl.open();
 
        if (handle == NULL)
-               os::abort("nativevm_init: failed to open libjava.so at: %s", p);
-
-       MFREE(p, char, len);
+               os::abort("nativevm_init: failed to open libjava.so at: %s", sb.c_str());
 
        NativeLibraries& nls = vm->get_nativelibraries();
        nls.add(nl);
@@ -127,8 +124,16 @@ void nativevm_preinit(void)
        HPI& hpi = vm->get_hpi();
        hpi.initialize();
 
+       _Jv_sun_misc_Perf_init();
        _Jv_sun_misc_Unsafe_init();
 
+#  if !defined(NDEBUG)
+       // Sanity check current time in milliseconds, because negative values
+       // might confuse OpenJDKs sanity checks.
+       if (opt_PrintWarnings && (builtin_currenttimemillis() < 0))
+               log_println("nativevm_preinit: Current time in milliseconds is negative, please check your time!");
+#  endif
+
 # else
 #  error unknown classpath configuration
 # endif