refactor assertions so they can be disabled easily at compile time; fix a couple of method invocation bugs

This commit is contained in:
Joel Dice 2007-06-22 17:17:13 -06:00
parent 5ee38e259a
commit 39bbcc03eb
5 changed files with 37 additions and 9 deletions

View File

@ -1,20 +1,30 @@
public class Test {
public static void main(String[] args) {
private static void small() {
for (int i = 0; i < 1024; ++i) {
byte[] a = new byte[4 * 1024];
}
}
private static void medium() {
for (int i = 0; i < 8; ++i) {
Object[] array = new Object[32];
for (int j = 0; j < 32; ++j) {
array[j] = new byte[32 * 1024];
}
}
}
private static void large() {
for (int i = 0; i < 8; ++i) {
byte[] a = new byte[16 * 1024 * 1024];
}
}
public static void main(String[] args) {
small();
medium();
large();
}
}

View File

@ -171,7 +171,7 @@ $(generator-objects): $(bld)/%.o: $(src)/%.cpp
@mkdir -p $(dir $(@))
$(cxx) $(generator-cflags) -c $(<) -o $(@)
$(fast-objects): $(bld)/fast-%.o: $(src)/%.cpp
$(fast-objects): $(bld)/fast-%.o: $(src)/%.cpp $(interpreter-depends)
@echo "compiling $(@)"
@mkdir -p $(dir $(@))
$(cxx) $(fast-cflags) -c $(<) -o $(@)

View File

@ -567,14 +567,13 @@ system(Context* c)
inline void NO_RETURN
abort(Context* c)
{
c->system->abort(); // this should not return
::abort();
abort(c->system);
}
inline void
assert(Context* c, bool v)
{
if (UNLIKELY(not v)) abort(c);
assert(c->system, v);
}
void

View File

@ -45,6 +45,25 @@ class System {
}
};
inline void NO_RETURN
abort(System* s)
{
s->abort(); // this should not return
::abort();
}
#ifdef NDEBUG
inline void
assert(System*, bool)
{ }
#else
inline void
assert(System* s, bool v)
{
if (UNLIKELY(not v)) abort(s);
}
#endif
} // namespace vm
#endif//SYSTEM_H

View File

@ -174,14 +174,13 @@ class RawMonitorResource {
inline void NO_RETURN
abort(Thread* t)
{
t->vm->system->abort(); // this should not return
::abort();
abort(t->vm->system);
}
inline void
assert(Thread* t, bool v)
{
if (UNLIKELY(not v)) abort(t);
assert(t->vm->system, v);
}
Machine::Machine(System* system, Heap* heap, ClassFinder* classFinder):
@ -1727,7 +1726,7 @@ resolve(Thread* t, object pool, unsigned index,
object (*find)(Thread*, object, object))
{
object o = arrayBody(t, pool, index);
if (objectClass(o) == arrayBody(t, t->vm->types, Machine::ByteArrayType)) {
if (objectClass(o) == arrayBody(t, t->vm->types, Machine::ReferenceType)) {
PROTECT(t, pool);
object class_ = resolveClass(t, o, referenceClass);
@ -3126,6 +3125,7 @@ run(Thread* t)
sp -= parameterCount;
frame = makeFrame(t, code, frame, 0, sp,
codeMaxLocals(t, methodCode(t, code)), false);
code = methodCode(t, code);
memcpy(&frameLocals(t, frame, 0), stack + sp, parameterCount * BytesPerWord);