Commit 332b4f68 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Correct bug where FieldReference did not check the class name; Debug stuff to figure out this bug.

parent 30559e7f
......@@ -130,6 +130,10 @@ More detailed changes:
* Generate JUnit output which can be used in test environments.
* Performed some refactoring on the deserialization/serialization code.
* `tool-classfile`
* Corrected comparison behavior of `FieldReference`, it did not check the
class name, so if a class referred to a field of the same name when
using SummerCoat it will result in the wrong class field being read
from whatever class just happened to be set first.
* Corrected parsing of the stack map table.
* Removed `net.multiphasicapps.classfile.ExecutableCode`, it was not used.
* `tool-profiler`
......
......@@ -102,7 +102,8 @@ public final class Task
*/
public final TaskThread contextThread()
{
todo.DEBUG.note("TODO -- Implement better contextThread().");
todo.DEBUG.note("TODO -- Implement better contextThread(), lid=%d.",
this.lid);
// Could not determine the context thread, use fallback by calling
// any thread and hoping it works
......@@ -229,5 +230,16 @@ public final class Task
// Return the allocated pointer
return rv;
}
/**
* Returns the physical ID of the task.
*
* @return The task physical ID.
* @since 2019/12/14
*/
public final int physicalProcessId()
{
return this.pid;
}
}
......@@ -162,7 +162,22 @@ public final class TaskThread
Task task = Globals.getTaskManager().getTask(this.pid);
// Set the task and enter user mode now
Assembly.sysCallP(SystemCallIndex.FRAME_TASK_ID_SET, task.pid);
todo.DEBUG.code('P', 'i', task.pid);
todo.DEBUG.note("ours=%d ? p=%d task=%d/%d/%d cl=%d cn=%d mn=%d mc=%d",
this.pid,
Assembly.objectToPointer(task),
task.pid,
task.physicalProcessId(),
task.lid,
Assembly.memReadInt(Assembly.objectToPointer(task), 0),
Assembly.memReadInt(Assembly.objectToPointer(task), 4),
Assembly.memReadInt(Assembly.objectToPointer(task), 8),
Assembly.memReadInt(Assembly.objectToPointer(task), 12));
for (int i = 0; i <= 36; i += 4)
todo.DEBUG.note("@%d = %d", i,
Assembly.memReadInt(Assembly.objectToPointer(task), i));
Assembly.sysCallP(SystemCallIndex.FRAME_TASK_ID_SET, task.lid);
// Set new static field register
int oldsfp = Assembly.specialGetStaticFieldRegister();
......
......@@ -65,7 +65,7 @@ public final class ThreadManager
{
TaskThread thread = threads[i];
if (thread == null || thread.processId() == __pid)
if (thread == null || thread.processId() != __pid)
continue;
return thread;
......
......@@ -17,5 +17,40 @@ package java.lang;
public final class Byte
extends Number
{
/** The value of this byte. */
private final byte _value;
/**
* Initializes the byte.
*
* @param __v The value.
* @since 2019/12/14
*/
public Byte(byte __v)
{
this._value = __v;
}
/**
* {@inheritDoc}
* @since 2019/12/14
*/
@Override
public String toString()
{
return Integer.toString(this._value, 10);
}
/**
* Wraps the given byte value.
*
* @param __v The value to wrap.
* @return The wrapped byte.
* @since 2019/12/14
*/
public static final Byte valueOf(byte __v)
{
return new Byte(__v);
}
}
......@@ -295,7 +295,7 @@ public final class Minimizer
}
// If an array, add the length of the array
if (isarray)
else if (isarray)
{
// Synthetic + Transient + Final
sorted.add(0, new Field(new FieldFlags(0x1090),
......@@ -350,11 +350,10 @@ public final class Minimizer
temp._count++;
}
// Always align the field area to 8 bytes so that way if there are
// any long/double in the fields for an object following this, it will
// properly be aligned
// Align fields sizes to 4-bytes always so that the next class on
// top of this has aligned field data
for (__TempFields__ temp : rv)
temp._bytes = (temp._bytes + 7) & ~7;
temp._bytes = (temp._bytes + 3) & ~3;
// Return static and instance fields
return rv;
......
......@@ -383,7 +383,7 @@ public final class NativeCodeBuilder
*
* @param __dt The data type used.
* @param __load Is this a load operation?
* @param __v The value to store.
* @param __v The value to load/store.
* @param __p The pointer.
* @param __o The offset.
* @return The generated instruction.
......
......@@ -143,7 +143,7 @@ public final class NearNativeByteCodeHandler
this.isinstance = __bc.isInstance();
// Determine monitor target register and the volatile base
int volbase = NativeCode.ARGUMENT_REGISTER_BASE + 2 +
int volbase = NativeCode.ARGUMENT_REGISTER_BASE + 3 +
__bc.maxLocals() + __bc.maxStack();
this.monitortarget = volbase;
this.volatiles = new VolatileRegisterStack(volbase + 1);
......@@ -1922,6 +1922,9 @@ public final class NearNativeByteCodeHandler
if (__at == null || __fr == null)
throw new NullPointerException("NARG");
if ("pid".equals(__fr.memberName().toString()))
todo.DEBUG.note("%s -> %s", state.classname, __fr);
// Accessing final fields of another class will always be treated as
// normal despite being in the constructor of a class
if (!state.classname.equals(__fr.className()))
......
......@@ -70,7 +70,8 @@ public final class FieldReference
return false;
FieldReference o = (FieldReference)__o;
return this.name.equals(o.name) &&
return this.classname.equals(o.classname) &&
this.name.equals(o.name) &&
this.type.equals(o.type);
}
......@@ -81,7 +82,8 @@ public final class FieldReference
@Override
public int hashCode()
{
return this.name.hashCode() ^
return this.classname.hashCode() ^
this.name.hashCode() ^
this.type.hashCode();
}
......
......@@ -119,9 +119,15 @@ public final class LoadedClassInfo
if (rv > 0)
return rv;
// Allocation size is the super-class size plus our size
this._allocsize = (rv = this.baseOffset() +
// Find the bootstrap
BootstrapState bootstrap = this.__bootstrap();
// This class is the size of the super class and our size
ClassName supercl = this._class.superName();
this._allocsize = (rv = (supercl == null ? 0 :
bootstrap.findClass(supercl).allocationSize()) +
this._class.header.ifbytes);
return rv;
}
......@@ -779,6 +785,10 @@ public final class LoadedClassInfo
fieldInstanceOffset(af.field.memberName(),
af.field.memberType());
}
if ("pid".equals(af.field.memberName().toString()))
todo.DEBUG.note("%s.pid = %s (%s)",
af.field.className(), vx, this._class.thisName());
break;
// Pointer to class information
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment