mirror of
https://github.com/CPunch/Cosmo.git
synced 2025-12-05 13:00:46 +00:00
implemented jump table dispatch
- currently only enabled on supported platforms (GNU C Compiler + Clang) - when enabled, sped up examples/fibtest.cosmo by about 20% (avg of 11.179s prior and 8.799 after) NOTE: malicious dumps can trivially cause crashes now by having junk function chunks
This commit is contained in:
13
src/cvm.h
13
src/cvm.h
@@ -8,6 +8,19 @@
|
||||
|
||||
// #define VM_DEBUG
|
||||
|
||||
/*
|
||||
if we're using GNUC or clang, we can use computed gotos which speeds up
|
||||
cosmoV_execute by about 20% from benchmarking. of course, if you know
|
||||
your compiler supports computed gotos, you can define VM_JUMPTABLE
|
||||
|
||||
BTW: be weary of maliciously crafted cosmo dumps!! it's very easy to crash
|
||||
cosmo with this enabled and reading invalid opcodes due to us just using the
|
||||
opcode as an index into the jump table
|
||||
*/
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
# define VM_JUMPTABLE
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COSMOVM_OK,
|
||||
|
||||
Reference in New Issue
Block a user