Merge branch 'master' of dice:git/vm

This commit is contained in:
Joel Dice 2007-09-14 14:34:38 -06:00
commit 1f30fa8c72
3 changed files with 117 additions and 23 deletions

View File

@ -5,6 +5,7 @@ import java.io.InputStream;
import java.io.IOException;
public abstract class ResourceBundle {
protected String name;
protected ResourceBundle parent;
private static String replace(char a, char b, String s) {
@ -24,7 +25,7 @@ public abstract class ResourceBundle {
(replace('.', '/', name) + ".properties");
if (in != null) {
try {
return new MapResourceBundle(new Parser().parse(in), parent);
return new MapResourceBundle(name, parent, new Parser().parse(in));
} finally {
in.close();
}
@ -96,7 +97,7 @@ public abstract class ResourceBundle {
return value;
}
}
return null;
throw new MissingResourceException(key, name, key);
}
public String getString(String key) {
@ -108,7 +109,10 @@ public abstract class ResourceBundle {
private static class MapResourceBundle extends ResourceBundle {
private final Map<String, Object> map;
public MapResourceBundle(Map<String, Object> map, ResourceBundle parent) {
public MapResourceBundle(String name, ResourceBundle parent,
Map<String, Object> map)
{
this.name = name;
this.parent = parent;
this.map = map;
}

View File

@ -52,8 +52,8 @@ cflags += -O0 -g3 -DVM_STRESS -DVM_STRESS_MAJOR
endif
ifeq ($(mode),fast)
cflags += -O3 -DNDEBUG
#strip = strip
#show-size = ls -l
strip = strip
show-size = ls -l
endif
cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(bld)/%.o,$(x)))

View File

@ -517,6 +517,37 @@ store(Thread* t, unsigned index)
BytesPerWord * 2);
}
void
populateMultiArray(Thread* t, object array, int32_t* counts,
unsigned index, unsigned dimensions)
{
if (index + 1 == dimensions or counts[index] == 0) {
return;
}
PROTECT(t, array);
object spec = className(t, objectClass(t, array));
PROTECT(t, spec);
object elementSpec = makeByteArray
(t, byteArrayLength(t, spec) - 1, false);
memcpy(&byteArrayBody(t, elementSpec, 0),
&byteArrayBody(t, spec, 1),
byteArrayLength(t, spec) - 1);
object class_ = resolveClass(t, elementSpec);
PROTECT(t, class_);
for (int32_t i = 0; i < counts[index]; ++i) {
object a = makeArray(t, counts[index + 1], true);
setObjectClass(t, a, class_);
set(t, objectArrayBody(t, array, i), a);
populateMultiArray(t, a, counts, index + 1, dimensions);
}
}
object
run(Thread* t)
{
@ -701,8 +732,24 @@ run(Thread* t)
object array = popObject(t);
if (LIKELY(array)) {
if (objectClass(t, array)
== arrayBody(t, t->vm->types, Machine::BooleanArrayType))
{
if (LIKELY(index >= 0 and
static_cast<uintptr_t>(index) < byteArrayLength(t, array)))
static_cast<uintptr_t>(index)
< booleanArrayLength(t, array)))
{
pushInt(t, booleanArrayBody(t, array, index));
} else {
object message = makeString(t, "%d not in [0,%d)", index,
booleanArrayLength(t, array));
exception = makeArrayIndexOutOfBoundsException(t, message);
goto throw_;
}
} else {
if (LIKELY(index >= 0 and
static_cast<uintptr_t>(index)
< byteArrayLength(t, array)))
{
pushInt(t, byteArrayBody(t, array, index));
} else {
@ -711,6 +758,7 @@ run(Thread* t)
exception = makeArrayIndexOutOfBoundsException(t, message);
goto throw_;
}
}
} else {
exception = makeNullPointerException(t);
goto throw_;
@ -723,6 +771,21 @@ run(Thread* t)
object array = popObject(t);
if (LIKELY(array)) {
if (objectClass(t, array)
== arrayBody(t, t->vm->types, Machine::BooleanArrayType))
{
if (LIKELY(index >= 0 and
static_cast<uintptr_t>(index)
< booleanArrayLength(t, array)))
{
booleanArrayBody(t, array, index) = value;
} else {
object message = makeString(t, "%d not in [0,%d)", index,
booleanArrayLength(t, array));
exception = makeArrayIndexOutOfBoundsException(t, message);
goto throw_;
}
} else {
if (LIKELY(index >= 0 and
static_cast<uintptr_t>(index) < byteArrayLength(t, array)))
{
@ -733,6 +796,7 @@ run(Thread* t)
exception = makeArrayIndexOutOfBoundsException(t, message);
goto throw_;
}
}
} else {
exception = makeNullPointerException(t);
goto throw_;
@ -962,7 +1026,7 @@ run(Thread* t)
fprintf(stderr, "dup2\n");
}
memcpy(stack + ((sp + 1) * 2), stack + ((sp - 2) * 2), BytesPerWord * 4);
memcpy(stack + ((sp ) * 2), stack + ((sp - 2) * 2), BytesPerWord * 4);
sp += 2;
} goto loop;
@ -1719,9 +1783,9 @@ run(Thread* t)
case iushr: {
int32_t b = popInt(t);
int32_t a = popInt(t);
uint32_t a = popInt(t);
pushInt(t, static_cast<uint32_t>(a >> b));
pushInt(t, a >> b);
} goto loop;
case ixor: {
@ -2023,7 +2087,7 @@ run(Thread* t)
} goto loop;
case lushr: {
uint64_t b = popLong(t);
int64_t b = popLong(t);
uint64_t a = popLong(t);
pushLong(t, a >> b);
@ -2056,6 +2120,32 @@ run(Thread* t)
}
} goto loop;
case multianewarray: {
uint16_t index = codeReadInt16(t, ip);
uint8_t dimensions = codeBody(t, code, ip++);
object class_ = resolveClass(t, codePool(t, code), index - 1);
if (UNLIKELY(exception)) goto throw_;
int32_t counts[dimensions];
for (int i = dimensions - 1; i >= 0; --i) {
counts[i] = popInt(t);
if (UNLIKELY(counts[i] < 0)) {
object message = makeString(t, "%d", counts[i]);
exception = makeNegativeArraySizeException(t, message);
goto throw_;
}
}
object array = makeArray(t, counts[0], true);
setObjectClass(t, array, class_);
PROTECT(t, array);
populateMultiArray(t, array, counts, 0, dimensions);
pushObject(t, array);
} goto loop;
case new_: {
uint16_t index = codeReadInt16(t, ip);