mirror of
https://github.com/corda/corda.git
synced 2025-01-16 01:40:17 +00:00
Merge branch 'master' of dice:git/vm
This commit is contained in:
commit
1f30fa8c72
@ -5,6 +5,7 @@ import java.io.InputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public abstract class ResourceBundle {
|
public abstract class ResourceBundle {
|
||||||
|
protected String name;
|
||||||
protected ResourceBundle parent;
|
protected ResourceBundle parent;
|
||||||
|
|
||||||
private static String replace(char a, char b, String s) {
|
private static String replace(char a, char b, String s) {
|
||||||
@ -24,7 +25,7 @@ public abstract class ResourceBundle {
|
|||||||
(replace('.', '/', name) + ".properties");
|
(replace('.', '/', name) + ".properties");
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
return new MapResourceBundle(new Parser().parse(in), parent);
|
return new MapResourceBundle(name, parent, new Parser().parse(in));
|
||||||
} finally {
|
} finally {
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
@ -96,7 +97,7 @@ public abstract class ResourceBundle {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
throw new MissingResourceException(key, name, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(String key) {
|
public String getString(String key) {
|
||||||
@ -108,7 +109,10 @@ public abstract class ResourceBundle {
|
|||||||
private static class MapResourceBundle extends ResourceBundle {
|
private static class MapResourceBundle extends ResourceBundle {
|
||||||
private final Map<String, Object> map;
|
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.parent = parent;
|
||||||
this.map = map;
|
this.map = map;
|
||||||
}
|
}
|
||||||
|
4
makefile
4
makefile
@ -52,8 +52,8 @@ cflags += -O0 -g3 -DVM_STRESS -DVM_STRESS_MAJOR
|
|||||||
endif
|
endif
|
||||||
ifeq ($(mode),fast)
|
ifeq ($(mode),fast)
|
||||||
cflags += -O3 -DNDEBUG
|
cflags += -O3 -DNDEBUG
|
||||||
#strip = strip
|
strip = strip
|
||||||
#show-size = ls -l
|
show-size = ls -l
|
||||||
endif
|
endif
|
||||||
|
|
||||||
cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(bld)/%.o,$(x)))
|
cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(bld)/%.o,$(x)))
|
||||||
|
126
src/run.cpp
126
src/run.cpp
@ -517,6 +517,37 @@ store(Thread* t, unsigned index)
|
|||||||
BytesPerWord * 2);
|
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
|
object
|
||||||
run(Thread* t)
|
run(Thread* t)
|
||||||
{
|
{
|
||||||
@ -701,15 +732,32 @@ run(Thread* t)
|
|||||||
object array = popObject(t);
|
object array = popObject(t);
|
||||||
|
|
||||||
if (LIKELY(array)) {
|
if (LIKELY(array)) {
|
||||||
if (LIKELY(index >= 0 and
|
if (objectClass(t, array)
|
||||||
static_cast<uintptr_t>(index) < byteArrayLength(t, array)))
|
== arrayBody(t, t->vm->types, Machine::BooleanArrayType))
|
||||||
{
|
{
|
||||||
pushInt(t, byteArrayBody(t, array, index));
|
if (LIKELY(index >= 0 and
|
||||||
|
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 {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d)", index,
|
if (LIKELY(index >= 0 and
|
||||||
byteArrayLength(t, array));
|
static_cast<uintptr_t>(index)
|
||||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
< byteArrayLength(t, array)))
|
||||||
goto throw_;
|
{
|
||||||
|
pushInt(t, byteArrayBody(t, array, index));
|
||||||
|
} else {
|
||||||
|
object message = makeString(t, "%d not in [0,%d)", index,
|
||||||
|
byteArrayLength(t, array));
|
||||||
|
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
|
goto throw_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
exception = makeNullPointerException(t);
|
exception = makeNullPointerException(t);
|
||||||
@ -723,15 +771,31 @@ run(Thread* t)
|
|||||||
object array = popObject(t);
|
object array = popObject(t);
|
||||||
|
|
||||||
if (LIKELY(array)) {
|
if (LIKELY(array)) {
|
||||||
if (LIKELY(index >= 0 and
|
if (objectClass(t, array)
|
||||||
static_cast<uintptr_t>(index) < byteArrayLength(t, array)))
|
== arrayBody(t, t->vm->types, Machine::BooleanArrayType))
|
||||||
{
|
{
|
||||||
byteArrayBody(t, array, index) = value;
|
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 {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d)", index,
|
if (LIKELY(index >= 0 and
|
||||||
byteArrayLength(t, array));
|
static_cast<uintptr_t>(index) < byteArrayLength(t, array)))
|
||||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
{
|
||||||
goto throw_;
|
byteArrayBody(t, array, index) = value;
|
||||||
|
} else {
|
||||||
|
object message = makeString(t, "%d not in [0,%d)", index,
|
||||||
|
byteArrayLength(t, array));
|
||||||
|
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
|
goto throw_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
exception = makeNullPointerException(t);
|
exception = makeNullPointerException(t);
|
||||||
@ -962,7 +1026,7 @@ run(Thread* t)
|
|||||||
fprintf(stderr, "dup2\n");
|
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;
|
sp += 2;
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
@ -1719,9 +1783,9 @@ run(Thread* t)
|
|||||||
|
|
||||||
case iushr: {
|
case iushr: {
|
||||||
int32_t b = popInt(t);
|
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;
|
} goto loop;
|
||||||
|
|
||||||
case ixor: {
|
case ixor: {
|
||||||
@ -2023,7 +2087,7 @@ run(Thread* t)
|
|||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lushr: {
|
case lushr: {
|
||||||
uint64_t b = popLong(t);
|
int64_t b = popLong(t);
|
||||||
uint64_t a = popLong(t);
|
uint64_t a = popLong(t);
|
||||||
|
|
||||||
pushLong(t, a >> b);
|
pushLong(t, a >> b);
|
||||||
@ -2056,6 +2120,32 @@ run(Thread* t)
|
|||||||
}
|
}
|
||||||
} goto loop;
|
} 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_: {
|
case new_: {
|
||||||
uint16_t index = codeReadInt16(t, ip);
|
uint16_t index = codeReadInt16(t, ip);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user