1 /* |
1 /* |
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2019, 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. |
352 case longTag : if (t->as_LongConstant()->value() == (jlong)0) { set_constant(jlong_cast(0)); return; } break; |
352 case longTag : if (t->as_LongConstant()->value() == (jlong)0) { set_constant(jlong_cast(0)); return; } break; |
353 default : ShouldNotReachHere(); |
353 default : ShouldNotReachHere(); |
354 } |
354 } |
355 if (t2->is_constant()) { |
355 if (t2->is_constant()) { |
356 if (t->tag() == intTag) { |
356 if (t->tag() == intTag) { |
357 int value = t->as_IntConstant()->value(); |
357 jint value = t->as_IntConstant()->value(); |
358 int shift = t2->as_IntConstant()->value() & 31; |
358 jint shift = t2->as_IntConstant()->value(); |
359 jint mask = ~(~0 << (32 - shift)); |
|
360 if (shift == 0) mask = ~0; |
|
361 switch (x->op()) { |
359 switch (x->op()) { |
362 case Bytecodes::_ishl: set_constant(value << shift); return; |
360 case Bytecodes::_ishl: set_constant(java_shift_left(value, shift)); return; |
363 case Bytecodes::_ishr: set_constant(value >> shift); return; |
361 case Bytecodes::_ishr: set_constant(java_shift_right(value, shift)); return; |
364 case Bytecodes::_iushr: set_constant((value >> shift) & mask); return; |
362 case Bytecodes::_iushr: set_constant(java_shift_right_unsigned(value, shift)); return; |
365 default: break; |
363 default: break; |
366 } |
364 } |
367 } else if (t->tag() == longTag) { |
365 } else if (t->tag() == longTag) { |
368 jlong value = t->as_LongConstant()->value(); |
366 jlong value = t->as_LongConstant()->value(); |
369 int shift = t2->as_IntConstant()->value() & 63; |
367 jint shift = t2->as_IntConstant()->value(); |
370 jlong mask = ~(~jlong_cast(0) << (64 - shift)); |
|
371 if (shift == 0) mask = ~jlong_cast(0); |
|
372 switch (x->op()) { |
368 switch (x->op()) { |
373 case Bytecodes::_lshl: set_constant(value << shift); return; |
369 case Bytecodes::_lshl: set_constant(java_shift_left(value, shift)); return; |
374 case Bytecodes::_lshr: set_constant(value >> shift); return; |
370 case Bytecodes::_lshr: set_constant(java_shift_right(value, shift)); return; |
375 case Bytecodes::_lushr: set_constant((value >> shift) & mask); return; |
371 case Bytecodes::_lushr: set_constant(java_shift_right_unsigned(value, shift)); return; |
376 default: break; |
372 default: break; |
377 } |
373 } |
378 } |
374 } |
379 } |
375 } |
380 } |
376 } |