1364 if (cast != NULL) { // Here's the payoff. |
1364 if (cast != NULL) { // Here's the payoff. |
1365 replace_in_map(val, cast); |
1365 replace_in_map(val, cast); |
1366 } |
1366 } |
1367 } |
1367 } |
1368 |
1368 |
|
1369 /** |
|
1370 * Use speculative type to optimize CmpP node: if comparison is |
|
1371 * against the low level class, cast the object to the speculative |
|
1372 * type if any. CmpP should then go away. |
|
1373 * |
|
1374 * @param c expected CmpP node |
|
1375 * @return result of CmpP on object casted to speculative type |
|
1376 * |
|
1377 */ |
|
1378 Node* Parse::optimize_cmp_with_klass(Node* c) { |
|
1379 // If this is transformed by the _gvn to a comparison with the low |
|
1380 // level klass then we may be able to use speculation |
|
1381 if (c->Opcode() == Op_CmpP && |
|
1382 (c->in(1)->Opcode() == Op_LoadKlass || c->in(1)->Opcode() == Op_DecodeNKlass) && |
|
1383 c->in(2)->is_Con()) { |
|
1384 Node* load_klass = NULL; |
|
1385 Node* decode = NULL; |
|
1386 if (c->in(1)->Opcode() == Op_DecodeNKlass) { |
|
1387 decode = c->in(1); |
|
1388 load_klass = c->in(1)->in(1); |
|
1389 } else { |
|
1390 load_klass = c->in(1); |
|
1391 } |
|
1392 if (load_klass->in(2)->is_AddP()) { |
|
1393 Node* addp = load_klass->in(2); |
|
1394 Node* obj = addp->in(AddPNode::Address); |
|
1395 const TypeOopPtr* obj_type = _gvn.type(obj)->is_oopptr(); |
|
1396 if (obj_type->speculative_type() != NULL) { |
|
1397 ciKlass* k = obj_type->speculative_type(); |
|
1398 inc_sp(2); |
|
1399 obj = maybe_cast_profiled_obj(obj, k); |
|
1400 dec_sp(2); |
|
1401 // Make the CmpP use the casted obj |
|
1402 addp = basic_plus_adr(obj, addp->in(AddPNode::Offset)); |
|
1403 load_klass = load_klass->clone(); |
|
1404 load_klass->set_req(2, addp); |
|
1405 load_klass = _gvn.transform(load_klass); |
|
1406 if (decode != NULL) { |
|
1407 decode = decode->clone(); |
|
1408 decode->set_req(1, load_klass); |
|
1409 load_klass = _gvn.transform(decode); |
|
1410 } |
|
1411 c = c->clone(); |
|
1412 c->set_req(1, load_klass); |
|
1413 c = _gvn.transform(c); |
|
1414 } |
|
1415 } |
|
1416 } |
|
1417 return c; |
|
1418 } |
1369 |
1419 |
1370 //------------------------------do_one_bytecode-------------------------------- |
1420 //------------------------------do_one_bytecode-------------------------------- |
1371 // Parse this bytecode, and alter the Parsers JVM->Node mapping |
1421 // Parse this bytecode, and alter the Parsers JVM->Node mapping |
1372 void Parse::do_one_bytecode() { |
1422 void Parse::do_one_bytecode() { |
1373 Node *a, *b, *c, *d; // Handy temps |
1423 Node *a, *b, *c, *d; // Handy temps |
2237 // If this is a backwards branch in the bytecodes, add Safepoint |
2287 // If this is a backwards branch in the bytecodes, add Safepoint |
2238 maybe_add_safepoint(iter().get_dest()); |
2288 maybe_add_safepoint(iter().get_dest()); |
2239 a = pop(); |
2289 a = pop(); |
2240 b = pop(); |
2290 b = pop(); |
2241 c = _gvn.transform( new (C) CmpPNode(b, a) ); |
2291 c = _gvn.transform( new (C) CmpPNode(b, a) ); |
|
2292 c = optimize_cmp_with_klass(c); |
2242 do_if(btest, c); |
2293 do_if(btest, c); |
2243 break; |
2294 break; |
2244 |
2295 |
2245 case Bytecodes::_ifeq: btest = BoolTest::eq; goto handle_ifxx; |
2296 case Bytecodes::_ifeq: btest = BoolTest::eq; goto handle_ifxx; |
2246 case Bytecodes::_ifne: btest = BoolTest::ne; goto handle_ifxx; |
2297 case Bytecodes::_ifne: btest = BoolTest::ne; goto handle_ifxx; |