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 # ifdef DELTA_COMPILER
00026 
00027 
00028 
00029 class AssignNode;
00030 class TypeTestNode;
00031 class ContextInitNode;
00032 class Inliner;
00033 
00034 class NodeBuilder: public CustomizedMethodClosure {
00035  private:
00036   ExprStack*    _exprStack;             
00037   Inliner*      _inliner;               
00038   InlinedScope* _scope;                 
00039   Node*         _current;               
00040 
00041   void append_exit(Node* exitNode);     
00042   void append1(Node* node);
00043   void branch (MergeNode* target);
00044   void comment(char* s);
00045   GrowableArray<PReg*>* copyCurrentExprStack();
00046   void access_temporary(int no, int context, bool push);
00047   GrowableArray<PReg*>* pass_arguments(PReg* self, int nofArgs);
00048   void splitMergeExpr(Expr* expr, TypeTestNode* test);
00049   GrowableArray<Expr*>* splittablePaths(const Expr* expr, const TypeTestNode* test) const;
00050   GrowableArray<NonTrivialNode*>* nodesBetween(Node* from, Node* to);
00051   MergeNode* insertMergeBefore(Node* n);
00052   Expr* copy_into_context(Expr* e, int no);
00053   void materialize(PReg* r, GrowableArray<BlockPReg*>* materialized);   
00054 
00055   bool abortIfDead(Expr* e);                                            
00056   void generate_subinterval(MethodInterval* m, bool produces_result);   
00057   void constant_if_node(IfNode* node, ConstantExpr* cond);              
00058   TypeTestNode* makeTestNode(bool cond, PReg* r);                       
00059 
00060   
00061   void gen_normal_send(SendInfo* info, int nofArgs, SAPReg* result);
00062   void gen_self_send  (SendInfo* info, int nofArgs, SAPReg* result);
00063   void gen_super_send (SendInfo* info, int nofArgs, SAPReg* result);
00064 
00065   friend class Inliner;
00066   friend class CompilerInliningPolicy;
00067   friend class PrimInliner;
00068  protected:
00069   void abort();
00070 
00071  public:
00072   static Node*  EndOfCode;              
00073   
00074   NodeBuilder();
00075   void initialize(InlinedScope* scope);
00076 
00077   InlinedScope* scope() const           { return _scope; }
00078   ExprStack* exprStack() const          { return _exprStack; }
00079   Node* current() const                 { return _current; }
00080   void setCurrent(Node* n)              { assert(n != EndOfCode, "bad node"); _current = n; }
00081   void append (Node* node);             
00082   bool is_in_dead_code() const          { return _current == EndOfCode; }
00083   Inliner* inliner() const              { return _inliner; }
00084   void removeContextCreation();         
00085   PReg* float_at(int fno);
00086 
00087  public:
00088   void if_node(IfNode* node);
00089   void cond_node(CondNode* node);
00090   void while_node(WhileNode* node);
00091   void primitive_call_node(PrimitiveCallNode* node);
00092   void dll_call_node(DLLCallNode* node);
00093 
00094  public:
00095   void allocate_temporaries(int nofTemps);
00096 
00097   void push_self();
00098   void push_tos();
00099   void push_literal(oop obj);
00100 
00101   void push_argument(int no);
00102   void push_temporary(int no);
00103   void push_temporary(int no, int context);
00104   void push_instVar(int offset);
00105   void push_global(associationOop obj);
00106 
00107   void store_temporary(int no);
00108   void store_temporary(int no, int context);
00109   void store_instVar(int offset);
00110   void store_global(associationOop obj);
00111 
00112   void pop();
00113 
00114   void normal_send(InterpretedIC* ic);
00115   void self_send  (InterpretedIC* ic);
00116   void super_send (InterpretedIC* ic);
00117 
00118   void double_equal();
00119   void double_not_equal();
00120 
00121   void method_return(int nofArgs);
00122   void nonlocal_return(int nofArgs);
00123 
00124   void allocate_closure(AllocationType type, int nofArgs, methodOop meth);
00125   void allocate_context(int nofTemps, bool forMethod);
00126 
00127   void set_self_via_context();
00128   void copy_self_into_context();
00129   void copy_argument_into_context(int argNo, int no);
00130 
00131   void zap_scope();
00132 
00133   void predict_prim_call(primitive_desc* pdesc, int failure_start);
00134 
00135   void float_allocate(int nofFloatTemps, int nofFloatExprs);
00136   void float_floatify(Floats::Function f, int fno);
00137   void float_move(int fno, int from);
00138   void float_set(int fno, doubleOop value);
00139   void float_nullary(Floats::Function f, int fno);
00140   void float_unary(Floats::Function f, int fno);
00141   void float_binary(Floats::Function f, int fno);
00142   void float_unaryToOop(Floats::Function f, int fno);
00143   void float_binaryToOop(Floats::Function f, int fno);
00144 };
00145 
00146 
00147 # endif