Main Page   Class Hierarchy   Compound List   File List   Header Files   Compound Members   File Members  

stack.h

This is the verbatim text of the stack.h include file.
/* Sun-$Revision: 23.6 $ */

/* Copyright 1992-9 Sun Microsystems, Inc. and Stanford University.
   See the LICENSE file for license information. */

# pragma interface

// A stack is a part of a process.  It contains the memory area used for
// the stack frames and provides iteration methods etc.

extern int32 FrameChainNesting;   // are nmethods on stacks chained? (>0 = yes)

const int32 PrimStackSize   = 32*K; // max. stack size used by primitives
const int32 StackMarkOffset =  2*K; // to detect stack overflows in the VM

class Stack: public StackObj {
 public:
  Process* process;
  char* base;
  int32 size;
  
  Stack() {}            // stacks are created implicitly as part of processes
  void init(Process* p, char* b, int32 s) { process = p; base = b; size = s; }
  bool allocate();
  void deallocate();
  
  char* end()                           { return base + size; }
  bool  contains(void* sp)              { return base <= (char*)sp
                                             && (char*)sp < end(); }
  char* spLimit()                         { return base + PrimStackSize; }
  bool  isStackOverflow(void* spVal)
    { return base <= (char*)spVal && (char*)spVal < spLimit(); }
  
 protected:
  int32* mark_addr()    { return (int32*)(base + StackMarkOffset); }
 public:
  void mark();          // mark end of stack to detect overflows
  bool markDestroyed(); // answer true if stack mark was overwritten

  // frame operations
  frame* last_self_frame(bool includePrologue, RegisterLocator** = NULL);
                                // return last (most recent) Self frame, & optionally a RegisterLocator
  frame* callee_of(const frame* f);
  frame* first_VM_frame();      // frame called by last_self_frame()
  void   consistencyCheck(primDoFn f, frame* firstVmFrame = NULL);
  
  frame* interpreter_frame_for_continuing_NLR_from_primitive();
  frame* interpreter_frame_for_continuing_from_return_trap();
  
 protected:
   frame* find_frame_entering(char* ep);
   
 public:
  // memory operations
  void chainFrames();
  void unchainFrames();
  void scavenge_contents();
  void gc_mark_contents();
  void gc_unmark_contents();
  void enumerate_references(enumeration *e);
  void enumerate_families(enumeration *e);
  void verify();
  void switch_pointers(oop from, oop to);
  void remove_patches();
 protected:
  void enumerate_block_references();
  
    
 public:
  void frames_do(framesDoFn f, primDoFn pfn = NULL);
        // apply f to all Self frames; pfn is for consistency check
  void vframes_do(vframesDoFn fn, frame* f = NULL);
        // apply fn to all Self vframes, or start at f if non-null
  
  // programming operations
  void convert();
  
 public:
  // printing operations
  void print();
  int32 depth();
  int32 vdepth(frame* f = NULL);
};

extern "C" {
  void print_stack();
  void CallFramesDo(Stack*, framesDoFn, primDoFn);
}

Generated at Tue Jun 27 12:10:34 2000 for SelfVM by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999