mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-16 20:28:04 +01:00
Inline the bytecode array in ObjFn.
This commit is contained in:
@ -114,7 +114,6 @@ ObjFn* wrenNewFunction(WrenVM* vm)
|
||||
// Allocate these before the function in case they trigger a GC which would
|
||||
// free the function.
|
||||
// TODO: Hack! make variable sized.
|
||||
unsigned char* bytecode = allocate(vm, sizeof(Code) * 1024);
|
||||
Value* constants = allocate(vm, sizeof(Value) * 256);
|
||||
|
||||
ObjFn* fn = allocate(vm, sizeof(ObjFn));
|
||||
@ -122,7 +121,6 @@ ObjFn* wrenNewFunction(WrenVM* vm)
|
||||
|
||||
fn->numConstants = 0;
|
||||
fn->numUpvalues = 0;
|
||||
fn->bytecode = bytecode;
|
||||
fn->constants = constants;
|
||||
|
||||
return fn;
|
||||
|
||||
@ -168,10 +168,12 @@ typedef struct
|
||||
Obj obj;
|
||||
int numConstants;
|
||||
int numUpvalues;
|
||||
unsigned char* bytecode;
|
||||
|
||||
// TODO: Flexible array?
|
||||
Value* constants;
|
||||
|
||||
// TODO: Hack! Don't hardcode.
|
||||
unsigned char bytecode[1024];
|
||||
} ObjFn;
|
||||
|
||||
// An instance of a first-class function and the environment it has closed over.
|
||||
|
||||
@ -332,7 +332,6 @@ static void freeObj(WrenVM* vm, Obj* obj)
|
||||
switch (obj->type)
|
||||
{
|
||||
case OBJ_FN:
|
||||
deallocate(vm, ((ObjFn*)obj)->bytecode);
|
||||
deallocate(vm, ((ObjFn*)obj)->constants);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user