Native method registry java.lang.Class wtf

This commit is contained in:
vegowotenks 2024-09-09 15:43:26 +02:00
parent 3282694b32
commit b4c428685f
9 changed files with 987 additions and 40 deletions

View file

@ -11,7 +11,7 @@ impl Bytecode {
match opcode {
0x00 => (Instruction::NoOperation(), 1),
0x01 => (Instruction::StoreIntoIntArray(), 1),
0x01 => (Instruction::PushNull(), 1),
0x02 => (Instruction::PushConstIntM1(), 1),
0x03 => (Instruction::PushConstInt0(), 1),
0x04 => (Instruction::PushConstInt1(), 1),
@ -25,7 +25,7 @@ impl Bytecode {
0x10 => (Instruction::LoadByteImmediate(self.bytes[offset+1]), 2),
0x11 => (Instruction::LoadShortImmediate((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
0x12 => (Instruction::LoadConstant(self.bytes[offset+1]), 2),
0x13 => (Instruction::LoadWideConstant((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
0x13 => (Instruction::LoadCostantWide((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
0x14 => (Instruction::LoadConstant64((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
0x1A => (Instruction::LoadLocalInt0(), 1),
@ -59,6 +59,7 @@ impl Bytecode {
0x59 => (Instruction::Duplicate(), 1),
0x68 => (Instruction::MultiplyInt(), 1),
0x6C => (Instruction::DivideInt(), 1),
0x6D => (Instruction::DivideLong(), 1),
0x7A => (Instruction::ShiftIntRight(), 1),
@ -135,6 +136,18 @@ impl Bytecode {
0xBC => (Instruction::NewPrimitiveArray(self.bytes[offset+1]), 2),
0xBD => (Instruction::NewArray((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
0xBE => (Instruction::ArrayLength(), 1),
0xC2 => (Instruction::EnterMonitor(), 1),
0xC3 => (Instruction::ExitMonitor(), 1),
0xC6 => {
let bytes = [self.bytes[offset+1], self.bytes[offset+2]];
(Instruction::BranchNull(i16::from_be_bytes(bytes)), 3)
}
0xC7 => {
let bytes = [self.bytes[offset+1], self.bytes[offset+2]];
(Instruction::BranchNonNull(i16::from_be_bytes(bytes)), 3)
}
_ => (Instruction::Unknown(opcode), 1)
}
}
@ -167,7 +180,7 @@ impl Debug for Bytecode {
#[repr(u8)]
pub enum Instruction {
NoOperation() = 0x00, // No-Operation
StoreIntoIntArray() = 0x01, // ..., arrayref, index, value
PushNull() = 0x01, // ..., arrayref, index, value
PushConstIntM1() = 0x02, // Push -1
PushConstInt0() = 0x03, // Push 0
PushConstInt1() = 0x04, // Push 1
@ -181,7 +194,7 @@ pub enum Instruction {
LoadByteImmediate(u8) = 0x10, // push immediate short
LoadShortImmediate(u16) = 0x11, // push immediate short
LoadConstant(u8) = 0x12, // Push from constant pool
LoadWideConstant(u16) = 0x13, // Push from constant pool with wide index, don't load
LoadCostantWide(u16) = 0x13, // Push from constant pool with wide index, don't load
// double or long or whatever
LoadConstant64(u16) = 0x14, // Push Long or Double from constant pool
LoadLocalInt0() = 0x1A, // Load int from local variable
@ -215,6 +228,7 @@ pub enum Instruction {
Duplicate() = 0x59, // duplicate top stack value
MultiplyInt() = 0x68, // int multiplication
DivideInt() = 0x6C, // integer division, round toward zero and more rules
DivideLong() = 0x6D, // long division
ShiftIntRight() = 0x7a, // shift int
@ -252,5 +266,11 @@ pub enum Instruction {
NewPrimitiveArray(u8) = 0xBC, // make a primitive array
NewArray(u16) = 0xBD, // Create a new array from a constant-pool component class reference
ArrayLength() = 0xBE, // Get length from array reference
EnterMonitor() = 0xC2, // enter the synchronization monitor of an object
ExitMonitor() = 0xC3, // exit the synchronization monitor of an object
BranchNull(i16) = 0xC6, // branch if Null
BranchNonNull(i16) = 0xC7, // branch if Null
Unknown(u8),
}