Advertisement

Need a VM

Started by April 04, 2009 05:00 PM
2 comments, last by WitchLord 15 years, 7 months ago
I program an image codec. It is at http://www.geocities.com/repstsb/libima.html . I need a VM to convert RAW data into RGB data. It would only need to do basic things and support arrays because reading many samples at once is quicker. It would need to be fast, safe and have platform-independent byte code. Could AngelScript do that? Is the bytecode sandboxed? And by this I mean any bytecode and not just bytecode that was generated by AngelScript. If I define AS_MAX_PORTABILITY, would the bytecode be platform independent? Or would someone have another suggestion? Anyway, I think AngelScript is a great idea. I think that one of the most interesting uses of AngelScript would be for writing drivers for an OS.
Do you know Mihai Cartoaje? He has also queried about AngelScript for the libima project.

Quote: Could AngelScript do that?


Yes, AngelScript can be used for what you want.

Quote: Is the bytecode sandboxed? And by this I mean any bytecode and not just bytecode that was generated by AngelScript.


The VM is not sandboxed. The bytecode compiler in AngelScript is providing the sandboxing. This provides better runtime performance. If you want sandboxing in AS you shouldn't use precompiled bytecode.

Quote: If I define AS_MAX_PORTABILITY, would the bytecode be platform independent? Or would someone have another suggestion?


By defining AS_MAX_PORTABILITY and AS_64BIT_PTR you should be able to get platform independent bytecode. I haven't really tested this though.





I wonder if you wouldn't be better off writing a specialized VM for your project. A VM is quite easy to write. The difficult part is writing the compiler, but if you can settle for a simple assembler-like language then that shouldn't be too difficult either.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Quote: Do you know Mihai Cartoaje?

Repstsb is my handle just as WitchLord is yours.
Quote: The VM is not sandboxed. The bytecode compiler in AngelScript is providing the sandboxing. This provides better runtime performance. If you want sandboxing in AS you shouldn't use precompiled bytecode.

The AngelScript compiler is too big to include in an image decoder. It is 4MB.
How foolish of me. I should have checked your profile. ;) I don't know where I got the idea that you had signed another name.

Yeah, I guess embedding a compiler in a decoder would be too much.

Anyway, I think you really should consider writing a specialized VM for the decoder. It would allow you to create optimal instruction sets for your needs. You could for example have 1 specific instruction for modulating two arrays of pixel values. In a more generic VM like AngelScript that would have to be written in several separate instructions, and thus severely impact the performance of the decoder.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement