1 /* vim: set ts=4 sw=4 tw=99 et:
3 * Copyright (C) 2012 David Anderson
5 * This file is part of JITCraft.
7 * JITCraft is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation, either version 3 of the License, or (at your option)
12 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with
17 * JITCraft. If not, see http://www.gnu.org/licenses/.
19 #ifndef _include_jc_stack_h_
20 #define _include_jc_stack_h_
25 #include "Functions.h"
26 #include "VirtualObjectVisitor.h"
51 Top(LocalSlot *sp, bytecode *pc, Frame *fp)
52 : sp(sp), pc(pc), fp(NULL)
57 : sp(sp), pc(NULL), fp(NULL)
70 Address lifoPosition_;
73 Frame(Frame *prev, bytecode *prevpc, Function *fun, Code *code, Address lifoPosition)
78 lifoPosition_(lifoPosition)
83 return reinterpret_cast<LocalSlot *>(this + 1);
85 LocalSlot *stackBase() {
86 return locals() + code_->nlocals();
88 Function *fun() const {
92 Function *maybeFun() const {
101 bytecode *prevpc() const {
104 Address lifoPosition() const {
105 return lifoPosition_;
107 LocalSlot &arg(unsigned slot) {
108 assert(slot < fun()->nargs());
109 return *(reinterpret_cast<LocalSlot *>(this) - slot - 1);
111 void accept(VirtualObjectVisitor *visitor);
121 static const size_t STACK_SIZE = 1024 * 1024;
130 Frame *pushFrame(Function *fun);
136 void setTop(Top *top) {
140 return Top((LocalSlot *)buffer_);
142 void accept(VirtualObjectVisitor *visitor);
147 #endif // _include_jc_stack_h_