Skip to content

VmStacks

Sambura edited this page Mar 27, 2024 · 1 revision

Table of Contents

Virtual Machine Stacks

Four stacks exist.

Object stack

This is the main stack in a system. Most of operations either work on top of this stack or involve it in some other way. Contains object references only. Each end every method works with own object stack. On method call a new object stack instance is created. Call arguments are passed from callers stack to called method stack. Number of call arguments is passed on integer stack, as described in detail below. On return from method its object stack is discarded, and the topmost object on stack is returned back to caller (pushed on its object stack). If called method’s object stack is empty on return, null object will be pushed on calling method’s stack.

Term “stack” is usually corresponds to object stack, if other stack is not specified explicitly.

Integer stack

Integer stack is used to do integer math in a fast way. On method call a new integer stack is created and number of passed (on object stack) arguments is pushed on integer stack. On return integer stack is discarded. No value is returned on integer stack. Integer stack can and will be used to process values of other binary data types, such as float, double, boolean, etc.

Exceptions catchers stack

Each method is executed with own catchers stack. See push catcher and pop catcher operations below.

Call stack

Used for return and exception unwind purposes. This stack’s element has all the current executing method stuff: object, integer and exception stacks, ‘this’ object pointer, return address.

Clone this wiki locally