Fix primitive array handling

This commit is contained in:
Mike Hearn 2017-01-19 16:41:01 +00:00 committed by exfalso
parent f7a651d6ba
commit 539af98836
4 changed files with 23 additions and 14 deletions

View File

@ -258,6 +258,7 @@ const unsigned ACC_SUPER = 1 << 5;
const unsigned ACC_SYNCHRONIZED = ACC_SUPER; const unsigned ACC_SYNCHRONIZED = ACC_SUPER;
const unsigned ACC_VOLATILE = 1 << 6; const unsigned ACC_VOLATILE = 1 << 6;
const unsigned ACC_TRANSIENT = 1 << 7; const unsigned ACC_TRANSIENT = 1 << 7;
const unsigned ACC_VARARGS = 1 << 7;
const unsigned ACC_NATIVE = 1 << 8; const unsigned ACC_NATIVE = 1 << 8;
const unsigned ACC_INTERFACE = 1 << 9; const unsigned ACC_INTERFACE = 1 << 9;
const unsigned ACC_ABSTRACT = 1 << 10; const unsigned ACC_ABSTRACT = 1 << 10;

View File

@ -125,10 +125,15 @@ using namespace avian::util;
type2 name2; \ type2 name2; \
} MAKE_NAME(resource_)(t, name1, name2); } MAKE_NAME(resource_)(t, name1, name2);
AVIAN_EXPORT void vmPrintTrace(vm::Thread* t);
AVIAN_EXPORT void vmfPrintTrace(vm::Thread* t, FILE* out);
namespace vm { namespace vm {
const bool Verbose = false; const bool Verbose = false;
const bool DebugRun = false; const bool DebugRun = false;
const bool DebugCalls = false;
const bool DebugStack = false; const bool DebugStack = false;
const bool DebugMonitors = false; const bool DebugMonitors = false;
const bool DebugReferences = false; const bool DebugReferences = false;
@ -2559,10 +2564,6 @@ void popResources(Thread* t);
} // namespace vm } // namespace vm
AVIAN_EXPORT void vmPrintTrace(vm::Thread* t);
AVIAN_EXPORT void vmfPrintTrace(vm::Thread* t, FILE* out);
namespace vm { namespace vm {
void dumpHeap(Thread* t, FILE* out); void dumpHeap(Thread* t, FILE* out);

View File

@ -4880,9 +4880,8 @@ uint64_t jvmGetClassDeclaredConstructors(Thread* t, uintptr_t* arguments)
GcMethod* vmMethod = cast<GcMethod>(t, table->body()[i]); GcMethod* vmMethod = cast<GcMethod>(t, table->body()[i]);
PROTECT(t, vmMethod); PROTECT(t, vmMethod);
if (((not publicOnly) or (vmMethod->flags() & ACC_PUBLIC)) bool isCtor = strcmp(reinterpret_cast<char*>(vmMethod->name()->body().begin()), "<init>") == 0;
and strcmp(reinterpret_cast<char*>(vmMethod->name()->body().begin()), if (((not publicOnly) or (vmMethod->flags() & ACC_PUBLIC)) and isCtor) {
"<init>") == 0) {
object method = makeJconstructor(t, vmMethod, i); object method = makeJconstructor(t, vmMethod, i);
assertT(t, ai < objectArrayLength(t, array)); assertT(t, ai < objectArrayLength(t, array));

View File

@ -574,10 +574,11 @@ unsigned invokeNativeSlow(Thread* t, GcMethod* method, void* function)
uint64_t result; uint64_t result;
if (DebugRun) { if (DebugRun) {
signed char *cname = method->class_() && method->class_()->name() ? method->class_()->name()->body().begin() : (signed char*) "?";
signed char *mname = method->name() ? method->name()->body().begin() : (signed char*) "?";
fprintf(stderr, fprintf(stderr,
"invoke native method %s.%s\n", "invoke native method %s.%s\n",
method->class_()->name()->body().begin(), cname, mname);
method->name()->body().begin());
} }
{ {
@ -785,12 +786,13 @@ loop:
instruction = code->body()[ip++]; instruction = code->body()[ip++];
if (DebugRun) { if (DebugRun) {
GcMethod *method_ = frameMethod(t, frame);
signed char *cname = method_->class_() && method_->class_()->name() ? method_->class_()->name()->body().begin() : (signed char*) "?";
signed char *mname = method_->name() ? method_->name()->body().begin() : (signed char*) "?";
fprintf(stderr, fprintf(stderr,
"ip: %d; instruction: 0x%x in %s.%s ", "ip: %d; instruction: 0x%x in %s.%s ",
ip - 1, ip - 1,
instruction, instruction, cname, mname);
frameMethod(t, frame)->class_()->name()->body().begin(),
frameMethod(t, frame)->name()->body().begin());
int line = findLineNumber(t, frameMethod(t, frame), ip); int line = findLineNumber(t, frameMethod(t, frame), ip);
switch (line) { switch (line) {
@ -2989,6 +2991,12 @@ invoke : {
if (method->flags() & ACC_NATIVE) { if (method->flags() & ACC_NATIVE) {
invokeNative(t, method); invokeNative(t, method);
} else { } else {
if (DebugCalls && method) {
printf("invoke %s.%s\n",
method->class_() && method->class_()->name() ? (const char *)method->class_()->name()->body().begin() : "<?>",
method->name() ? (const char *)method->name()->body().begin() : "<?>"
);
}
checkStack(t, method); checkStack(t, method);
pushFrame(t, method); pushFrame(t, method);
} }
@ -2996,8 +3004,8 @@ invoke : {
goto loop; goto loop;
throw_: throw_:
if (DebugRun) { if (DebugRun || DebugCalls) {
fprintf(stderr, "throw\n"); fprintf(stderr, "throw @ %s\n", frameMethod(t, frame)->name()->body().begin());
} }
pokeInt(t, t->frame + FrameIpOffset, t->ip); pokeInt(t, t->frame + FrameIpOffset, t->ip);