3 ***DISCLAIMER***: _These notes are from the defunct k8 project which_
4 _precedes SquirrelJME. The notes for SquirrelJME start on 2016/02/26!_
5 _The k8 project was effectively a Java SE 8 operating system and as such_
6 _all of the notes are in the context of that scope. That project is no_
7 _longer my goal as SquirrelJME is the spiritual successor to it._
11 As a side-project I can write a toy Java 8 ME implementation for extremely
12 crippled devices which I doubt Oracle would ever support, or anyone at all.
13 JavaME lacks strong reflection which is a bonus. Essentially what I can do is
14 have it written completely in C or assembly. I would just need class and
15 reference lookups for built-in static classes. It could actually work too. I
16 do wonder though how light it can be however. The thing is though that internal
17 classes will be purely native, while loaded classes would be interpreted or at
18 least some kind of stack caching (similar to JamVM). I could quite possibly
19 target devices such as GameBoys, the N64, TI-83+, ancient Palm PDAs. I can then
20 derive using that and use it as a sort of microsized bootstrap environment
21 for Squirrnix to build on. I could also even support that Zilog eZ80 board I
22 have. Well, The TI-83 I have has 512KiB of flash ROM, 32KiB of RAM, and a
23 6MHz CPU. So these are extremely very low bottom end of the line in terms of
24 today (since these are just basic calculators).
28 The JavaME 8 data sheet says optimized for devices starting at 128KiB of RAM
29 and 1MiB of ROM. Java Card starts from 18KiB ROM and 8KiB RAM, however Java
30 Card does not really do much and is just intended for smart cards. So the
31 question is, which tricks could I use to make this as tiny as possible? Since
32 embedded devices are so embedded, only C should be used in most cases and use
33 assembly where appropriate. I will need to write a super tiny deflate
34 decompression algorithm code though to handle JAR files however. There are 216
35 classes in Java ME 8. The very nice thing about Java ME 8 is that it has NIO
36 and stuff such as FileChannel. This means no more going back to the start of an
37 input stream to get old data.
41 I can actually use a blanketed approach. For example, for all of the exceptions
42 they can be constructed exactly the same and they for the most part have the
43 same exact constructors. Thus all that code is not duplicated due to the fact
44 that they are all virtually the same. I may however have to code for old and
45 potentially broken C compilers though, stuff that is not at least at C99
46 levels. However, I can sort of avoid that. Another thing is the target CPUs
47 would be 8-bit and 16-bit too potentially. I could also support DOS and
48 some other ancient systems too. I suppose for minimum string usage, I will have
49 to have a dedicated pool for strings and then reference them by their constants
50 based on which index they are at. For minimal memory usage, although char is
51 16-bits, the strings should be stored as UTF-8 with some kind of length
52 attached. A string table builder with a processor thing can handle that though,
53 at least deciding which string to use. It would be done where the table is
54 indexed directly rather than having an actual table. When it comes to Strings
55 though, the object would need a direct memory reference. This means that
56 the code will need memory models. There would either be a 16-bit or 32-bit
57 memory model. However, I do wonder if I can have a kind of compressed pointer
58 of sorts by using only a 8-bit value. That would be very limited however. The
59 VM could be multi-threaded but with locks on objects and other flags for
60 objects to determine what it is for example.
64 I could also target stuff such as OpenFirmware on PowerPC and the BIOS while
65 still having some kind of Java in it. So for example in GRUB for the x86, you
66 can just have a JAR module which is loaded also and it runs right from it.
67 This could be an actually interesting project. I do know that Palm PDAs are
68 good enough (even the very ancient ones such as the IIIxe) are juicy enough to
69 actually have a decent setup.
73 The one thing I will have to do though is premature optimization, I MUST
74 optimize for the smallest code size possible. Targetting more advanced Game
75 Boys and such should be possible also. The only real limitation is ROM size
76 limitations, assuming ROM is executable. The SNES for example has 128KiB of
77 RAM which is at the JavaME 8 supposed limit.
81 Actually I like JavaME 8 already, it has `String.format`! No need to roll my
82 own at all! Well, the thing with C is that I have to be careful with memory
83 but I can easily just use the stack without issue.
87 Means for exception handling and such I am going to need setjmp and longjmp so
92 The most important thing though with C is source organization, I need to find
93 the best way to organize.
97 I also need to avoid using 64-bit types since that is a rather new concept
102 I believe I will move my code off to another repository and keep it separated
103 from this. Although I really do like this single set of repository however. I
104 believe I will not do this and just keep it here.
108 Well if it ever gets super popular I can just split if off then, which will
113 Actually I can sort of see this as becoming my operating system sort of,
114 although I would have preferred it purely in Java.
118 Actually this might get ugly due to namespace lackings.
122 Yes, I believe I am going to fork things off so it can be standalone and a bit
123 cleaner. Even though I have worked on my OS for two years almost I seem to not
124 be getting anywhere. Perhaps after writing this SquirrnixME I can gain the
125 required experience to come back to this. If I ever get stumped I can always
126 just come back to this too for example.
130 Writing code for SquirrnixME instead, however I just came by to say that during
131 my dump writer work (since I already wrote a bunch of the supporting code) I
132 found that DescriptorField does not have equals(). Actually forget that, it is
133 handled by the super class.
137 Had to implement handling of field value constants so that information could