00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 class vframe: public PrintableResourceObj {
00042  private:
00043   
00044   
00045   virtual oop callee_argument_at(int index) const;
00046 
00047  protected:
00048   frame _fr;
00049 
00050   vframe(const frame* fr) { _fr = *fr; }        
00051 
00052  public:
00053   
00054   static vframe* new_vframe(frame* f);
00055 
00056   
00057   frame fr() const { return _fr; }
00058 
00059   
00060   virtual vframe* sender() const;
00061 
00062   
00063   
00064   virtual bool is_top() const { return true; }
00065 
00066   
00067   virtual vframe* top() const;          
00068 
00069   
00070   virtual bool equal(const vframe* f) const;
00071 
00072   
00073   virtual bool is_c_frame()           const { return false; }
00074   virtual bool is_c_chunk()           const { return false; }
00075   virtual bool is_delta_frame()       const { return false; }
00076   virtual bool is_interpreted_frame() const { return false; }
00077   virtual bool is_compiled_frame()    const { return false; }
00078   virtual bool is_deoptimized_frame() const { return false; }
00079 
00080   
00081   virtual void print_value() const;
00082   virtual void print();
00083 
00084   
00085   virtual void verify() const {};
00086 
00087   
00088   friend class interpretedVFrame;
00089   friend class compiledVFrame;
00090   friend class cVFrame;
00091   friend class deltaVFrame;
00092   friend class deoptimizedVFrame;
00093 };
00094 
00095 class deltaVFrame: public vframe {
00096  private:
00097    oop callee_argument_at(int index) const; 
00098 
00099  public:
00100   
00101   deltaVFrame(const frame* fr) : vframe(fr) {}
00102 
00103   bool is_delta_frame() const   { return true; }
00104 
00105   
00106   virtual oop receiver() const                  = 0;
00107 
00108   
00109   virtual methodOop method() const              = 0;
00110 
00111   
00112   virtual int bci() const                       = 0;
00113 
00114   virtual oop temp_at(int offset) const         = 0;
00115   virtual oop expression_at(int index) const    = 0;
00116   virtual oop context_temp_at(int offset) const = 0;
00117 
00118   
00119   
00120   
00121   
00122   virtual contextOop canonical_context() const = 0;
00123 
00124   
00125   virtual GrowableArray<oop>* expression_stack() const = 0;
00126 
00127   
00128   
00129   
00130   
00131   
00132   
00133   virtual deltaVFrame* parent() const           = 0;
00134   
00135   
00136   deltaVFrame* sender_delta_frame() const; 
00137 
00138   
00139   GrowableArray<oop>* arguments() const;
00140 
00141   
00142   oop argument_at(int index) const;
00143 
00144   
00145   void print();
00146   void print_activation(int index) const;
00147 
00148   
00149   void verify() const;
00150   virtual void verify_debug_info() const {};
00151 };
00152 
00153 
00154 
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162 class interpretedVFrame: public deltaVFrame {
00163  public: 
00164   
00165   interpretedVFrame(frame* fr) : deltaVFrame(fr) {};
00166 
00167   
00168   void set_receiver(oop obj);
00169 
00170   
00171   u_char* hp() const;
00172   void  set_hp(u_char* p);
00173 
00174   
00175   void temp_at_put(int offset, oop obj);
00176 
00177   
00178   void expression_at_put(int index, oop obj);
00179 
00180   
00181   
00182   contextOop interpreter_context() const;
00183 
00184  private:
00185   static const int temp_offset;
00186   static const int hp_offset;
00187   static const int receiver_offset;
00188   static const int argument_offset;
00189   oop* expression_addr(int offset) const;
00190   bool has_interpreter_context() const;
00191 
00192  public:
00193   
00194   bool is_interpreted_frame() const     { return true; }
00195   bool equal(const vframe* f) const;
00196 
00197  public:
00198   
00199   oop receiver() const;
00200   methodOop method() const;
00201   int bci() const;
00202   oop temp_at(int offset) const;
00203   oop expression_at(int index) const;
00204   oop context_temp_at(int offset) const;
00205   contextOop canonical_context() const;
00206   GrowableArray<oop>* expression_stack() const;
00207   deltaVFrame* parent() const;
00208   void verify() const;
00209 };
00210 
00211 #ifdef DELTA_COMPILER
00212 
00213 class compiledVFrame: public deltaVFrame {
00214  public:
00215   
00216   static compiledVFrame* new_vframe(const frame* fr, ScopeDesc* sd, int bci);
00217   compiledVFrame(const frame* fr, ScopeDesc* sd, int bci);
00218 
00219   
00220   nmethod*  code() const;
00221 
00222   
00223   ScopeDesc* scope() const { return sd; }
00224 
00225   
00226   
00227   contextOop compiledVFrame::compiled_context() const;
00228 
00229   
00230   void rewind_bci(); 
00231 
00232   
00233   virtual ScopeDesc* parent_scope() const = 0;
00234 
00235  protected:
00236   ScopeDesc* sd;
00237   int        _bci;
00238 
00239   static contextOop compute_canonical_context(ScopeDesc* sd, const compiledVFrame* vf, contextOop con = NULL);
00240   static oop        resolve_name             (NameDesc* nd,  const compiledVFrame* vf, contextOop con = NULL);
00241   static oop        resolve_location         (Location loc,  const compiledVFrame* vf, contextOop con = NULL);
00242 
00243   
00244   
00245   
00246   
00247   static oop filler_oop();
00248 
00249   
00250   
00251   int  bci_for(ScopeDesc* d) const;
00252 
00253   friend struct MemoizedBlockNameDesc;
00254   friend class  blockClosureOopDesc;
00255  public:
00256   
00257   bool is_compiled_frame() const { return true; }
00258   vframe* sender() const;
00259   bool equal(const vframe* f) const;
00260 
00261  public:
00262   
00263   methodOop method() const;
00264   int  bci() const;
00265   oop temp_at(int offset) const;
00266   oop expression_at(int index) const;
00267   oop context_temp_at(int offset) const;
00268   GrowableArray<oop>* expression_stack() const;
00269   void verify() const;
00270   void verify_debug_info() const;
00271 };
00272 
00273 class compiledMethodVFrame : public compiledVFrame {
00274  public:
00275   
00276   compiledMethodVFrame(const frame* fr, ScopeDesc* sd, int bci);
00277 
00278  public:
00279   
00280   bool is_top() const;
00281 
00282  public:
00283   
00284   deltaVFrame* parent() const { return NULL; }
00285   contextOop canonical_context() const;
00286   oop  receiver() const;
00287   
00288   ScopeDesc* parent_scope() const { return NULL; }
00289 };
00290 
00291 class compiledBlockVFrame : public compiledVFrame {
00292  public:
00293   
00294   compiledBlockVFrame(const frame* fr, ScopeDesc* sd, int bci);
00295 
00296  public:
00297   
00298   bool is_top() const;
00299 
00300  public:
00301   
00302   deltaVFrame* parent() const;
00303   contextOop canonical_context() const;
00304   oop  receiver() const;
00305   
00306   ScopeDesc* parent_scope() const;
00307 };
00308 
00309 class compiledTopLevelBlockVFrame : public compiledVFrame {
00310  public:
00311   
00312   compiledTopLevelBlockVFrame(const frame* fr, ScopeDesc* sd, int bci);
00313 
00314  public:
00315   
00316   bool is_top() const { return true; }
00317 
00318  public:
00319   
00320   oop  receiver() const;
00321   contextOop canonical_context() const;
00322   deltaVFrame* parent() const;
00323   
00324   ScopeDesc* parent_scope() const;
00325 };
00326 
00327 
00328 
00329 
00330 class deoptimizedVFrame: public deltaVFrame {
00331  public:
00332   
00333   deoptimizedVFrame(const frame* fr);
00334   deoptimizedVFrame(const frame* fr, int offset);
00335 
00336   
00337   
00338   contextOop deoptimized_context() const;
00339 
00340  private:
00341   int offset;
00342   objArrayOop frame_array;
00343 
00344   
00345   objArrayOop retrieve_frame_array() const;
00346 
00347   
00348   oop  obj_at(int index) const;
00349   int  end_of_expressions() const;
00350 
00351   enum {
00352     receiver_offset     = 0,
00353     method_offset       = 1,
00354     bci_offset          = 2,
00355     locals_size_offset  = 3,
00356     first_temp_offset   = 4,
00357   };
00358 
00359   friend class StackChunkBuilder;
00360 
00361  public:
00362   
00363   bool equal(const vframe* f) const;
00364   bool is_deoptimized_frame() const { return true; }
00365   vframe* sender() const;
00366   bool is_top() const;
00367 
00368  public:
00369   
00370   oop receiver() const;
00371   methodOop method() const;
00372   int bci() const;
00373   deltaVFrame* parent() const { return NULL; }
00374   oop temp_at(int offset) const;
00375   oop expression_at(int index) const;
00376   oop context_temp_at(int offset) const;
00377   GrowableArray<oop>* expression_stack() const;
00378   contextOop canonical_context() const;
00379 };
00380 
00381 #endif
00382 
00383 class cVFrame: public vframe {
00384  public:
00385   
00386   cVFrame(const frame* fr) : vframe(fr) {}
00387 
00388  public:
00389   
00390   bool is_c_frame() const { return true; }
00391   void print_value() const;
00392   void print();
00393 };
00394 
00395 class cChunk: public cVFrame {
00396  public:
00397   
00398   cChunk(const frame* fr) : cVFrame(fr) {}
00399 
00400  public:
00401   
00402   bool is_c_chunk() const { return true; }
00403   vframe* sender() const;
00404   void print_value() const;
00405   void print();
00406 
00407  private:
00408   
00409   oop callee_argument_at(int index) const;
00410 };