jatovm / jato Goto Github PK
View Code? Open in Web Editor NEWJato, an open source implementation of the JVM
Home Page: http://www.jatovm.org/
License: Other
Jato, an open source implementation of the JVM
Home Page: http://www.jatovm.org/
License: Other
Jython 2.5.2rc4 fails to start up under Jato:
$ jato -jar jython.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError:
sun/misc/Unsafe.arrayBaseOffset(Ljava/lang/Class;)I
at java.util.concurrent.atomic.AtomicReferenceArray.<clinit>(AtomicReferenceArray.java:24)
at org.python.google.common.collect.CustomConcurrentHashMap$Segment.newEntryArray(CustomConcurrentHashMap.java:1683)
at org.python.google.common.collect.CustomConcurrentHashMap$Segment.<init>(CustomConcurrentHashMap.java:1670)
at org.python.google.common.collect.CustomConcurrentHashMap.<init>(CustomConcurrentHashMap.java:269)
at org.python.google.common.collect.MapMaker.makeMap(MapMaker.java:440)
at org.python.core.PyType.fromClass(PyType.java:1280)
at org.python.core.PyObject.<init>(PyObject.java:66)
at org.python.core.PyBuiltinCallable.<init>(PyBuiltinCallable.java:21)
at org.python.core.PyBuiltinMethod.<init>(PyBuiltinMethod.java:16)
at org.python.core.PyBuiltinMethodNarrow.<init>(PyBuiltinMethodNarrow.java:24)
at org.python.core.PyType$type___subclasses___exposer.<init>(Unknown Source)
at org.python.core.PyType$PyExposer.<init>(Unknown Source)
at org.python.core.PyType.<clinit>(PyType.java:33)
at org.python.core.PyObject.<init>(PyObject.java:66)
at org.python.core.PyBuiltinCallable.<init>(PyBuiltinCallable.java:21)
at org.python.core.PyBuiltinMethod.<init>(PyBuiltinMethod.java:16)
at org.python.core.PyBuiltinMethodNarrow.<init>(PyBuiltinMethodNarrow.java:24)
at org.python.core.PyDataDescr$getset_descriptor___get___exposer.<init>(Unknown Source)
at org.python.core.PyDataDescr$PyExposer.<init>(Unknown Source)
at org.python.core.PyDataDescr.<clinit>(PyDataDescr.java)
at org.python.core.PyBuiltinCallable$PyExposer.<init>(Unknown Source)
at org.python.core.PyBuiltinCallable.<clinit>(PyBuiltinCallable.java)
at org.python.core.PyObject$PyExposer.<init>(Unknown Source)
at org.python.core.PyObject.<clinit>(PyObject.java:26)
at org.python.util.jython.run(jython.java:150)
at org.python.util.jython.main(jython.java:129)
The PMD benchmark fails under Jato:
$ jato -jar dacapo-2006-10-MR2.jar pmd
[snip]
Digest validation failed for stdout.log, expecting 0x15443d38fce80cd97026c5ca650fe3dae0a30e01 found 0x41d3599f62204597fd2a4ef061249c601cabc949
===== DaCapo pmd FAILED =====
Validation FAILED for pmd default
but works fine under JamVM.
EntryTest
, for example, gets stuck in a busy loop in boostrap classloader code:
[main] Native and Java stack trace:
[main] [<00419041>] native : sigquit_handler+18 (/home/penberg/jato/vm/signal.c:184)
[main] [<3ba240efdf>] native : signal_bh_trampoline+3ba1fe120b (arch/x86/signal-bh.S:126)
[main] [<40635ef3>] jit : java/util/zip/Inflater.decode(Inflater.java:709)
[main] [<40632448>] jit : java/util/zip/Inflater.inflate(Inflater.java:322)
[main] [<4063076c>] jit : java/util/zip/InflaterInputStream.read(InflaterInputStream.java:196)
[main] [<405ee573>] jit : java/io/FilterInputStream.read(FilterInputStream.java:189)
[main] [<406ea2ef>] jit : java/util/jar/JarFile$EntryInputStream.read(JarFile.java:912)
[main] [<406e9ebd>] jit : java/util/jar/JarFile$EntryInputStream.read(JarFile.java:930)
[main] [<405eb17d>] jit : java/io/InputStreamReader.read(InputStreamReader.java:459)
[main] [<405e581a>] jit : java/io/BufferedReader.fill(BufferedReader.java:370)
[main] [<405e2deb>] jit : java/io/BufferedReader.readLine(BufferedReader.java:469)
[main] [<4008e382>] jit : java/lang/VMClassLoader.getBootPackages(VMClassLoader.java:263)
[main] [<4007be1b>] jit : java/lang/VMClassLoader.<clinit>(VMClassLoader.java:88)
[main] [<00410260>] native : vm_class_init+175 (/home/penberg/jato/vm/class.c:748)
[main] [<0042567a>] native : vm_class_ensure_init+ffffffffffff2edd (/home/penberg/jato/include/vm/class.h:126)
[main] [<40075d52>] jit : java/lang/VMClassLoader.getSystemClassLoader(VMClassLoader.java)
[main] [<40077e73>] jit : java/lang/ClassLoader$StaticData.<clinit>(ClassLoader.java:154)
[main] [<00410260>] native : vm_class_init+175 (/home/penberg/jato/vm/class.c:748)
[main] [<400750a3>] jit : java/lang/ClassLoader.getSystemClassLoader(ClassLoader.java:799)
[main] [<0041b60c>] native : native_call_gp+e4 (/home/penberg/jato/arch/x86/call.c:205)
[main] [<0041b671>] native : native_call+42 (/home/penberg/jato/arch/x86/call.c:272)
[main] [<0040f927>] native : call_method_a+41 (/home/penberg/jato/vm/call.c:54)
[main] [<0040f9f1>] native : vm_call_method_v+99 (/home/penberg/jato/vm/call.c:71)
[main] [<00411aa2>] native : vm_call_method_object+48e2 (/home/penberg/jato/include/vm/call.h:81)
[main] [<00405ebc>] native : do_main_class+18 (/home/penberg/jato/jato.c:1010)
[main] [<004057b5>] native : ./jato() [0x4057b5]
[main] [<3ba1c21734>] native : signal_bh_trampoline+3ba17f3960 (arch/x86/signal-bh.S:126)
So perhaps issue #34 isn't fixed properly.
Initial version of LLVM backend is now in master. It's not fully functional and lacks invokeinterface
among others.
The build fails on Darwin:
jato (master) λ make
CC monoburg.o
clang: warning: argument unused during compilation: '-rdynamic'
BISON parser.c
CC parser.o
clang: warning: argument unused during compilation: '-rdynamic'
LINK monoburg
clang: warning: argument unused during compilation: '-rdynamic'
CC allchblk.o
In file included from allchblk.c:19:
In file included from include/private/gc_priv.h:66:
include/private/gcconfig.h:477:2: error: expected identifier or '('
--> unknown machine type
^
1 error generated.
make[1]: *** [allchblk.o] Error 1
make: *** [boehmgc] Error 2
Running JRuby, for example, yields the following exception:
$ JAVACMD=jato ./bin/jruby test/externals/ruby1.8/runner.rb
vm/class.c:883: warning: vm_class_resolve_name_and_type not implemented
Method.java:477:in getAnnotation': java.lang.UnsatisfiedLinkError: java/lang/reflect/VMMethod.getAnnotation(Ljava/lang/Class;)Ljava/lang/annotation/Annotation; from RubyModule.java:556:in
clump'
from TypePopulator.java:50:in populate' from RubyModule.java:653:in
defineAnnotatedMethodsIndividually'
from RubyModule.java:541:in defineAnnotatedMethods' from RubyModule.java:141:in
createModuleClass'
from Ruby.java:1114:in initRoot' from Ruby.java:1047:in
init'
from Ruby.java:179:in newInstance' from Main.java:182:in
internalRun'
from Main.java:164:in run' from Main.java:148:in
run'
from Main.java:128:in `main'
That's caused by the fact that we only support class annotations, and not field or method annotations.
See commit 49284cf ("test/functional: Disable parameter annotation tests") for details.
The following test case:
public class DoubleTest {
public static void main(String[] args) {
System.out.println(Double.valueOf(1.1));
}
}
produces wrong results with Jato:
$ jato DoubleTest
1.1000000000000001
JamVM and OpenJDK do the right thing:
$ /usr/local/jamvm/bin/jamvm DoubleTest
1.1
$ java DoubleTest
1.1
It looks like the generated native code in Jato is wrong and Arhur and Tomek suspected we might be using the wrong SSE rounding mode. The problem is likely to be visible for Float.valueOf() and possibly other double and float operations.
The Jar file manifest parser is incomplete.
~/testing/jato/apache-maven-3.0.3$ JAVACMD=/home/penberg/bin/jato ./bin/mvn
vm_class_resolve_class: warning: failed to load class org/apache/maven/eventspy/internal/EventSpyDispatcher
__convert_ldc: warning: unable to lookup class
convert_instruction: warning: conversion error at PC=157
[ERROR] Error executing Maven.
[ERROR] org.apache.maven.eventspy.internal.EventSpyDispatcher
Commit a631581 ("x86,jit: Fix floating point conversion issues") fixed compatibility problems wrt. floating point conversions but turned every {float,double} -> {int,long} conversion into a CALL instruction. We should inline fastpath to generated code like CACAO, for example, does.
I have struggled to obtain replies from the Jato 'mailing list'
so I hope that I can pose my questions here.
-Will the Jato Java VM support 64 bit Java in memory?
-Will there be Windows, Mac, Linux downloadable build versions
of Jato?
-Will Jato have the opion to entirely disable floating point arithmetic overflow
or underflow via arithmetic on float, Float, double, Double types?
$ cat DynamicProxyTest.java
import java.lang.reflect.*;
public class DynamicProxyTest {
public static void main(String[] args) {
InvocationHandler handler = new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
throw new RuntimeException("hello");
}
};
Runnable r = (Runnable) Proxy.newProxyInstance(Runnable.class.getClassLoader(), new Class[] { Runnable.class }, handler);
r.run();
}
}
With OpenJDK:
$ java DynamicProxyTest
Exception in thread "main" java.lang.RuntimeException: hello
at DynamicProxyTest$1.invoke(DynamicProxyTest.java:7)
at $Proxy0.run(Unknown Source)
at DynamicProxyTest.main(DynamicProxyTest.java:11)
With Jato:
$ jato DynamicProxyTest
[main] SIGSEGV at EIP 0806a35f while accessing memory address 0000e14b.
[main] Registers:
[main] eax: 00000000 ebx: 08387410 ecx: b7455f8c edx: 00000000
[main] esi: 0000e0ff edi: a753384d ebp: bfb70e04 esp: bfb70ddc
[main] Code: f3 74 68 83 7b 20 01 75 22 83 7e 20 01 75 58 83 ec 0c 53 e8 74 ff ff ff 89 1c 24 89 c7 e8 6a ff ff ff 89 fb 83 c4 10 89 c6 eb d4 <8b> 46 4c 85 c0 75 04 31 ff eb 2c 52 52 50 53 e8 a6 ff ff ff 83
[main] Native and Java stack trace:
[main] [<0806a35f>] native : vm_class_is_assignable_from+46 (/home/penberg/src/jato/vm/class.c:1253)
[main] [<0806a372>] native : vm_class_is_assignable_from+59 (/home/penberg/src/jato/vm/class.c:1253)
[main] [<0805eec2>] native : throw_from_jit+53 (/home/penberg/src/jato/jit/exception.c:363)
[main] [<0807867a>] native : throw_exception+32 (/home/penberg/src/jato/sys/linux-x86/exception.c:51)
[main] [] jit : $Proxy0.run(Unknown Source)
[main] [] jit : DynamicProxyTest.main(DynamicProxyTest.java:11)
[main] [<0805ce05>] native : do_main_class+12c (/home/penberg/src/jato/vm/jato.c:1037)
[main] [<0805d3ba>] native : jato(main+0x55f) [0x805d3ba]
[main] [] native : signal_bh_trampoline+af3e8c5a (arch/x86/signal-bh.S:41)
[main] [<0805bd50>] native : jato() [0x805bd50]
Aborted
The x86-64 architecture reuses much of the 32-bit architecture code for instruction encoding. This has the unfortunate side-effect that there's a 4 GB limit for pointers on x86-64.
Running JRuby:
JAVACMD=jato ./bin/jruby test/externals/ruby1.8/runner.rb
fails to run because Jato is unable to compile the org/jruby/RubySymbol class. That's because we don't properly parse annotation string array element values.
Using
Ubuntu 12.04x86
jruby 1.5.6
Jato VM version 0.3
root@sdkie:/home/sdkie/Desktop/programs# jruby hello.rb
Sha256.java:215:in sha': java.lang.ArrayIndexOutOfBoundsException: 32 > 31 from Sha256.java:129:in
transform'
from BaseHash.java:123:in update' from Fortuna.java:286:in
addRandomBytes'
from BasePRNG.java:142:in addRandomBytes' from Fortuna.java:309:in
setup'
from BasePRNG.java:82:in init' from Fortuna.java:127:in
setup'
from BasePRNG.java:82:in init' from FortunaImpl.java:67:in
engineSetSeed'
from SecureRandom.java:323:in setSeed' from SecureRandom.java:365:in
nextBytes'
from SecureRandom.java:386:in next' from Random.java:320:in
nextLong'
from Ruby.java:208:in <init>' from Ruby.java:275:in
newInstance'
from Main.java:262:in internalRun' from Main.java:221:in
run'
from Main.java:201:in `main'
Given this test program:
public class Hashtable<K, V> {
private final float loadFactor;
public Hashtable(int initialCapacity, float loadFactor)
{
HashEntry<K, V>[] buckets = (HashEntry<K, V>[]) new HashEntry[initialCapacity];
if (!(loadFactor > 0))
throw new IllegalArgumentException();
this.loadFactor = loadFactor;
}
private static final class HashEntry<K, V> {
}
public static void main(String[] args) {
Hashtable ht = new Hashtable(100, 0.75f);
}
}
If you compile Jato with GCC optimization level "-O2", for example:
make CFLAGS=-O2
and then run the program as follows:
javac Hashtable.java
./jato -Xtrace:exceptions \
-bootclasspath .:/usr/local/classpath/share/classpath/glibj.zip \
-Djava.library.path=/usr/local/classpath/lib/classpath/ \
-Xnosystemclassloader Hashtable
You will see the following crash:
[main] trace exception: exception object 0x236c630 (java/lang/IllegalArgumentException) thrown
[main] message : 0x0 null
[main] from : 0x40fa8fc7: Hashtable.<init>(IF)V
[main] (Hashtable.java:12)
[main] action : unwind to 0x40fa8db1: Hashtable.main([Ljava/lang/String;)V
[main] (Hashtable.java:20)
[main] trace exception: exception object 0x236c630 (java/lang/IllegalArgumentException) thrown
[main] message : 0x0 null
[main] from : 0x40fa8db0: Hashtable.main([Ljava/lang/String;)V
[main] (Hashtable.java:20)
[main] action : unwind to native caller at 0x41e4b8
Exception in thread "main" java.lang.IllegalArgumentException
at Hashtable.(Hashtable.java:12)
at Hashtable.main(Hashtable.java:20)
Now while this doesn't seem to happen with the "-Os" GCC optimization level, it's by pure luck. Looking at the generated assembly, we see that XMM registers (which are caller saved registers on x86-64) are not saved before call
instructions:
[main] 0x41d7ff51: 48 89 e5 mov %rsp,%rbp
[main] 0x41d7ff54: 48 83 ec 40 sub $0x40,%rsp
[main] 0x41d7ff58: 53 push %rbx
[main] 0x41d7ff59: 41 54 push %r12
[main] 0x41d7ff5b: 41 55 push %r13
[main] 0x41d7ff5d: 41 56 push %r14
[main] 0x41d7ff5f: 41 57 push %r15
[main] 0x41d7ff61: 57 push %rdi
[main] 0x41d7ff62: 49 89 ff mov %rdi,%r15
[main] 0x41d7ff65: 49 89 f6 mov %rsi,%r14
[main] 0x41d7ff68: f3 0f 10 f8 movss %xmm0,%xmm7
[main] 0x41d7ff6c: 4d 89 fd mov %r15,%r13
[main] 0x41d7ff6f: 4d 85 6d 00 test %r13,0x0(%r13)
[main] 0x41d7ff73: 4c 89 ef mov %r13,%rdi
[main] 0x41d7ff76: f6 04 25 00 90 d3 00 00 testb $0x0,0xd39000
[main] 0x41d7ff7e: e8 bd cd ff ff callq 0x0000000041d7cd40 # java/lang/Object.<init>()V
[main] 0x41d7ff83: 45 89 f6 mov %r14d,%r14d
[main] 0x41d7ff86: 4c 89 f7 mov %r14,%rdi
[main] 0x41d7ff89: e8 c2 51 6b be callq 0x0000000000435150 # array_size_check+0 (/home/penberg/jato/vm/object.c:494)
which means that the any function that uses the XMM registers will clobber our registers.
I went through the code and I believe that the register allocator does not properly handle caller-saved registers. The special-casing in __update_live_ranges() seems incomplete because it doesn't update the "defs" bitmap nor updates use positions.
penberg@jaguar:~/src/jato$ ./jato -Xdebug:stack -jar ~/testing/jato/dacapo-2006-10-MR2.jar antlr
Stack frame redzone overwritten at 0xa93a95be: (nil)
Aborted
Current master with Classpath 0.98 on Ubuntu 11.04 x86_64.
headius@headius-vbox-ubuntu:~/projects/jato$ make torture
MAKE
make -C clojure JAVA=/home/headius/projects/jato/jato
/home/headius/projects/jato/jato -cp clojure-1.1.0/clojure.jar clojure.main hello.clj
[main] SIGSEGV at RIP 0043c5eb while accessing memory address 00000040.
[main] Registers:
[main] rsp: 00007fff54212688
[main] rax: 0000000000000000 rbx: 0000000000000040 rcx: 00002b58901062c0
[main] rdx: 0000000000000000 rsi: 0000000000000001 rdi: 00000000030abe80
[main] rbp: 00007fff542126c8 r8: 0000000003119520 r9: 000000000000003f
[main] r10: 00000000006ca76c r11: 00000000fffffffa r12: 00000000030abe80
[main] r13: 0000000002cfe320 r14: 0000000002cfe348 r15: 0000000002d13e60
[main] Code: 89 6d e8 4c 89 75 f0 4c 89 7d f8 48 83 ec 40 48 8b 5f 08 64 48 8b 04 25 28 00 00 00 48 89 45 c8 31 c0 48 85 db 0f 84 15 01 00 00 <4c> 8b 2b 8b 3d ac f4 28 00 e8 df dd fd ff 49 39 c5 0f 85 fe 00
[main] Native and Java stack trace:
[main] [<0043c5eb>] native : /home/headius/projects/jato/jato(vm_object_unlock+0x3b) [0x43c5eb]
[main] [<4072a526>] jit : java/util/Hashtable.put(Hashtable.java)
[main] [<40729eab>] jit : java/util/Properties.setProperty(Properties.java:157)
[main] [<0041b960>] vm native : gnu/classpath/VMSystemProperties.preInit(Native Method)
[main] native_vmsystemproperties_preinit+0 (/home/headius/projects/jato/vm/jato.c:302)
[main] [<40728bdb>] jit : gnu/classpath/SystemProperties.<clinit>(SystemProperties.java:69)
[main] [<0043092c>] native : vm_class_init+10c (/home/headius/projects/jato/vm/class.c:748)
[main] [<00461723>] native : vm_class_ensure_init+fffffffffffe1a33 (/home/headius/projects/jato/include/vm/class.h:112)
[main] [<40710fd2>] jit : gnu/classpath/SystemProperties.getProperty(SystemProperties.java)
[main] [<40727ed4>] jit : java/lang/VMClassLoader.getResources(VMClassLoader.java:184)
[main] [<407233ea>] jit : java/lang/VMClassLoader.getResource(VMClassLoader.java:170)
[main] [<40722d4b>] jit : java/lang/VMClassLoader.getBootPackages(VMClassLoader.java:252)
[main] [<4071426b>] jit : java/lang/VMClassLoader.<clinit>(VMClassLoader.java:89)
[main] [<0043092c>] native : vm_class_init+10c (/home/headius/projects/jato/vm/class.c:748)
[main] [<00461723>] native : vm_class_ensure_init+fffffffffffe1a33 (/home/headius/projects/jato/include/vm/class.h:112)
[main] [<40710af2>] jit : java/lang/VMClassLoader.getSystemClassLoader(VMClassLoader.java)
[main] [<40712bb1>] jit : java/lang/ClassLoader$StaticData.<clinit>(ClassLoader.java:154)
[main] [<0043092c>] native : vm_class_init+10c (/home/headius/projects/jato/vm/class.c:748)
[main] [<004505de>] native : vm_class_ensure_init+fffffffffffd08ee (/home/headius/projects/jato/include/vm/class.h:112)
[main] [<004413b6>] native : static_field_signal_bh+26 (/home/headius/projects/jato/vm/static.c:66)
[main] [<00470f4b>] native : signal_bh_trampoline+87 (arch/x86/signal-bh.S:124)
[main] [<4070fe59>] jit : java/lang/ClassLoader.getSystemClassLoader(ClassLoader.java:796)
[main] [<004439ea>] native : /home/headius/projects/jato/jato() [0x4439ea]
[main] [<00443ab4>] native : native_call+84 (/home/headius/projects/jato/arch/x86/call.c:268)
[main] [<0042ee65>] native : /home/headius/projects/jato/jato(vm_call_method_v+0xe5) [0x42ee65]
[main] [<00433623>] native : vm_call_method_object+9003 (/home/headius/projects/jato/include/vm/call.h:81)
[main] [<0041bcd7>] native : do_main_class+37 (/home/headius/projects/jato/vm/jato.c:1025)
[main] [<0041d145>] native : /home/headius/projects/jato/jato(main+0xa65) [0x41d145]
[main] [<2b58911b7efe>] native : ic_vcall_stub+2b5890d29a65 (arch/x86/ic_lowlevel_64.S:17)
make[2]: *** [test] Aborted
make[1]: *** [clojure] Error 2
make: *** [torture] Error 2
penberg@jaguar:~/testing/jato$ jato -Xmx512M -jar JPCApplication.jar
Jan 10, 1970 5:11:27 a.m. org.jpc.j2se.JPCApplication main
INFO: Using configuration specified in manifest
Jan 10, 1970 5:11:32 a.m. org.jpc.emulator.memory.codeblock.CodeBlockManager
INFO: JVM allows classloader creation: using advanced compilers.
Charlie Nutter reports the following breakage with GNU Classpath 0.98:
~/jato $ ./jato -jar ../jruby/lib/jruby.jar -e "puts 1"
vm/class.c:931: warning: vm_class_resolve_name_and_type not implemented
[main] SIGSEGV at EIP 0806d782 while accessing memory address 04c48213.
[main] Registers:
[main] eax: 04c481c7 ebx: 08ded380 ecx: 00000001 edx: a78bd9c0
[main] esi: 08ded380 edi: a78bd9c0 ebp: bf9f7504 esp: bf9f74cc
[main] Code: 7b 20 01 75 26 83 78 20 01 75 45 83 ec 0c 53 e8 5b ff ff
ff 89 1c 24 89 45 d4 e8 50 ff ff ff 83 c4 10 8b 5d d4 eb bf 39 c3 74
09 <8b> 40 4c 85 c0 75 f5 eb 1e b0 01 8b 96 d8 00 00 00 8d 4a 01 83
[main] Native and Java stack trace:
[main] [<0806d782>] native :
./jato(vm_class_is_assignable_from_slow+0x63) [0x806d782]
[main] [<08061907>] native : vm_class_is_assignable_from+3c
(/home/headius/jato/include/vm/class.h:229)
[main] [<08061eab>] native : throw_from_jit+50
(/home/headius/jato/jit/exception.c:363)
[main] [<0807f07e>] native : throw_exception+32
(/home/headius/jato/sys/linux-x86/exception.c:51)
[main] [] jit : $Proxy0.optional(Unknown Source)
[main] [] jit :
org/jruby/anno/JavaMethodDescriptor.(JavaMethodDescriptor.java:80)
[main] [] jit :
org/jruby/RubyModule$MethodClumper.clump(RubyModule.java:624)
[main] [] jit :
org/jruby/anno/TypePopulator$DefaultTypePopulator.populate(TypePopulator.java:62)
[main] [] jit :
org/jruby/RubyModule.defineAnnotatedMethodsIndividually(RubyModule.java:718)
[main] [] jit :
org/jruby/RubyModule.defineAnnotatedMethods(RubyModule.java:606)
[main] [] jit :
org/jruby/RubyModule.createModuleClass(RubyModule.java:150)
[main] [] jit : org/jruby/Ruby.initRoot(Ruby.java:1176)
[main] [] jit : org/jruby/Ruby.init(Ruby.java:1104)
[main] [] jit : org/jruby/Ruby.newInstance(Ruby.java:250)
[main] [] jit : org/jruby/Main.internalRun(Main.java:239)
[main] [] jit : org/jruby/Main.run(Main.java:221)
[main] [] jit : org/jruby/Main.run(Main.java:205)
[main] [] jit : org/jruby/Main.main(Main.java:185)
[main] [<0805f710>] native : do_main_class+13e
(/home/headius/jato/vm/jato.c:1081)
[main] [<0805fcc7>] native : ./jato(main+0x55f) [0x805fcc7]
[main] [<00253e36>] native :
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xe6) [0x253e36]
[main] [<0805e500>] native : ./jato() [0x805e500]
Aborted
The issue here is that GNU Classpath throws IncompleteAnnotationException:
[main] trace exception: exception object 0xe3e5780
(java/lang/annotation/IncompleteAnnotationException) thrown
[main] message : 0x0 null
[main] from : 0xa793c922:
sun/reflect/annotation/AnnotationInvocationHandler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;
[main] (AnnotationInvocationHandler.java:373)
[main] action : unwind to 0xa793c58d: $Proxy0.optional()I
[main] (UNKNOWN:-1)
[main] trace exception: exception object 0xe3e5780
(java/lang/annotation/IncompleteAnnotationException) thrown
[main] message : 0x0 null
[main] from : 0xa793c58c: $Proxy0.optional()I
[main] (UNKNOWN:-1)
[main] action : jump to handler at 0xa793c622
[main] (UNKNOWN:-1)
We need to investigate whether this is a GNU Classpath bug or not. The failure to report the exception properly is a known separate issue:
Running some JRuby tests breaks because we don't implement VMThreadMXBeanImpl APIs:
~/src/jruby$ JAVACMD=jato bin/jruby test/test_method.rb
[snip]
ThreadMXBeanImpl.java:220:in `getThreadInfo': java.lang.UnsatisfiedLinkError: gnu/java/lang/management/VMThreadMXBeanImpl.getThreadInfoForId(JI)Ljava/lang/management/ThreadInfo;
Using GCC 4.7.2-2 from Fedora 17:
[penberg@golgotha jato]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.7.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --disable-build-with-cxx --disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.7.2 20120921 (Red Hat 4.7.2-2) (GCC)
I'm seeing the following SIGSEGV during early bootstrap classloading which is not visible with older GCC from Fedora 16:
[penberg@golgotha jato]$ ./jato -cp test/functional jvm/EntryTest
[main] SIGSEGV at RIP 04df8547 while accessing memory address 00000000.
[main] Registers:
[main] rsp: 00007fffc07e0080
[main] rax: 00000000422a50f0 rbx: 0000000000000080 rcx: 0000000000008000
[main] rdx: 0000000000000000 rsi: 00000000044d5000 rdi: 000000000129ed20
[main] rbp: 00007fffc07e0260 r8: 0000000000008000 r9: 00000000044d5000
[main] r10: 0000003ba1fb0778 r11: 000000000384e7c0 r12: 0000000000008000
[main] r13: 0000000004db16c0 r14: 0000000000000002 r15: 000000000129ed20
[main] Stack:
[main] 000000000129ed20 000000000129ed20 00000000044d5000 0000000000000000
[main] 0000000000008000 0000000000008000 00007fffc07e00f0 0000000004cc32b0
[main] 0000000004e0be10 0000000000000000 00000000c07e0110 0000000003b80b18
[main] Code: 00 00 00 00 33 00 00 00 00 00 00 00 e1 00 00 00 00 00 00 00 20 86 df 04 00 00 00 00 20 84 df 04 00 00 00 00 38 86 df 04 00 00 00 <00> 02 00 00 00 00 00 00 00 c0 16 db 04 00 00 00 00 00 00 00 00
[main] Native and Java stack trace:
[main] [<04df8547>] native : signal_bh_trampoline+49ca8db (arch/x86/signal-bh.S:126)
[main] [<422a4458>] jit : java/util/zip/Inflater.inflate(Inflater.java:322)
[main] [<422a277c>] jit : java/util/zip/InflaterInputStream.read(InflaterInputStream.java:196)
[main] [<422597b3>] jit : java/io/InputStreamReader.read(InputStreamReader.java:393)
[main] [<4225782a>] jit : java/io/BufferedReader.fill(BufferedReader.java:370)
[main] [<42254dfb>] jit : java/io/BufferedReader.readLine(BufferedReader.java:469)
[main] [<422a1a23>] jit : gnu/java/util/jar/JarUtils.read_attributes(JarUtils.java:194)
[main] [<422a1395>] jit : gnu/java/util/jar/JarUtils.readMainSection(JarUtils.java:140)
[main] [<4229e940>] jit : gnu/java/util/jar/JarUtils.readMFManifest(JarUtils.java:101)
[main] [<42209d01>] jit : java/util/jar/Manifest.read(Manifest.java:162)
[main] [<4220689f>] jit : java/util/jar/Manifest.<init>(Manifest.java:89)
[main] [<421e4e8f>] jit : java/util/jar/JarFile.readManifest(JarFile.java:303)
[main] [<421e2f38>] jit : java/util/jar/JarFile.<init>(JarFile.java:268)
[main] [<4218a763>] jit : gnu/java/net/protocol/jar/Connection$JarFileCache.get(Connection.java:99)
[main] [<421873f2>] jit : gnu/java/net/protocol/jar/Connection.connect(Connection.java:141)
[main] [<421862d2>] jit : gnu/java/net/protocol/jar/Connection.getInputStream(Connection.java:159)
[main] [<4217a12d>] jit : java/net/URL.openStream(URL.java:737)
[main] [<41cff9d1>] jit : java/lang/VMClassLoader.getBootPackages(VMClassLoader.java:262)
[main] [<41cede1b>] jit : java/lang/VMClassLoader.<clinit>(VMClassLoader.java:88)
[main] [<00410214>] native : vm_class_init+175 (/home/penberg/jato/vm/class.c:748)
[main] [<00425542>] native : vm_class_ensure_init+ffffffffffff2f0d (/home/penberg/jato/include/vm/class.h:126)
[main] [<41ce7d52>] jit : java/lang/VMClassLoader.getSystemClassLoader(VMClassLoader.java)
[main] [<41ce9e73>] jit : java/lang/ClassLoader$StaticData.<clinit>(ClassLoader.java:154)
[main] [<00410214>] native : vm_class_init+175 (/home/penberg/jato/vm/class.c:748)
[main] [<41ce70a3>] jit : java/lang/ClassLoader.getSystemClassLoader(ClassLoader.java:799)
[main] [<0041b54e>] native : native_call_gp+c6 (/home/penberg/jato/arch/x86/call.c:203)
[main] [<0041b5b3>] native : native_call+42 (/home/penberg/jato/arch/x86/call.c:270)
[main] [<0040f8db>] native : call_method_a+41 (/home/penberg/jato/vm/call.c:54)
[main] [<0040f9a5>] native : vm_call_method_v+99 (/home/penberg/jato/vm/call.c:71)
[main] [<00411a56>] native : vm_call_method_object+48e6 (/home/penberg/jato/include/vm/call.h:81)
[main] [<00405e6f>] native : do_main_class+18 (/home/penberg/jato/jato.c:1004)
[main] [<00405775>] native : ./jato() [0x405775]
[main] [<3ba1c21734>] native : signal_bh_trampoline+3ba17f3ac8 (arch/x86/signal-bh.S:126)
Decoding the trapping instruction:
[penberg@golgotha linux]$ ./scripts/decodecode
Code: 00 00 00 00 33 00 00 00 00 00 00 00 e1 00 00 00 00 00 00 00 20 86 df 04 00 00 00 00 20 84 df 04 00 00 00 00 38 86 df 04 00 00 00 <00> 02 00 00 00 00 00 00 00 c0 16 db 04 00 00 00 00 00 00 00 00
Code: 00 00 00 00 33 00 00 00 00 00 00 00 e1 00 00 00 00 00 00 00 20 86 df 04 00 00 00 00 20 84 df 04 00 00 00 00 38 86 df 04 00 00 00 <00> 02 00 00 00 00 00 00 00 c0 16 db 04 00 00 00 00 00 00 00 00
All code
========
0: 00 00 add %al,(%rax)
2: 00 00 add %al,(%rax)
4: 33 00 xor (%rax),%eax
6: 00 00 add %al,(%rax)
8: 00 00 add %al,(%rax)
a: 00 00 add %al,(%rax)
c: e1 00 loope 0xe
e: 00 00 add %al,(%rax)
10: 00 00 add %al,(%rax)
12: 00 00 add %al,(%rax)
14: 20 86 df 04 00 00 and %al,0x4df(%rsi)
1a: 00 00 add %al,(%rax)
1c: 20 84 df 04 00 00 00 and %al,0x4(%rdi,%rbx,8)
23: 00 38 add %bh,(%rax)
25: 86 df xchg %bl,%bh
27: 04 00 add $0x0,%al
29: 00 00 add %al,(%rax)
2b:* 00 02 add %al,(%rdx) <-- trapping instruction
2d: 00 00 add %al,(%rax)
2f: 00 00 add %al,(%rax)
31: 00 00 add %al,(%rax)
33: 00 c0 add %al,%al
35: 16 (bad)
36: db 04 00 fildl (%rax,%rax,1)
39: 00 00 add %al,(%rax)
3b: 00 00 add %al,(%rax)
3d: 00 00 add %al,(%rax)
...
Code starting with the faulting instruction
===========================================
0: 00 02 add %al,(%rdx)
2: 00 00 add %al,(%rax)
4: 00 00 add %al,(%rax)
6: 00 00 add %al,(%rax)
8: 00 c0 add %al,%al
a: 16 (bad)
b: db 04 00 fildl (%rax,%rax,1)
e: 00 00 add %al,(%rax)
10: 00 00 add %al,(%rax)
12: 00 00 add %al,(%rax)
...
Indicates that the %rdx register is clobbered.
Valgrind reports the following:
[penberg@golgotha jato]$ valgrind ./jato -Xnogc -cp test/functional jvm/EntryTest
==11402== Memcheck, a memory error detector
==11402== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==11402== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==11402== Command: ./jato -Xnogc -cp test/functional jvm/EntryTest
==11402==
JIT: Enabling workarounds for valgrind.
==11402== Jump to the invalid address stated on the next line
==11402== at 0x0: ???
==11402== by 0x410214: vm_class_init (class.c:748)
==11402== by 0x508F760: ???
==11402== by 0x41B54E: native_call_gp (call.c:203)
==11402== by 0x41B5B3: native_call (call.c:270)
==11402== by 0x40F8DB: call_method_a (call.c:54)
==11402== by 0x40F9A5: vm_call_method_v (call.c:71)
==11402== by 0x411A56: vm_call_method_object (call.h:81)
==11402== by 0x405E6F: do_main_class (jato.c:1004)
==11402== by 0x405775: main (jato.c:1068)
==11402== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==11402==
==11402== Use of uninitialised value of size 8
==11402== at 0x3BA1C464B1: _itoa_word (in /usr/lib64/libc-2.15.so)
==11402== by 0x3BA1C49118: vfprintf (in /usr/lib64/libc-2.15.so)
==11402== by 0x3BA1C74064: vsnprintf (in /usr/lib64/libc-2.15.so)
==11402== by 0x40B7F2: str_vprintf (string.c:154)
==11402== by 0x41AAE2: trace_printf (trace.c:57)
==11402== by 0x420D0E: print_backtrace_and_die (backtrace.c:152)
==11402== by 0x3BA240EFDF: ??? (in /usr/lib64/libpthread-2.15.so)
==11402==
==11402== Conditional jump or move depends on uninitialised value(s)
==11402== at 0x3BA1C464B8: _itoa_word (in /usr/lib64/libc-2.15.so)
==11402== by 0x3BA1C49118: vfprintf (in /usr/lib64/libc-2.15.so)
==11402== by 0x3BA1C74064: vsnprintf (in /usr/lib64/libc-2.15.so)
==11402== by 0x40B7F2: str_vprintf (string.c:154)
==11402== by 0x41AAE2: trace_printf (trace.c:57)
==11402== by 0x420D0E: print_backtrace_and_die (backtrace.c:152)
==11402== by 0x3BA240EFDF: ??? (in /usr/lib64/libpthread-2.15.so)
==11402==
==11402== Conditional jump or move depends on uninitialised value(s)
==11402== at 0x3BA1C49168: vfprintf (in /usr/lib64/libc-2.15.so)
==11402== by 0x3BA1C74064: vsnprintf (in /usr/lib64/libc-2.15.so)
==11402== by 0x40B7F2: str_vprintf (string.c:154)
==11402== by 0x41AAE2: trace_printf (trace.c:57)
==11402== by 0x420D0E: print_backtrace_and_die (backtrace.c:152)
==11402== by 0x3BA240EFDF: ??? (in /usr/lib64/libpthread-2.15.so)
==11402==
==11402== Conditional jump or move depends on uninitialised value(s)
==11402== at 0x3BA1C48DF0: vfprintf (in /usr/lib64/libc-2.15.so)
==11402== by 0x3BA1C74064: vsnprintf (in /usr/lib64/libc-2.15.so)
==11402== by 0x40B7F2: str_vprintf (string.c:154)
==11402== by 0x41AAE2: trace_printf (trace.c:57)
==11402== by 0x420D0E: print_backtrace_and_die (backtrace.c:152)
==11402== by 0x3BA240EFDF: ??? (in /usr/lib64/libpthread-2.15.so)
==11402==
==11402== Conditional jump or move depends on uninitialised value(s)
==11402== at 0x3BA1C48E6A: vfprintf (in /usr/lib64/libc-2.15.so)
==11402== by 0x3BA1C74064: vsnprintf (in /usr/lib64/libc-2.15.so)
==11402== by 0x40B7F2: str_vprintf (string.c:154)
==11402== by 0x41AAE2: trace_printf (trace.c:57)
==11402== by 0x420D0E: print_backtrace_and_die (backtrace.c:152)
==11402== by 0x3BA240EFDF: ??? (in /usr/lib64/libpthread-2.15.so)
==11402==
[main] SIGSEGV at RIP 00000000 while accessing memory address 00000000.
[main] Registers:
[main] rsp: 00000007fefff7b8
[main] rax: 0000000000000000 rbx: 00000000040d9cc0 rcx: 0000000000000000
[main] rdx: 0000000000000000 rsi: 00000000004e1576 rdi: 00000000169f5dc8
[main] rbp: 00000007fefff9a0 r8: 0000000000000000 r9: 0000000000000000
[main] r10: 0000000016566d00 r11: 00000000040d9330 r12: 0000000000000000
[main] r13: 00000000040d17f8 r14: 0000000000000000 r15: 0000000000000000
[main] Stack:
[main] 0000000005092534 00000000169f5dc8 0000000000000000 0000000000000000
[main] 00000000040d17f8 0000000000000000 00000000040d9cc0 0000000000001102
[main] 0000000000000000 0000000016ad01a0 0000000000000000 0000000000001102
[main] Native and Java stack trace:
[main] [<00000000>] native : [(nil)]
[main] [<00410214>] native : ./jato() [0x410214]
[main] [<0508f760>] jit : java/lang/ClassLoader.getSystemClassLoader(ClassLoader.java:799)
[main] [<0041b54e>] native : ./jato() [0x41b54e]
[main] [<0041b5b3>] native : ./jato() [0x41b5b3]
[main] [<0040f8db>] native : ./jato() [0x40f8db]
[main] [<0040f9a5>] native : ./jato() [0x40f9a5]
[main] [<00411a56>] native : ./jato() [0x411a56]
[main] [<00405e6f>] native : ./jato() [0x405e6f]
[main] [<00405775>] native : ./jato() [0x405775]
[main] [<3ba1c21734>] native : /lib64/libc.so.6(__libc_start_main+0xf4) [0x3ba1c21734]
==11402==
==11402== HEAP SUMMARY:
==11402== in use at exit: 102,012,458 bytes in 198,987 blocks
==11402== total heap usage: 1,942,210 allocs, 1,743,223 frees, 1,062,288,077 bytes allocated
==11402==
==11402== LEAK SUMMARY:
==11402== definitely lost: 729,256 bytes in 622 blocks
==11402== indirectly lost: 358 bytes in 19 blocks
==11402== possibly lost: 1,963,405 bytes in 46,171 blocks
==11402== still reachable: 99,319,439 bytes in 152,175 blocks
==11402== suppressed: 0 bytes in 0 blocks
==11402== Rerun with --leak-check=full to see details of leaked memory
==11402==
==11402== For counts of detected and suppressed errors, rerun with: -v
==11402== Use --track-origins=yes to see where uninitialised values come from
==11402== ERROR SUMMARY: 42 errors from 6 contexts (suppressed: 2 from 2)
Aborted (core dumped)
where the code that calls %rdx is:
[penberg@golgotha jato]$ addr2line -e jato
0x410214
/home/penberg/jato/vm/class.c:748
which is class initializer trampoline:
739 if (vmc->class) {
740 /* XXX: Make sure there's at most one of these. */
741 for (uint16_t i = 0; i < vmc->class->methods_count; ++i) {
742 if (strcmp(vmc->methods[i].name, "<clinit>"))
743 continue;
744
745 void (*clinit_trampoline)(void)
746 = vm_method_trampoline_ptr(&vmc->methods[i]);
747
748 clinit_trampoline();
749 if (exception_occurred())
750 goto error;
751 }
752 }
Commit 9429bdf disabled '-ftree-vectorize' because it breaks tests on x86-64. We should figure out the root cause, fix it, and enable the optimization.
The jato.internal.VM class is scaffolding from historical times that can do all sorts of interesting and insecure things. The class needs to go.
Jato doesn't support the following annotation element value types:
I tried to follow the instructions to build on Ubuntu 14.04 but they don't work.
penberg@jaguar:~/src/jruby$ JAVACMD=jato ./bin/jruby -w test/externals/ruby1.8/runner.rb vm/class.c:900: warning: vm_class_resolve_name_and_type not implemented Error: Your application used more stack memory than the safety cap of 2048k. Specify -J-Xss####k to increase it (#### = cap size in KB). Exception trace follows: java.lang.StackOverflowError at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:581) at java.lang.ClassLoader.loadClass(ClassLoader.java:320) at java.lang.ClassLoader$1.loadClass(ClassLoader.java:1112) at java.lang.ClassLoader.loadClass(ClassLoader.java:293) at java.lang.VMClassLoader.loadClass(Native Method) at java.lang.ClassLoader.loadClass(ClassLoader.java:328) at java.lang.ClassLoader$1.loadClass(ClassLoader.java:1112) at java.lang.ClassLoader.loadClass(ClassLoader.java:293) at java.lang.VMClassLoader.loadClass(Native Method) at java.lang.ClassLoader.loadClass(ClassLoader.java:328) at java.lang.ClassLoader$1.loadClass(ClassLoader.java:1112) at java.lang.ClassLoader.loadClass(ClassLoader.java:293) [ snip recursion ] at java.lang.VMClassLoader.loadClass(Native Method) at java.lang.ClassLoader.loadClass(ClassLoader.java:328) at java.lang.ClassLoader$1.loadClass(ClassLoader.java:1112) at java.lang.ClassLoader.loadClass(ClassLoader.java:293) at org.jruby.RubyModule.defineAnnotatedMethodsIndividually(RubyModule.java:653) at org.jruby.RubyModule.defineAnnotatedMethods(RubyModule.java:541) at org.jruby.RubyNil.createNilClass(RubyNil.java:65) at org.jruby.Ruby.initRoot(Ruby.java:1134) at org.jruby.Ruby.init(Ruby.java:1050) at org.jruby.Ruby.newInstance(Ruby.java:182) at org.jruby.Main.internalRun(Main.java:182) at org.jruby.Main.run(Main.java:164) at org.jruby.Main.run(Main.java:148) at org.jruby.Main.main(Main.java:128)
StackTraceTest reports the following with OpenJDK (with Jato specific test cases commented out):
Exception in thread "main" java.lang.UnsatisfiedLinkError: jvm/StackTraceTest.nativeMethod()V
at jvm.StackTraceTest.nativeMethod(Native Method)
at jvm.StackTraceTest.testJNIUnsatisfiedLinkErrorStackTrace(StackTraceTest.java:91)
at jvm.StackTraceTest.main(StackTraceTest.java:111)
Jato on x86-64 reports the same thing:
Exception in thread "main" java.lang.UnsatisfiedLinkError: jvm.StackTraceTest.nativeMethod()V
at jvm.StackTraceTest.nativeMethod(Native Method)
at jvm.StackTraceTest.testJNIUnsatisfiedLinkErrorStackTrace(StackTraceTest.java:91)
at jvm.StackTraceTest.main(StackTraceTest.java:111)
but on x86-32 the native method is missing:
Exception in thread "main" java.lang.UnsatisfiedLinkError: jvm/StackTraceTest.nativeMethod()V
at jvm.StackTraceTest.testJNIUnsatisfiedLinkErrorStackTrace(StackTraceTest.java:91)
at jvm.StackTraceTest.main(StackTraceTest.java:111)
Unsupported bytecode opcodes should cause java.lang.VerifyError to be thrown and not crash the VM.
The JIT compiler does not know about x86-64 "red zone":
http://eli.thegreenplace.net/2011/09/06/stack-frame-layout-on-x86-64/
this means that anything the JIT compiler saves on the stack without explicitly moving the stack pointer can be clobbered by other functions that were compiled with GCC. This might explain odd data corruption for various different applications on x86-64.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.