diff -r a350c2cc736a -r 75e385f68b7e jitcraft/Stack.h --- a/jitcraft/Stack.h Fri Jun 29 19:35:17 2012 -0700 +++ b/jitcraft/Stack.h Sat Jun 30 19:38:53 2012 -0700 @@ -21,16 +21,19 @@ #include #include "Utility.h" #include "Code.h" -#include "UnsafeArray.h" namespace jc { + +class Object; +class Array; union LocalSlot { int i32; float f; - void *p; - UnsafeArray *unsafeArray; + Address address; + Object *obj; + Array *array; }; struct Top @@ -56,14 +59,14 @@ Frame *prev_; bytecode *prevpc_; Code *code_; - void *prevUnsafeStack_; + Address lifoPosition_; public: - Frame(Frame *prev, bytecode *prevpc, Code *code, void *prevUnsafeStack) + Frame(Frame *prev, bytecode *prevpc, Code *code, Address lifoPosition) : prev_(prev), prevpc_(prevpc), code_(code), - prevUnsafeStack_(prevUnsafeStack) + lifoPosition_(lifoPosition) { } @@ -82,8 +85,8 @@ bytecode *prevpc() const { return prevpc_; } - void *prevUnsafeStack() const { - return prevUnsafeStack_; + Address lifoPosition() const { + return lifoPosition_; } LocalSlot &arg(unsigned slot) { assert(slot < code()->nargs()); @@ -121,51 +124,6 @@ } }; -// The unsafe stack is designed for structures which interop unsafely with C++. -// In this stack, buffers can be overrun, even inside the VM - but with two -// caveats: -// -// The unsafe stack cannot hold safe references. -// Indirect reads and writes from the unsafe stack cannot escape the unsafe -// stack. -class UnsafeStack -{ - char *buffer_; - char *pos_; - char *end_; - - private: - static const size_t STACK_SIZE = 1024 * 1024; - - public: - UnsafeStack(); - ~UnsafeStack(); - bool initialize(); - - public: - void *position() const { - return pos_; - } - void *allocate(size_t nbytes) { - nbytes = Align(nbytes, kMallocAlignment); - - if (pos_ + nbytes > end_) { - assert(false); - return NULL; - } - - void *ptr = pos_; - pos_ += nbytes; - return ptr; - } - - void unwind(void *to) { - char *p = (char *)to; - assert(p < pos_ && p >= buffer_); - pos_ = p; - } -}; - } #endif // _include_jc_stack_h_