5 I wonder how valid it would be for `newarray` and `anewarray` to return the
6 same object if an attempt is made to allocate an array of zero length for a
11 Time to start delving into the native code generation and SSA stuff since I
12 will need that for the invocation of methods. The first thing I will do is the
13 native compiler core so that the code generator and parsers are in separated
14 parts along with the personalities split apart.
18 Ok so as I have stated on the 20th of this month, the SSA and basic block
19 layout will remain simple so that although it would not heavily be that
20 optimized it should result in faster JITs for much weaker systems. The
21 resulting code should be smaller and faster than a literal pure interpreter
22 translation of the byte code. In essence, SSA will only be really performed
23 within the internals of the basic block rather than the entire method. So to
24 keep things simple, writes to locals will always be performed and basic blocks
25 will start on methods. So the instruction before the method is called, if
26 anything is on the stack it is calculated and stored into variables. Then at
27 the start of the new block which has the method call, the arguments are passed
28 around to the sub-method and existing stack storage places are ignored. Also,
29 getting and putting of fields will be the start of basic blocks also. Also, any
30 jump target is the start of a basic block. An exception for getting of a field
31 that is not the start of a basic block will be one which is final and has a
32 constant value assigned to it. That will just use the given value of the
33 field as a temporary, however this might not always be possible for instances.
34 I can also perform basic optimization with locals. For example if a local is
35 pushed to the stack and it is checked for null or an array operation is
36 performed then its length is "known" or it is null/not-null. So this means that
37 in addition to jump targets, I need to consider local variable sets. If a local
38 variable is set by any instruction then it cannot use a global cached state.
39 For example, the input of a method, the local variable for this if not changed
40 by the method it will be known that it is always non-null so it will be flagged
41 as such. However if the given parameter is changed, then it will be null
42 checked in each basic block. The resulting SSA would not produce the fastest
43 code, but the code generator should run fast and not use that much memory
48 Actually, not too sure if this would even be SSA.
52 It would be somewhat SSA inspired however.
56 When the sorting algorithms are implemented, there will quite literally be
57 quite a number of duplicate code which does similar things when sorting.
61 However, if I choose merge sort then the sort of an array can just recursively
62 call itself. That is, it would split as small as possible and then call the
63 from index and to index variant to sort the internal section. There would be
64 function all overhead, especially with very large arrays however. It would
65 be possible that there would not be enough stack space to call that many