Converts an OOMIR module into JVM class files Returns a HashMap where the key is the JVM class name (with '/') and the value is the bytecode
(
module: &oomir::Module,
_tcx: TyCtxt, // Keep tcx in signature if needed later, but unused now
)
| 33 | }; |
| 34 | |
| 35 | mod constant_pool; |
| 36 | mod consts; |
| 37 | mod helpers; |
| 38 | mod jvm; |
| 39 | mod jvm_gen; |
| 40 | mod large_methods; |
| 41 | mod optimise2; |
| 42 | mod stackmaps; |
| 43 | mod translator; |
| 44 | |
| 45 | pub const F128_CLASS: &str = "org/rustlang/runtime/F128"; |
| 46 | pub const I128_CLASS: &str = "org/rustlang/runtime/I128"; |
| 47 | pub const U128_CLASS: &str = "org/rustlang/runtime/U128"; |
| 48 | |
| 49 | static OUTPUT_DIRECTORY_COUNTER: AtomicUsize = AtomicUsize::new(0); |
| 50 | |
| 51 | #[derive(Default)] |
| 52 | pub(crate) struct EmittedClassRegistry { |
| 53 | variants: Mutex<HashMap<String, Vec<Arc<EmittedClassVariant>>>>, |
| 54 | } |
| 55 | |
| 56 | struct EmittedClassVariant { |
| 57 | hash: u64, |
| 58 | len: usize, |
| 59 | state: Mutex<EmittedClassState>, |
| 60 | ready: Condvar, |
| 61 | } |
| 62 | |
| 63 | enum EmittedClassState { |
| 64 | Pending, |
| 65 | Ready(Arc<[u8]>), |
| 66 | } |
| 67 | |
| 68 | fn bytecode_hash(bytecode: &[u8]) -> u64 { |
| 69 | bytecode.iter().fold(0xcbf29ce484222325u64, |hash, byte| { |
| 70 | (hash ^ u64::from(*byte)).wrapping_mul(0x100000001b3) |
| 71 | }) |
| 72 | } |
| 73 | |
| 74 | fn factory_return_instruction(ty: &oomir::Type) -> Instruction { |
| 75 | match ty { |
| 76 | oomir::Type::I8 |
| 77 | | oomir::Type::U8 |
| 78 | | oomir::Type::I16 |
| 79 | | oomir::Type::U16 |
| 80 | | oomir::Type::F16 |
| 81 | | oomir::Type::I32 |
| 82 | | oomir::Type::U32 |
| 83 | | oomir::Type::Boolean |
| 84 | | oomir::Type::Char => Instruction::Ireturn, |
| 85 | oomir::Type::I64 | oomir::Type::U64 => Instruction::Lreturn, |
| 86 | oomir::Type::F32 => Instruction::Freturn, |
| 87 | oomir::Type::F64 => Instruction::Dreturn, |
| 88 | oomir::Type::Str |
| 89 | | oomir::Type::Class(_) |
| 90 | | oomir::Type::Array(_) |
| 91 | | oomir::Type::Slice(_) |
| 92 | | oomir::Type::Reference(_) |
no test coverage detected