Added RootScopes for AST roots.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of JITCraft.
6 * JITCraft is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
11 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * JITCraft. If not, see http://www.gnu.org/licenses/.
18 #ifndef _include_jc_stack_h_
19 #define _include_jc_stack_h_
24 #include "Functions.h"
47 Top(LocalSlot *sp, bytecode *pc)
66 Address lifoPosition_;
69 Frame(Frame *prev, bytecode *prevpc, Function *fun, Code *code, Address lifoPosition)
74 lifoPosition_(lifoPosition)
79 return reinterpret_cast<LocalSlot *>(this + 1);
81 LocalSlot *stackBase() {
82 return locals() + code_->nlocals();
84 Function *fun() const {
88 Function *maybeFun() const {
97 bytecode *prevpc() const {
100 Address lifoPosition() const {
101 return lifoPosition_;
103 LocalSlot &arg(unsigned slot) {
104 assert(slot < fun()->nargs());
105 return *(reinterpret_cast<LocalSlot *>(this) - slot - 1);
116 static const size_t STACK_SIZE = 1024 * 1024;
125 Frame *pushFrame(Frame *prev, Function *fun);
126 Frame *popFrame(Frame *frame);
131 void setTop(Top *top) {
135 return Top((LocalSlot *)buffer_);
141 #endif // _include_jc_stack_h_