deep

a Cross Development Platform for Java

User Tools

Site Tools


dev:crosscompiler:arrays

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
dev:crosscompiler:arrays [2015/03/29 09:41] – [Mehrdimensionale Arrays] ursgrafdev:crosscompiler:arrays [2016/02/25 13:33] – external edit 127.0.0.1
Line 42: Line 42:
 //[[I// and //[I// are the corresponding type descriptors. When accessing an element one has to access a reference in the first dimension followed by the element access in the second dimension.  //[[I// and //[I// are the corresponding type descriptors. When accessing an element one has to access a reference in the first dimension followed by the element access in the second dimension. 
  
-==== Generating an ==== +==== Generating an Multidimensional Array of Basetypes ==== 
-Der folgende Code +The following code  
 <code java> <code java>
   short[][] a = new short[2][3]   short[][] a = new short[2][3]
 </code> </code>
-führt auf den Bytecode+gives a Bytecode
 <code> <code>
 0 iconst_2 0 iconst_2
Line 54: Line 54:
 6 putstatic ch/ntb/inf/deep/runtime/mpc555/test/ArrayTest3.a1: short[][] 6 putstatic ch/ntb/inf/deep/runtime/mpc555/test/ArrayTest3.a1: short[][]
 </code> </code>
-Wenn aber ein Array gleich initialisiert wird, z.B. mit +If an array is immediately initialized 
 <code java> <code java>
   short[][] a2 = {{1,2},{3,4}};   short[][] a2 = {{1,2},{3,4}};
 </code> </code>
-führt das auf den Bytecode+the Bytecode will be
 <code> <code>
 9 iconst_2 9 iconst_2
Line 79: Line 79:
 29 iconst_2 29 iconst_2
 30 newarray short 30 newarray short
-usw.+etc.
 </code> </code>
-Das Problem ist im ersten Falldass nur der Typdescriptor von [[I gelinkt würde. [I muss ebenfalls erzeugt werdenIm Heapmanager muss die Methode //multianewarray// das Array allozieren und insbesondere auch die Referenzen auf [[I und [I setzenDie Referenz auf [[I wird als Parameter übergebenIm Typdescriptor von [[I steht die Referenz auf [I. Die muss dort geholt werden und am richtigen Ort im Object gespeichert werden. \\ +The problem with the first case isthat only the type descriptor //[[I// would be linkedHowever, //[I// must be created as wellIn the method //multianewarray// of the heap manager the array must be allocated and the references to //[[I// and //[I// must be setThe reference to //[[I// is passed as a parameterIn //[[I// there is the reference to //[I//This reference must be fetched and inserted into the object at the appropriate position. \\ 
-Die gleichen Überlegungen gelten auch für Arrays mit höheren DimensionenAuch dort wird //multianewarray// nur in besonderen Situationen verwendet+Similar thoughts are true for arrays with higher dimensionsAs well, the instruction //multianewarray// is used solely for special purposes
-==== Erzeugung von mehrdimensionalen Arrays von Objekten ==== +==== Generating an Multidimensional Array of Objects ==== 
-Hier gelten grundsätzlich die gleichen Bedingungen wie oben +Here, the same conditions are true as described above
-Der folgende Javacode +
 <code java> <code java>
   ClassA[][][] a1 = new ClassA[3][2][2];   ClassA[][][] a1 = new ClassA[3][2][2];
 </code> </code>
-wird in den Bytecode+This leads to Bytecode
 <code> <code>
   0 iconst_3   0 iconst_3
Line 97: Line 96:
   7 astore_1 [a1]   7 astore_1 [a1]
 </code> </code>
-übersetzt. Hier wird also bereits also bereits die korrekte Referenz auf //[[[ClassA;// in die SSA aufgenommenDer Heapmanager muss wie bei den Basistypen aus dem Typdescriptor von //[[[ClassA;// die weiteren Typdescriptoren //[[ClassA;//, //[ClassA;// und //ClassA;// rekursiv holen. +The reference to //[[[ClassA;// can be found already in the SSA. The heap manager has to fetch the base types //[[ClassA;//, //[ClassA;// and //ClassA;// from the type descriptor recursively.
dev/crosscompiler/arrays.txt · Last modified: 2022/12/20 11:24 by ursgraf