< prev index next >

src/share/vm/c1/c1_Canonicalizer.cpp

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 72,85 **** switch (x->op()) { case Bytecodes::_isub: set_constant(0); return; case Bytecodes::_lsub: set_constant(jlong_cast(0)); return; case Bytecodes::_iand: // fall through case Bytecodes::_land: // fall through ! case Bytecodes::_ior: // fall through case Bytecodes::_lor : set_canonical(x->x()); return; case Bytecodes::_ixor: set_constant(0); return; case Bytecodes::_lxor: set_constant(jlong_cast(0)); return; } } if (x->x()->type()->is_constant() && x->y()->type()->is_constant()) { // do constant folding for selected operations --- 72,86 ---- switch (x->op()) { case Bytecodes::_isub: set_constant(0); return; case Bytecodes::_lsub: set_constant(jlong_cast(0)); return; case Bytecodes::_iand: // fall through case Bytecodes::_land: // fall through ! case Bytecodes::_ior : // fall through case Bytecodes::_lor : set_canonical(x->x()); return; case Bytecodes::_ixor: set_constant(0); return; case Bytecodes::_lxor: set_constant(jlong_cast(0)); return; + default : break; } } if (x->x()->type()->is_constant() && x->y()->type()->is_constant()) { // do constant folding for selected operations
*** 112,121 **** --- 113,123 ---- } break; case Bytecodes::_iand: set_constant(a & b); return; case Bytecodes::_ior : set_constant(a | b); return; case Bytecodes::_ixor: set_constant(a ^ b); return; + default : break; } } break; case longTag: { jlong a = x->x()->type()->as_LongConstant()->value();
*** 137,150 **** --- 139,155 ---- } break; case Bytecodes::_land: set_constant(a & b); return; case Bytecodes::_lor : set_constant(a | b); return; case Bytecodes::_lxor: set_constant(a ^ b); return; + default : break; } } break; + default: // other cases not implemented (must be extremely careful with floats & doubles!) + break; } } // make sure constant is on the right side, if any move_const_to_right(x);
*** 159,168 **** --- 164,174 ---- case Bytecodes::_imul: set_constant(0); return; // Note: for div and rem, make sure that C semantics // corresponds to Java semantics! case Bytecodes::_iand: set_constant(0); return; case Bytecodes::_ior : set_canonical(x->x()); return; + default : break; } } break; case longTag: if (x->y()->type()->as_LongConstant()->value() == (jlong)0) {
*** 172,184 **** --- 178,193 ---- case Bytecodes::_lmul: set_constant((jlong)0); return; // Note: for div and rem, make sure that C semantics // corresponds to Java semantics! case Bytecodes::_land: set_constant((jlong)0); return; case Bytecodes::_lor : set_canonical(x->x()); return; + default : break; } } break; + default: + break; } } }
*** 208,217 **** --- 217,227 ---- BasicType type = x->field()->type()->basic_type(); switch (conv->op()) { case Bytecodes::_i2b: if (type == T_BYTE) value = conv->value(); break; case Bytecodes::_i2s: if (type == T_SHORT || type == T_BYTE) value = conv->value(); break; case Bytecodes::_i2c: if (type == T_CHAR || type == T_BYTE) value = conv->value(); break; + default : break; } // limit this optimization to current block if (value != NULL && in_current_block(conv)) { set_canonical(new StoreField(x->obj(), x->offset(), x->field(), value, x->is_static(), x->state_before(), x->needs_patching()));
*** 301,310 **** --- 311,321 ---- BasicType type = x->elt_type(); switch (conv->op()) { case Bytecodes::_i2b: if (type == T_BYTE) value = conv->value(); break; case Bytecodes::_i2s: if (type == T_SHORT || type == T_BYTE) value = conv->value(); break; case Bytecodes::_i2c: if (type == T_CHAR || type == T_BYTE) value = conv->value(); break; + default : break; } // limit this optimization to current block if (value != NULL && in_current_block(conv)) { set_canonical(new StoreIndexed(x->array(), x->index(), x->length(), x->elt_type(), value, x->state_before(),
*** 349,368 **** --- 360,381 ---- if (shift == 0) mask = ~0; switch (x->op()) { case Bytecodes::_ishl: set_constant(value << shift); return; case Bytecodes::_ishr: set_constant(value >> shift); return; case Bytecodes::_iushr: set_constant((value >> shift) & mask); return; + default: break; } } else if (t->tag() == longTag) { jlong value = t->as_LongConstant()->value(); int shift = t2->as_IntConstant()->value() & 63; jlong mask = ~(~jlong_cast(0) << (64 - shift)); if (shift == 0) mask = ~jlong_cast(0); switch (x->op()) { case Bytecodes::_lshl: set_constant(value << shift); return; case Bytecodes::_lshr: set_constant(value >> shift); return; case Bytecodes::_lushr: set_constant((value >> shift) & mask); return; + default: break; } } } } if (t2->is_constant()) {
*** 400,409 **** --- 413,424 ---- set_constant(0); } } break; } + default: + break; } } else if (x->x()->type()->is_constant() && x->y()->type()->is_constant()) { switch (x->x()->type()->tag()) { case longTag: { jlong vx = x->x()->type()->as_LongConstant()->value();
*** 442,453 **** set_constant(-1); else set_constant(1); break; } - } } } void Canonicalizer::do_IfInstanceOf(IfInstanceOf* x) {} --- 457,470 ---- set_constant(-1); else set_constant(1); break; } + default: + break; + } } } void Canonicalizer::do_IfInstanceOf(IfInstanceOf* x) {}
*** 528,537 **** --- 545,556 ---- ciType* t = c->value()->java_mirror_type(); set_constant(t->is_primitive_type()); } break; } + default: + break; } } void Canonicalizer::do_Convert (Convert* x) { if (x->value()->type()->is_constant()) {
*** 570,598 **** --- 589,620 ---- if (conv) { switch (conv->op()) { case Bytecodes::_i2b: type = T_BYTE; break; case Bytecodes::_i2s: type = T_SHORT; break; case Bytecodes::_i2c: type = T_CHAR; break; + default : break; } } } } if (type != T_ILLEGAL) { switch (x->op()) { case Bytecodes::_i2b: if (type == T_BYTE) set_canonical(x->value()); break; case Bytecodes::_i2s: if (type == T_SHORT || type == T_BYTE) set_canonical(x->value()); break; case Bytecodes::_i2c: if (type == T_CHAR) set_canonical(x->value()); break; + default : break; } } else { Op2* op2 = x->value()->as_Op2(); if (op2 && op2->op() == Bytecodes::_iand && op2->y()->type()->is_constant()) { jint safebits = 0; jint mask = op2->y()->type()->as_IntConstant()->value(); switch (x->op()) { case Bytecodes::_i2b: safebits = 0x7f; break; case Bytecodes::_i2s: safebits = 0x7fff; break; case Bytecodes::_i2c: safebits = 0xffff; break; + default : break; } // When casting a masked integer to a smaller signed type, if // the mask doesn't include the sign bit the cast isn't needed. if (safebits && (mask & ~safebits) == 0) { set_canonical(x->value());
*** 667,679 **** case If::neq: return x != y; case If::lss: return x < y; case If::leq: return x <= y; case If::gtr: return x > y; case If::geq: return x >= y; ! } ShouldNotReachHere(); return false; } static bool is_safepoint(BlockEnd* x, BlockBegin* sux) { // An Instruction with multiple successors, x, is replaced by a Goto // to a single successor, sux. Is a safepoint check needed = was the --- 689,702 ---- case If::neq: return x != y; case If::lss: return x < y; case If::leq: return x <= y; case If::gtr: return x > y; case If::geq: return x >= y; ! default: ShouldNotReachHere(); return false; + } } static bool is_safepoint(BlockEnd* x, BlockBegin* sux) { // An Instruction with multiple successors, x, is replaced by a Goto // to a single successor, sux. Is a safepoint check needed = was the
*** 754,763 **** --- 777,788 ---- switch(cmp->op()) { case Bytecodes::_fcmpl: case Bytecodes::_fcmpg: case Bytecodes::_dcmpl: case Bytecodes::_dcmpg: set_canonical(x); return; + default: + break; } } set_bci(cmp->state_before()->bci()); set_canonical(canon); }
< prev index next >