ristretto_jit 0.33.0

JVM JIT Compiler
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::util::create_function;
use ristretto_classfile::attributes::{ArrayType, Instruction};
use ristretto_jit::{Result, Value};

#[test]
fn newarray_and_arraylength() -> Result<()> {
    let instructions = vec![
        Instruction::Bipush(10),
        Instruction::Newarray(ArrayType::Int),
        Instruction::Arraylength,
        Instruction::Ireturn,
    ];
    let function = create_function("()I", &instructions)?;
    let value = function.execute(&[], std::ptr::null())?.expect("value");
    assert_eq!(value, Value::I32(10));
    Ok(())
}