hotspot/src/share/vm/c1/c1_Instruction.cpp
changeset 46630 75aa3e39d02c
parent 41698 a3f113541801
equal deleted inserted replaced
46629:8eeacdc76bf2 46630:75aa3e39d02c
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   237     case Bytecodes::_dadd: // fall through
   237     case Bytecodes::_dadd: // fall through
   238     case Bytecodes::_imul: // fall through
   238     case Bytecodes::_imul: // fall through
   239     case Bytecodes::_lmul: // fall through
   239     case Bytecodes::_lmul: // fall through
   240     case Bytecodes::_fmul: // fall through
   240     case Bytecodes::_fmul: // fall through
   241     case Bytecodes::_dmul: return true;
   241     case Bytecodes::_dmul: return true;
   242   }
   242     default              : return false;
   243   return false;
   243   }
   244 }
   244 }
   245 
   245 
   246 
   246 
   247 bool ArithmeticOp::can_trap() const {
   247 bool ArithmeticOp::can_trap() const {
   248   switch (op()) {
   248   switch (op()) {
   249     case Bytecodes::_idiv: // fall through
   249     case Bytecodes::_idiv: // fall through
   250     case Bytecodes::_ldiv: // fall through
   250     case Bytecodes::_ldiv: // fall through
   251     case Bytecodes::_irem: // fall through
   251     case Bytecodes::_irem: // fall through
   252     case Bytecodes::_lrem: return true;
   252     case Bytecodes::_lrem: return true;
   253   }
   253     default              : return false;
   254   return false;
   254   }
   255 }
   255 }
   256 
   256 
   257 
   257 
   258 // Implementation of LogicOp
   258 // Implementation of LogicOp
   259 
   259 
   264     case Bytecodes::_land: // fall through
   264     case Bytecodes::_land: // fall through
   265     case Bytecodes::_ior : // fall through
   265     case Bytecodes::_ior : // fall through
   266     case Bytecodes::_lor : // fall through
   266     case Bytecodes::_lor : // fall through
   267     case Bytecodes::_ixor: // fall through
   267     case Bytecodes::_ixor: // fall through
   268     case Bytecodes::_lxor: break;
   268     case Bytecodes::_lxor: break;
   269     default              : ShouldNotReachHere();
   269     default              : ShouldNotReachHere(); break;
   270   }
   270   }
   271 #endif
   271 #endif
   272   // all LogicOps are commutative
   272   // all LogicOps are commutative
   273   return true;
   273   return true;
   274 }
   274 }
   445         MetadataType* t2 = v->type()->as_MetadataType();
   445         MetadataType* t2 = v->type()->as_MetadataType();
   446         return (t1 != NULL && t2 != NULL &&
   446         return (t1 != NULL && t2 != NULL &&
   447                 t1->is_loaded() && t2->is_loaded() &&
   447                 t1->is_loaded() && t2->is_loaded() &&
   448                 t1->constant_value() == t2->constant_value());
   448                 t1->constant_value() == t2->constant_value());
   449       }
   449       }
   450   }
   450     default:
   451   return false;
   451       return false;
       
   452   }
   452 }
   453 }
   453 
   454 
   454 Constant::CompareResult Constant::compare(Instruction::Condition cond, Value right) const {
   455 Constant::CompareResult Constant::compare(Instruction::Condition cond, Value right) const {
   455   Constant* rc = right->as_Constant();
   456   Constant* rc = right->as_Constant();
   456   // other is not a constant
   457   // other is not a constant
   469     case If::neq: return x != y ? cond_true : cond_false;
   470     case If::neq: return x != y ? cond_true : cond_false;
   470     case If::lss: return x <  y ? cond_true : cond_false;
   471     case If::lss: return x <  y ? cond_true : cond_false;
   471     case If::leq: return x <= y ? cond_true : cond_false;
   472     case If::leq: return x <= y ? cond_true : cond_false;
   472     case If::gtr: return x >  y ? cond_true : cond_false;
   473     case If::gtr: return x >  y ? cond_true : cond_false;
   473     case If::geq: return x >= y ? cond_true : cond_false;
   474     case If::geq: return x >= y ? cond_true : cond_false;
       
   475     default     : break;
   474     }
   476     }
   475     break;
   477     break;
   476   }
   478   }
   477   case longTag: {
   479   case longTag: {
   478     jlong x = lt->as_LongConstant()->value();
   480     jlong x = lt->as_LongConstant()->value();
   482     case If::neq: return x != y ? cond_true : cond_false;
   484     case If::neq: return x != y ? cond_true : cond_false;
   483     case If::lss: return x <  y ? cond_true : cond_false;
   485     case If::lss: return x <  y ? cond_true : cond_false;
   484     case If::leq: return x <= y ? cond_true : cond_false;
   486     case If::leq: return x <= y ? cond_true : cond_false;
   485     case If::gtr: return x >  y ? cond_true : cond_false;
   487     case If::gtr: return x >  y ? cond_true : cond_false;
   486     case If::geq: return x >= y ? cond_true : cond_false;
   488     case If::geq: return x >= y ? cond_true : cond_false;
       
   489     default     : break;
   487     }
   490     }
   488     break;
   491     break;
   489   }
   492   }
   490   case objectTag: {
   493   case objectTag: {
   491     ciObject* xvalue = lt->as_ObjectType()->constant_value();
   494     ciObject* xvalue = lt->as_ObjectType()->constant_value();
   493     assert(xvalue != NULL && yvalue != NULL, "not constants");
   496     assert(xvalue != NULL && yvalue != NULL, "not constants");
   494     if (xvalue->is_loaded() && yvalue->is_loaded()) {
   497     if (xvalue->is_loaded() && yvalue->is_loaded()) {
   495       switch (cond) {
   498       switch (cond) {
   496       case If::eql: return xvalue == yvalue ? cond_true : cond_false;
   499       case If::eql: return xvalue == yvalue ? cond_true : cond_false;
   497       case If::neq: return xvalue != yvalue ? cond_true : cond_false;
   500       case If::neq: return xvalue != yvalue ? cond_true : cond_false;
       
   501       default     : break;
   498       }
   502       }
   499     }
   503     }
   500     break;
   504     break;
   501   }
   505   }
   502   case metaDataTag: {
   506   case metaDataTag: {
   505     assert(xvalue != NULL && yvalue != NULL, "not constants");
   509     assert(xvalue != NULL && yvalue != NULL, "not constants");
   506     if (xvalue->is_loaded() && yvalue->is_loaded()) {
   510     if (xvalue->is_loaded() && yvalue->is_loaded()) {
   507       switch (cond) {
   511       switch (cond) {
   508       case If::eql: return xvalue == yvalue ? cond_true : cond_false;
   512       case If::eql: return xvalue == yvalue ? cond_true : cond_false;
   509       case If::neq: return xvalue != yvalue ? cond_true : cond_false;
   513       case If::neq: return xvalue != yvalue ? cond_true : cond_false;
       
   514       default     : break;
   510       }
   515       }
   511     }
   516     }
   512     break;
   517     break;
   513   }
   518   }
       
   519   default:
       
   520     break;
   514   }
   521   }
   515   return not_comparable;
   522   return not_comparable;
   516 }
   523 }
   517 
   524 
   518 
   525