1.1 --- a/src/share/vm/c1/c1_Instruction.hpp Mon Jul 23 13:04:59 2012 -0700 1.2 +++ b/src/share/vm/c1/c1_Instruction.hpp Tue Jul 24 10:51:00 2012 -0700 1.3 @@ -66,6 +66,7 @@ 1.4 class IfOp; 1.5 class Convert; 1.6 class NullCheck; 1.7 +class TypeCast; 1.8 class OsrEntry; 1.9 class ExceptionObject; 1.10 class StateSplit; 1.11 @@ -174,6 +175,7 @@ 1.12 virtual void do_IfOp (IfOp* x) = 0; 1.13 virtual void do_Convert (Convert* x) = 0; 1.14 virtual void do_NullCheck (NullCheck* x) = 0; 1.15 + virtual void do_TypeCast (TypeCast* x) = 0; 1.16 virtual void do_Invoke (Invoke* x) = 0; 1.17 virtual void do_NewInstance (NewInstance* x) = 0; 1.18 virtual void do_NewTypeArray (NewTypeArray* x) = 0; 1.19 @@ -302,7 +304,8 @@ 1.20 1.21 void update_exception_state(ValueStack* state); 1.22 1.23 - protected: 1.24 + //protected: 1.25 + public: 1.26 void set_type(ValueType* type) { 1.27 assert(type != NULL, "type must exist"); 1.28 _type = type; 1.29 @@ -485,6 +488,7 @@ 1.30 virtual TypeCheck* as_TypeCheck() { return NULL; } 1.31 virtual CheckCast* as_CheckCast() { return NULL; } 1.32 virtual InstanceOf* as_InstanceOf() { return NULL; } 1.33 + virtual TypeCast* as_TypeCast() { return NULL; } 1.34 virtual AccessMonitor* as_AccessMonitor() { return NULL; } 1.35 virtual MonitorEnter* as_MonitorEnter() { return NULL; } 1.36 virtual MonitorExit* as_MonitorExit() { return NULL; } 1.37 @@ -638,8 +642,8 @@ 1.38 // accessors 1.39 int java_index() const { return _java_index; } 1.40 1.41 - ciType* declared_type() const { return _declared_type; } 1.42 - ciType* exact_type() const; 1.43 + virtual ciType* declared_type() const { return _declared_type; } 1.44 + virtual ciType* exact_type() const; 1.45 1.46 // generic 1.47 virtual void input_values_do(ValueVisitor* f) { /* no values */ } 1.48 @@ -650,13 +654,13 @@ 1.49 public: 1.50 // creation 1.51 Constant(ValueType* type): 1.52 - Instruction(type, NULL, true) 1.53 + Instruction(type, NULL, /*type_is_constant*/ true) 1.54 { 1.55 assert(type->is_constant(), "must be a constant"); 1.56 } 1.57 1.58 Constant(ValueType* type, ValueStack* state_before): 1.59 - Instruction(type, state_before, true) 1.60 + Instruction(type, state_before, /*type_is_constant*/ true) 1.61 { 1.62 assert(state_before != NULL, "only used for constants which need patching"); 1.63 assert(type->is_constant(), "must be a constant"); 1.64 @@ -670,6 +674,7 @@ 1.65 virtual intx hash() const; 1.66 virtual bool is_equal(Value v) const; 1.67 1.68 + virtual ciType* exact_type() const; 1.69 1.70 enum CompareResult { not_comparable = -1, cond_false, cond_true }; 1.71 1.72 @@ -1103,6 +1108,29 @@ 1.73 }; 1.74 1.75 1.76 +// This node is supposed to cast the type of another node to a more precise 1.77 +// declared type. 1.78 +LEAF(TypeCast, Instruction) 1.79 + private: 1.80 + ciType* _declared_type; 1.81 + Value _obj; 1.82 + 1.83 + public: 1.84 + // The type of this node is the same type as the object type (and it might be constant). 1.85 + TypeCast(ciType* type, Value obj, ValueStack* state_before) 1.86 + : Instruction(obj->type(), state_before, obj->type()->is_constant()), 1.87 + _declared_type(type), 1.88 + _obj(obj) {} 1.89 + 1.90 + // accessors 1.91 + ciType* declared_type() const { return _declared_type; } 1.92 + Value obj() const { return _obj; } 1.93 + 1.94 + // generic 1.95 + virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); } 1.96 +}; 1.97 + 1.98 + 1.99 BASE(StateSplit, Instruction) 1.100 private: 1.101 ValueStack* _state; 1.102 @@ -1166,6 +1194,7 @@ 1.103 1.104 // JSR 292 support 1.105 bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; } 1.106 + bool is_method_handle_intrinsic() const { return target()->is_method_handle_intrinsic(); } 1.107 1.108 virtual bool needs_exception_state() const { return false; } 1.109 1.110 @@ -2277,14 +2306,16 @@ 1.111 private: 1.112 ciMethod* _method; 1.113 int _bci_of_invoke; 1.114 + ciMethod* _callee; // the method that is called at the given bci 1.115 Value _recv; 1.116 ciKlass* _known_holder; 1.117 1.118 public: 1.119 - ProfileCall(ciMethod* method, int bci, Value recv, ciKlass* known_holder) 1.120 + ProfileCall(ciMethod* method, int bci, ciMethod* callee, Value recv, ciKlass* known_holder) 1.121 : Instruction(voidType) 1.122 , _method(method) 1.123 , _bci_of_invoke(bci) 1.124 + , _callee(callee) 1.125 , _recv(recv) 1.126 , _known_holder(known_holder) 1.127 { 1.128 @@ -2294,6 +2325,7 @@ 1.129 1.130 ciMethod* method() { return _method; } 1.131 int bci_of_invoke() { return _bci_of_invoke; } 1.132 + ciMethod* callee() { return _callee; } 1.133 Value recv() { return _recv; } 1.134 ciKlass* known_holder() { return _known_holder; } 1.135