Generate default constructors at compile time.

Also re-ordered a few of the cases in the interpret loop. 
Removing a bit of code from CODE_CLASS and CODE_CALL triggered
some branch alignment issues which had a negative perf impact.
The new ordering seems to cancel that out.
This commit is contained in:
Bob Nystrom
2013-12-12 07:34:16 -08:00
parent e191424a70
commit 4ba5c38bbf
4 changed files with 232 additions and 237 deletions
+23 -23
View File
@@ -22,29 +22,6 @@ typedef enum
// Push true onto the stack.
CODE_TRUE,
// Define a new empty class and push it.
CODE_CLASS,
// Pop a superclass off the stack, then push a new class that extends it.
CODE_SUBCLASS,
// Define a method for symbol [arg] whose body is the function popped off the
// top of the stack. The class receiving the method is on top of the stack
// (after the function is popped off) and remains after this.
CODE_METHOD_INSTANCE,
// Define a method for symbol [arg] whose body is the function popped off the
// top of the stack. The class receiving the method is the metaclass of the
// class on top of the stack (after the function is popped off) and remains
// after this.
CODE_METHOD_STATIC,
// Define a constructor method for symbol [arg] whose body is the function
// popped off the top of the stack. The class receiving the method is the
// metaclass of the class on top of the stack (after the function is popped
// off) and remains after this.
CODE_METHOD_CTOR,
// Create a new list with [arg] elements. The top [arg] values on the stack
// are the elements in forward order. Removes the elements and then pushes
// the new list.
@@ -138,6 +115,29 @@ typedef enum
// stack.
CODE_RETURN,
// Define a new empty class and push it.
CODE_CLASS,
// Pop a superclass off the stack, then push a new class that extends it.
CODE_SUBCLASS,
// Define a method for symbol [arg] whose body is the function popped off the
// top of the stack. The class receiving the method is on top of the stack
// (after the function is popped off) and remains after this.
CODE_METHOD_INSTANCE,
// Define a method for symbol [arg] whose body is the function popped off the
// top of the stack. The class receiving the method is the metaclass of the
// class on top of the stack (after the function is popped off) and remains
// after this.
CODE_METHOD_STATIC,
// Define a constructor method for symbol [arg] whose body is the function
// popped off the top of the stack. The class receiving the method is the
// metaclass of the class on top of the stack (after the function is popped
// off) and remains after this.
CODE_METHOD_CTOR,
// This pseudo-instruction indicates the end of the bytecode. It should
// always be preceded by a `CODE_RETURN`, so is never actually executed.
CODE_END