1224
1225
1226 void GraphBuilder::_goto(int from_bci, int to_bci) {
1227 Goto *x = new Goto(block_at(to_bci), to_bci <= from_bci);
1228 if (is_profiling()) {
1229 compilation()->set_would_profile(true);
1230 x->set_profiled_bci(bci());
1231 if (profile_branches()) {
1232 x->set_profiled_method(method());
1233 x->set_should_profile(true);
1234 }
1235 }
1236 append(x);
1237 }
1238
1239
1240 void GraphBuilder::if_node(Value x, If::Condition cond, Value y, ValueStack* state_before) {
1241 BlockBegin* tsux = block_at(stream()->get_dest());
1242 BlockBegin* fsux = block_at(stream()->next_bci());
1243 bool is_bb = tsux->bci() < stream()->cur_bci() || fsux->bci() < stream()->cur_bci();
1244 // In case of loop invariant code motion or predicate insertion
1245 // before the body of a loop the state is needed
1246 Instruction *i = append(new If(x, cond, false, y, tsux, fsux, (is_bb || compilation()->is_optimistic()) ? state_before : NULL, is_bb));
1247
1248 assert(i->as_Goto() == NULL ||
1249 (i->as_Goto()->sux_at(0) == tsux && i->as_Goto()->is_safepoint() == tsux->bci() < stream()->cur_bci()) ||
1250 (i->as_Goto()->sux_at(0) == fsux && i->as_Goto()->is_safepoint() == fsux->bci() < stream()->cur_bci()),
1251 "safepoint state of Goto returned by canonicalizer incorrect");
1252
1253 if (is_profiling()) {
1254 If* if_node = i->as_If();
1255 if (if_node != NULL) {
1256 // Note that we'd collect profile data in this method if we wanted it.
1257 compilation()->set_would_profile(true);
1258 // At level 2 we need the proper bci to count backedges
1259 if_node->set_profiled_bci(bci());
1260 if (profile_branches()) {
1261 // Successors can be rotated by the canonicalizer, check for this case.
1262 if_node->set_profiled_method(method());
1263 if_node->set_should_profile(true);
1264 if (if_node->tsux() == fsux) {
1265 if_node->set_swapped(true);
1266 }
|
1224
1225
1226 void GraphBuilder::_goto(int from_bci, int to_bci) {
1227 Goto *x = new Goto(block_at(to_bci), to_bci <= from_bci);
1228 if (is_profiling()) {
1229 compilation()->set_would_profile(true);
1230 x->set_profiled_bci(bci());
1231 if (profile_branches()) {
1232 x->set_profiled_method(method());
1233 x->set_should_profile(true);
1234 }
1235 }
1236 append(x);
1237 }
1238
1239
1240 void GraphBuilder::if_node(Value x, If::Condition cond, Value y, ValueStack* state_before) {
1241 BlockBegin* tsux = block_at(stream()->get_dest());
1242 BlockBegin* fsux = block_at(stream()->next_bci());
1243 bool is_bb = tsux->bci() < stream()->cur_bci() || fsux->bci() < stream()->cur_bci();
1244
1245 bool subst_check = false;
1246 if (EnableValhalla && ACmpOnValues == 3 &&
1247 (stream()->cur_bc() == Bytecodes::_if_acmpeq || stream()->cur_bc() == Bytecodes::_if_acmpne) &&
1248 method() != ciEnv::current()->ValueBootstrapMethods_klass()->find_method(ciSymbol::isSubstitutable_name(), ciSymbol::object_object_boolean_signature())) {
1249 // If current method is ValueBootstrapMethods::isSubstitutable(),
1250 // compile the acmp as a regular pointer comparison otherwise we
1251 // could call ValueBootstrapMethods::isSubstitutable() back
1252 ValueType* left_vt = x->type();
1253 ValueType* right_vt = y->type();
1254 if (left_vt->is_object()) {
1255 assert(right_vt->is_object(), "must be");
1256 ciKlass* left_klass = x->as_loaded_klass_or_null();
1257 ciKlass* right_klass = y->as_loaded_klass_or_null();
1258
1259 if (left_klass == NULL || right_klass == NULL) {
1260 // The klass is still unloaded, or came from a Phi node. Go slow case;
1261 subst_check = true;
1262 } else if (left_klass->is_java_lang_Object() || left_klass->is_interface() ||
1263 right_klass->is_java_lang_Object() || right_klass->is_interface()) {
1264 // Either operand may be a value object, but we're not sure. Go slow case;
1265 subst_check = true;
1266 } else if (left_klass->is_valuetype() || right_klass->is_valuetype()) {
1267 subst_check = true;
1268 } else {
1269 // No need to do substituability check
1270 }
1271 }
1272 }
1273
1274 // In case of loop invariant code motion or predicate insertion
1275 // before the body of a loop the state is needed
1276 Instruction *i = append(new If(x, cond, false, y, tsux, fsux, (is_bb || compilation()->is_optimistic() || subst_check) ? state_before : NULL, is_bb, subst_check));
1277
1278 assert(i->as_Goto() == NULL ||
1279 (i->as_Goto()->sux_at(0) == tsux && i->as_Goto()->is_safepoint() == tsux->bci() < stream()->cur_bci()) ||
1280 (i->as_Goto()->sux_at(0) == fsux && i->as_Goto()->is_safepoint() == fsux->bci() < stream()->cur_bci()),
1281 "safepoint state of Goto returned by canonicalizer incorrect");
1282
1283 if (is_profiling()) {
1284 If* if_node = i->as_If();
1285 if (if_node != NULL) {
1286 // Note that we'd collect profile data in this method if we wanted it.
1287 compilation()->set_would_profile(true);
1288 // At level 2 we need the proper bci to count backedges
1289 if_node->set_profiled_bci(bci());
1290 if (profile_branches()) {
1291 // Successors can be rotated by the canonicalizer, check for this case.
1292 if_node->set_profiled_method(method());
1293 if_node->set_should_profile(true);
1294 if (if_node->tsux() == fsux) {
1295 if_node->set_swapped(true);
1296 }
|