1.1 --- a/src/share/vm/c1/c1_Instruction.hpp Wed Oct 09 11:05:17 2013 -0700 1.2 +++ b/src/share/vm/c1/c1_Instruction.hpp Wed Oct 09 16:32:21 2013 +0200 1.3 @@ -322,6 +322,36 @@ 1.4 _type = type; 1.5 } 1.6 1.7 + // Helper class to keep track of which arguments need a null check 1.8 + class ArgsNonNullState { 1.9 + private: 1.10 + int _nonnull_state; // mask identifying which args are nonnull 1.11 + public: 1.12 + ArgsNonNullState() 1.13 + : _nonnull_state(AllBits) {} 1.14 + 1.15 + // Does argument number i needs a null check? 1.16 + bool arg_needs_null_check(int i) const { 1.17 + // No data is kept for arguments starting at position 33 so 1.18 + // conservatively assume that they need a null check. 1.19 + if (i >= 0 && i < (int)sizeof(_nonnull_state) * BitsPerByte) { 1.20 + return is_set_nth_bit(_nonnull_state, i); 1.21 + } 1.22 + return true; 1.23 + } 1.24 + 1.25 + // Set whether argument number i needs a null check or not 1.26 + void set_arg_needs_null_check(int i, bool check) { 1.27 + if (i >= 0 && i < (int)sizeof(_nonnull_state) * BitsPerByte) { 1.28 + if (check) { 1.29 + _nonnull_state |= nth_bit(i); 1.30 + } else { 1.31 + _nonnull_state &= ~(nth_bit(i)); 1.32 + } 1.33 + } 1.34 + } 1.35 + }; 1.36 + 1.37 public: 1.38 void* operator new(size_t size) throw() { 1.39 Compilation* c = Compilation::current(); 1.40 @@ -566,7 +596,7 @@ 1.41 virtual void other_values_do(ValueVisitor* f) { /* usually no other - override on demand */ } 1.42 void values_do(ValueVisitor* f) { input_values_do(f); state_values_do(f); other_values_do(f); } 1.43 1.44 - virtual ciType* exact_type() const { return NULL; } 1.45 + virtual ciType* exact_type() const; 1.46 virtual ciType* declared_type() const { return NULL; } 1.47 1.48 // hashing 1.49 @@ -689,7 +719,6 @@ 1.50 int java_index() const { return _java_index; } 1.51 1.52 virtual ciType* declared_type() const { return _declared_type; } 1.53 - virtual ciType* exact_type() const; 1.54 1.55 // generic 1.56 virtual void input_values_do(ValueVisitor* f) { /* no values */ } 1.57 @@ -806,7 +835,6 @@ 1.58 {} 1.59 1.60 ciType* declared_type() const; 1.61 - ciType* exact_type() const; 1.62 1.63 // generic 1.64 HASHING2(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset()) // cannot be eliminated if needs patching or if volatile 1.65 @@ -1299,6 +1327,7 @@ 1.66 1.67 virtual bool needs_exception_state() const { return false; } 1.68 1.69 + ciType* exact_type() const { return NULL; } 1.70 ciType* declared_type() const; 1.71 1.72 // generic 1.73 @@ -1422,7 +1451,6 @@ 1.74 } 1.75 1.76 ciType* declared_type() const; 1.77 - ciType* exact_type() const; 1.78 }; 1.79 1.80 1.81 @@ -1490,7 +1518,7 @@ 1.82 vmIntrinsics::ID _id; 1.83 Values* _args; 1.84 Value _recv; 1.85 - int _nonnull_state; // mask identifying which args are nonnull 1.86 + ArgsNonNullState _nonnull_state; 1.87 1.88 public: 1.89 // preserves_state can be set to true for Intrinsics 1.90 @@ -1511,7 +1539,6 @@ 1.91 , _id(id) 1.92 , _args(args) 1.93 , _recv(NULL) 1.94 - , _nonnull_state(AllBits) 1.95 { 1.96 assert(args != NULL, "args must exist"); 1.97 ASSERT_VALUES 1.98 @@ -1537,21 +1564,12 @@ 1.99 Value receiver() const { assert(has_receiver(), "must have receiver"); return _recv; } 1.100 bool preserves_state() const { return check_flag(PreservesStateFlag); } 1.101 1.102 - bool arg_needs_null_check(int i) { 1.103 - if (i >= 0 && i < (int)sizeof(_nonnull_state) * BitsPerByte) { 1.104 - return is_set_nth_bit(_nonnull_state, i); 1.105 - } 1.106 - return true; 1.107 + bool arg_needs_null_check(int i) const { 1.108 + return _nonnull_state.arg_needs_null_check(i); 1.109 } 1.110 1.111 void set_arg_needs_null_check(int i, bool check) { 1.112 - if (i >= 0 && i < (int)sizeof(_nonnull_state) * BitsPerByte) { 1.113 - if (check) { 1.114 - _nonnull_state |= nth_bit(i); 1.115 - } else { 1.116 - _nonnull_state &= ~(nth_bit(i)); 1.117 - } 1.118 - } 1.119 + _nonnull_state.set_arg_needs_null_check(i, check); 1.120 } 1.121 1.122 // generic 1.123 @@ -2450,35 +2468,56 @@ 1.124 1.125 LEAF(ProfileCall, Instruction) 1.126 private: 1.127 - ciMethod* _method; 1.128 - int _bci_of_invoke; 1.129 - ciMethod* _callee; // the method that is called at the given bci 1.130 - Value _recv; 1.131 - ciKlass* _known_holder; 1.132 + ciMethod* _method; 1.133 + int _bci_of_invoke; 1.134 + ciMethod* _callee; // the method that is called at the given bci 1.135 + Value _recv; 1.136 + ciKlass* _known_holder; 1.137 + Values* _obj_args; // arguments for type profiling 1.138 + ArgsNonNullState _nonnull_state; // Do we know whether some arguments are never null? 1.139 + bool _inlined; // Are we profiling a call that is inlined 1.140 1.141 public: 1.142 - ProfileCall(ciMethod* method, int bci, ciMethod* callee, Value recv, ciKlass* known_holder) 1.143 + ProfileCall(ciMethod* method, int bci, ciMethod* callee, Value recv, ciKlass* known_holder, Values* obj_args, bool inlined) 1.144 : Instruction(voidType) 1.145 , _method(method) 1.146 , _bci_of_invoke(bci) 1.147 , _callee(callee) 1.148 , _recv(recv) 1.149 , _known_holder(known_holder) 1.150 + , _obj_args(obj_args) 1.151 + , _inlined(inlined) 1.152 { 1.153 // The ProfileCall has side-effects and must occur precisely where located 1.154 pin(); 1.155 } 1.156 1.157 - ciMethod* method() { return _method; } 1.158 - int bci_of_invoke() { return _bci_of_invoke; } 1.159 - ciMethod* callee() { return _callee; } 1.160 - Value recv() { return _recv; } 1.161 - ciKlass* known_holder() { return _known_holder; } 1.162 - 1.163 - virtual void input_values_do(ValueVisitor* f) { if (_recv != NULL) f->visit(&_recv); } 1.164 + ciMethod* method() const { return _method; } 1.165 + int bci_of_invoke() const { return _bci_of_invoke; } 1.166 + ciMethod* callee() const { return _callee; } 1.167 + Value recv() const { return _recv; } 1.168 + ciKlass* known_holder() const { return _known_holder; } 1.169 + int nb_profiled_args() const { return _obj_args == NULL ? 0 : _obj_args->length(); } 1.170 + Value profiled_arg_at(int i) const { return _obj_args->at(i); } 1.171 + bool arg_needs_null_check(int i) const { 1.172 + return _nonnull_state.arg_needs_null_check(i); 1.173 + } 1.174 + bool inlined() const { return _inlined; } 1.175 + 1.176 + void set_arg_needs_null_check(int i, bool check) { 1.177 + _nonnull_state.set_arg_needs_null_check(i, check); 1.178 + } 1.179 + 1.180 + virtual void input_values_do(ValueVisitor* f) { 1.181 + if (_recv != NULL) { 1.182 + f->visit(&_recv); 1.183 + } 1.184 + for (int i = 0; i < nb_profiled_args(); i++) { 1.185 + f->visit(_obj_args->adr_at(i)); 1.186 + } 1.187 + } 1.188 }; 1.189 1.190 - 1.191 // Call some C runtime function that doesn't safepoint, 1.192 // optionally passing the current thread as the first argument. 1.193 LEAF(RuntimeCall, Instruction)