# filled-new-array

## Purpose

Construct an array of the given type and size, filling it with the supplied contents. The type must be an array type. The array's contents must be single-word (that is, no arrays of long or double). The constructed instance is stored as a "result" in the same way that the method invocation instructions store their results, so the constructed instance must be moved to a register with a subsequent move-result-object instruction (if it is to be used).

## Details

Op & Format | Mnemonic / Syntax | Arguments
--- | --- | ---
24 35c | filled-new-array {vD, vE, vF, vG, vA}, type@CCCC | `B:` array size and argument word count (4 bits) `C:` type index (16 bits) `D..G, A:` argument registers (4 bits each)

## Constraints

- The value B must not be greater than 5.
- If B > 0, then D must be a valid register index in the current stack frame.
- If B > 1, then E must be a valid register index in the current stack frame.
- If B > 2, then F must be a valid register index in the current stack frame.
- If B > 3, then G must be a valid register index in the current stack frame.
- If B > 4, then A must be a valid register index in the current stack frame.
- C must be a valid index into the type pool.
- The type denoted by C must be a valid array type descriptor.
- The element size of the type denoted by C must be no larger than 32 bits.
- If the element type is a primitive type, then all actual arguments (vD .. vA, depending on B) must be primitive, too.
- If the element type is a reference type, then all actual arguments (vD .. vA, depending on B) must be references, too.

## Behavior

- An attempt is made to get a reference to the type T the name of which is contained in type pool entry C.
- If T is a reference type and it has not been loaded and resolved before, it is being loaded and resolved. All exceptions that are possible during class loading can occur at this point.
- An attempt is made to create a new array R of type T and length B. All exceptions that are possible during instantiation can occur at this point.
- The elements of R are filled according to the following rules:
  - If B > 0 then R[0] = vD
  - If B > 1 then R[1] = vE
  - If B > 2 then R[2] = vF
  - If B > 3 then R[3] = vG
  - If B > 4 then R[4] = vA
- No reference to R is stored in any register. Instead, R can be accessed by a move-result-object instruction immediately following this filled-new-array instruction.

## Exceptions

- NegativeArraySizeException if vB < 0
- All exceptions that are possible during class loading can occur.
- All exceptions that are possible during instantiation can occur.