stack trace work

This commit is contained in:
Joel Dice 2007-06-29 20:39:01 -06:00
parent c34ee64988
commit b8e009075c
8 changed files with 96 additions and 7 deletions

View File

@ -0,0 +1,19 @@
public class TestExceptions {
private static void evenMoreDangerous() {
throw new RuntimeException("chaos! panic! overwhelming anxiety!");
}
private static void moreDangerous() {
evenMoreDangerous();
}
private static void dangerous() {
moreDangerous();
}
public static void main(String[] args) {
dangerous();
}
}

View File

@ -0,0 +1,19 @@
package java.lang;
public class Error extends Throwable {
public Error(String message, Throwable cause) {
super(message, cause);
}
public Error(String message) {
this(message, null);
}
public Error(Throwable cause) {
this(null, cause);
}
public Error() {
this(null, null);
}
}

View File

@ -0,0 +1,19 @@
package java.lang;
public class Exception extends Throwable {
public Exception(String message, Throwable cause) {
super(message, cause);
}
public Exception(String message) {
this(message, null);
}
public Exception(Throwable cause) {
this(null, cause);
}
public Exception() {
this(null, null);
}
}

View File

@ -0,0 +1,19 @@
package java.lang;
public class RuntimeException extends Exception {
public RuntimeException(String message, Throwable cause) {
super(message, cause);
}
public RuntimeException(String message) {
this(message, null);
}
public RuntimeException(Throwable cause) {
this(null, cause);
}
public RuntimeException() {
this(null, null);
}
}

View File

@ -0,0 +1,8 @@
package java.lang;
public class StackTraceElement {
private Object method;
private int ip;
private StackTraceElement() { }
}

View File

@ -7,7 +7,7 @@ public class Throwable {
public Throwable(String message, Throwable cause) {
this.message = message;
this.trace = trace(1);
this.trace = trace(0);
this.cause = cause;
}

View File

@ -36,6 +36,7 @@ stress-cflags = -DDEBUG_MEMORY -DDEBUG_MEMORY_MAJOR
cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(bld)/%.o,$(x)))
asm-objects = $(foreach x,$(1),$(patsubst $(2)/%.S,$(bld)/%.o,$(x)))
java-classes = $(foreach x,$(1),$(patsubst $(2)/%.java,$(bld)/%.class,$(x)))
stdcpp-sources = $(src)/stdc++.cpp
stdcpp-objects = $(call cpp-objects,$(stdcpp-sources),$(src))
@ -122,10 +123,14 @@ fast-objects = \
fast-executable = $(bld)/fast-vm
fast-cflags = $(fast) $(cflags)
classpath-sources = $(shell find %(classpath)/java -name '*.java')
classpath-classes = $(call java-classes,$(classpath-sources),$(classpath))
input = $(bld)/classes/TestExceptions.class
# input-depends = \
# $(bld)/classes/java/lang/System.class \
# $(jni-library)
input-depends = \
$(bld)/classes/java/lang/System.class \
$(bld)/classes/java/lang/Throwable.class \
$(jni-library)
gen-run-arg = $(shell echo $(1) | sed -e 's:$(bld)/classes/\(.*\)\.class:\1:')
args = -cp $(bld)/classes -hs 67108864 $(call gen-run-arg,$(input))

View File

@ -2532,7 +2532,7 @@ run(Thread* t)
if (UNLIKELY(exception)) goto throw_;
loop:
//fprintf(stderr, "ip: %d; instruction: 0x%x\n", ip, codeBody(t, code, ip));
// fprintf(stderr, "ip: %d; instruction: 0x%x\n", ip, codeBody(t, code, ip));
switch (codeBody(t, code, ip++)) {
case aaload: {
@ -3713,8 +3713,7 @@ run(Thread* t)
} goto loop;
case putfield: {
object instance = pop(t);
if (LIKELY(instance)) {
if (LIKELY(stack[sp - 2])) {
uint8_t index1 = codeBody(t, code, ip++);
uint8_t index2 = codeBody(t, code, ip++);
uint16_t index = (index1 << 8) | index2;
@ -3723,6 +3722,7 @@ run(Thread* t)
if (UNLIKELY(exception)) goto throw_;
object value = pop(t);
object instance = pop(t);
setField(t, instance, field, value);
} else {
exception = makeNullPointerException(t);