Writing nanobots using Java Assembly directly

Jump to navigation Jump to search

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Users.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

Return to Thread:Talk:Code Size/Writing nanobots using Java Assembly directly/reply (3).

I think making use of library may be much useful than micro-optimizing bytecode size. Bytecode tools can be used for a few additional bytes though.

Xor (talk)05:54, 17 May 2019
 

As well as exploring the standard library it's also a good idea to carefully consider the robocode methods as well. For example, I was able to save a few bytes by switching from setTurnRightRadians to setTurnLeftRadians as it allowed me to save the result of getHeadingRadians in a register instead of calling it twice.

I didn't have any success with ProGuard when trying to shrink Quantum but switching to assembly with Krakatau has been quite fruitful. I've been able to save space by using dup to save variables on the stack instead of using local variables, which wouldn't have been possible in plain Java.

After my next update to Quantum I'll write a walkthrough from naive Java to optimised Java and finally down to bytecode. I'll be able to demonstrate most of the techniques listed in this page as well as a few new ideas like my gunheat lock for the radar.

Something I haven't explored yet is whether nested calls to event handlers can be exploited in some way. I don't think I could make use of it in Quantum but if/when I write a nano duelist it might come in handy.

David414 (talk)12:49, 19 May 2024