This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dev:crosscompiler:arrays [2017/03/01 09:42] – ursgraf | dev:crosscompiler:arrays [2022/12/20 11:24] (current) – ursgraf | ||
---|---|---|---|
Line 5: | Line 5: | ||
The field //length// denotes the number of elements of the array (16 bit). //heap// is used for the garbage collection ([[..: | The field //length// denotes the number of elements of the array (16 bit). //heap// is used for the garbage collection ([[..: | ||
When accessing array elements the code generator inserts code to check if the element index is in the range 0 to // | When accessing array elements the code generator inserts code to check if the element index is in the range 0 to // | ||
- | If the field //length// is used in Java the Bytecode instruktion // | + | If the field //length// is used in Java the Bytecode instruktion // |
===== Generating Arrays ===== | ===== Generating Arrays ===== | ||
Line 28: | Line 28: | ||
< | < | ||
0 iconst_4 | 0 iconst_4 | ||
- | 1 anewarray | + | 1 anewarray |
- | 4 putstatic | + | 4 putstatic |
</ | </ | ||
Here, as well, the reference to //[ClassA// has to be fetched from the object directory when generating the SSA. There are cases when there is no entry for // | Here, as well, the reference to //[ClassA// has to be fetched from the object directory when generating the SSA. There are cases when there is no entry for // | ||
Line 47: | Line 47: | ||
short[][] a = new short[2][3] | short[][] a = new short[2][3] | ||
</ | </ | ||
- | gives a Bytecode | + | leads to the Bytecode |
< | < | ||
0 iconst_2 | 0 iconst_2 | ||
1 iconst_3 | 1 iconst_3 | ||
2 multianewarray short[][] | 2 multianewarray short[][] | ||
- | 6 putstatic | + | 6 putstatic |
</ | </ | ||
If an array is immediately initialized | If an array is immediately initialized |