nodeBuilder.hpp

Go to the documentation of this file.
00001 /* Copyright 1994 - 1996 LongView Technologies L.L.C. $Revision: 1.26 $ */
00002 /* Copyright (c) 2006, Sun Microsystems, Inc.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 
00006 following conditions are met:
00007 
00008     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 
00010           disclaimer in the documentation and/or other materials provided with the distribution.
00011     * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 
00012           from this software without specific prior written permission.
00013 
00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 
00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
00020 
00021 
00022 */
00023 
00024 
00025 # ifdef DELTA_COMPILER
00026 
00027 // The NodeBuilder generates the intermediate representation for a method or block.
00028 
00029 class AssignNode;
00030 class TypeTestNode;
00031 class ContextInitNode;
00032 class Inliner;
00033 
00034 class NodeBuilder: public CustomizedMethodClosure {
00035  private:
00036   ExprStack*    _exprStack;             // current expression stack
00037   Inliner*      _inliner;               // my inliner
00038   InlinedScope* _scope;                 // scope for which this NodeBuilder is generating code
00039   Node*         _current;               // where new nodes are appended
00040 
00041   void append_exit(Node* exitNode);     // append an exit node (UncommonNode, Return, etc.)
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);   // materialize block (always call before storing/assigning PReg)
00054 
00055   bool abortIfDead(Expr* e);                                            // helper function for dead code handling
00056   void generate_subinterval(MethodInterval* m, bool produces_result);   // generate subinterval (e.g., code in then branch)
00057   void constant_if_node(IfNode* node, ConstantExpr* cond);              // code for if with const condition
00058   TypeTestNode* makeTestNode(bool cond, PReg* r);                       // make boolean type test node
00059 
00060   // for Inliner
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;              // "at end of code" marker
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);             // append a node
00082   bool is_in_dead_code() const          { return _current == EndOfCode; }
00083   Inliner* inliner() const              { return _inliner; }
00084   void removeContextCreation();         // remove context creation node 
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

Generated on Mon Oct 9 13:37:18 2006 for Strongtalk VM by  doxygen 1.4.7