1 /* |
1 /* |
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2016, 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. |
973 if (CSEArrayLength || |
973 if (CSEArrayLength || |
974 (array->as_AccessField() && array->as_AccessField()->field()->is_constant()) || |
974 (array->as_AccessField() && array->as_AccessField()->field()->is_constant()) || |
975 (array->as_NewArray() && array->as_NewArray()->length() && array->as_NewArray()->length()->type()->is_constant())) { |
975 (array->as_NewArray() && array->as_NewArray()->length() && array->as_NewArray()->length()->type()->is_constant())) { |
976 length = append(new ArrayLength(array, state_before)); |
976 length = append(new ArrayLength(array, state_before)); |
977 } |
977 } |
978 StoreIndexed* result = new StoreIndexed(array, index, length, type, value, state_before); |
978 ciType* array_type = array->declared_type(); |
|
979 bool check_boolean = false; |
|
980 if (array_type != NULL) { |
|
981 if (array_type->is_loaded() && |
|
982 array_type->as_array_klass()->element_type()->basic_type() == T_BOOLEAN) { |
|
983 assert(type == T_BYTE, "boolean store uses bastore"); |
|
984 Value mask = append(new Constant(new IntConstant(1))); |
|
985 value = append(new LogicOp(Bytecodes::_iand, value, mask)); |
|
986 } |
|
987 } else if (type == T_BYTE) { |
|
988 check_boolean = true; |
|
989 } |
|
990 StoreIndexed* result = new StoreIndexed(array, index, length, type, value, state_before, check_boolean); |
979 append(result); |
991 append(result); |
980 _memory->store_value(value); |
992 _memory->store_value(value); |
981 |
993 |
982 if (type == T_OBJECT && is_profiling()) { |
994 if (type == T_OBJECT && is_profiling()) { |
983 // Note that we'd collect profile data in this method if we wanted it. |
995 // Note that we'd collect profile data in this method if we wanted it. |
1438 if (method()->name() == ciSymbol::object_initializer_name() && |
1450 if (method()->name() == ciSymbol::object_initializer_name() && |
1439 scope()->wrote_final()) { |
1451 scope()->wrote_final()) { |
1440 need_mem_bar = true; |
1452 need_mem_bar = true; |
1441 } |
1453 } |
1442 |
1454 |
|
1455 BasicType bt = method()->return_type()->basic_type(); |
|
1456 switch (bt) { |
|
1457 case T_BYTE: |
|
1458 { |
|
1459 Value shift = append(new Constant(new IntConstant(24))); |
|
1460 x = append(new ShiftOp(Bytecodes::_ishl, x, shift)); |
|
1461 x = append(new ShiftOp(Bytecodes::_ishr, x, shift)); |
|
1462 break; |
|
1463 } |
|
1464 case T_SHORT: |
|
1465 { |
|
1466 Value shift = append(new Constant(new IntConstant(16))); |
|
1467 x = append(new ShiftOp(Bytecodes::_ishl, x, shift)); |
|
1468 x = append(new ShiftOp(Bytecodes::_ishr, x, shift)); |
|
1469 break; |
|
1470 } |
|
1471 case T_CHAR: |
|
1472 { |
|
1473 Value mask = append(new Constant(new IntConstant(0xFFFF))); |
|
1474 x = append(new LogicOp(Bytecodes::_iand, x, mask)); |
|
1475 break; |
|
1476 } |
|
1477 case T_BOOLEAN: |
|
1478 { |
|
1479 Value mask = append(new Constant(new IntConstant(1))); |
|
1480 x = append(new LogicOp(Bytecodes::_iand, x, mask)); |
|
1481 break; |
|
1482 } |
|
1483 } |
|
1484 |
1443 // Check to see whether we are inlining. If so, Return |
1485 // Check to see whether we are inlining. If so, Return |
1444 // instructions become Gotos to the continuation point. |
1486 // instructions become Gotos to the continuation point. |
1445 if (continuation() != NULL) { |
1487 if (continuation() != NULL) { |
1446 assert(!method()->is_synchronized() || InlineSynchronizedMethods, "can not inline synchronized methods yet"); |
1488 assert(!method()->is_synchronized() || InlineSynchronizedMethods, "can not inline synchronized methods yet"); |
1447 |
1489 |
1584 } |
1626 } |
1585 case Bytecodes::_putstatic: |
1627 case Bytecodes::_putstatic: |
1586 { Value val = pop(type); |
1628 { Value val = pop(type); |
1587 if (state_before == NULL) { |
1629 if (state_before == NULL) { |
1588 state_before = copy_state_for_exception(); |
1630 state_before = copy_state_for_exception(); |
|
1631 } |
|
1632 if (field->type()->basic_type() == T_BOOLEAN) { |
|
1633 Value mask = append(new Constant(new IntConstant(1))); |
|
1634 val = append(new LogicOp(Bytecodes::_iand, val, mask)); |
1589 } |
1635 } |
1590 append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching)); |
1636 append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching)); |
1591 } |
1637 } |
1592 break; |
1638 break; |
1593 case Bytecodes::_getfield: { |
1639 case Bytecodes::_getfield: { |
1654 case Bytecodes::_putfield: { |
1700 case Bytecodes::_putfield: { |
1655 Value val = pop(type); |
1701 Value val = pop(type); |
1656 obj = apop(); |
1702 obj = apop(); |
1657 if (state_before == NULL) { |
1703 if (state_before == NULL) { |
1658 state_before = copy_state_for_exception(); |
1704 state_before = copy_state_for_exception(); |
|
1705 } |
|
1706 if (field->type()->basic_type() == T_BOOLEAN) { |
|
1707 Value mask = append(new Constant(new IntConstant(1))); |
|
1708 val = append(new LogicOp(Bytecodes::_iand, val, mask)); |
1659 } |
1709 } |
1660 StoreField* store = new StoreField(obj, offset, field, val, false, state_before, needs_patching); |
1710 StoreField* store = new StoreField(obj, offset, field, val, false, state_before, needs_patching); |
1661 if (!needs_patching) store = _memory->store(store); |
1711 if (!needs_patching) store = _memory->store(store); |
1662 if (store != NULL) { |
1712 if (store != NULL) { |
1663 append(store); |
1713 append(store); |
4220 null_check(args->at(0)); |
4270 null_check(args->at(0)); |
4221 Instruction* offset = args->at(2); |
4271 Instruction* offset = args->at(2); |
4222 #ifndef _LP64 |
4272 #ifndef _LP64 |
4223 offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT))); |
4273 offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT))); |
4224 #endif |
4274 #endif |
4225 Instruction* op = append(new UnsafePutObject(t, args->at(1), offset, args->at(3), is_volatile)); |
4275 Value val = args->at(3); |
|
4276 if (t == T_BOOLEAN) { |
|
4277 Value mask = append(new Constant(new IntConstant(1))); |
|
4278 val = append(new LogicOp(Bytecodes::_iand, val, mask)); |
|
4279 } |
|
4280 Instruction* op = append(new UnsafePutObject(t, args->at(1), offset, val, is_volatile)); |
4226 compilation()->set_has_unsafe_access(true); |
4281 compilation()->set_has_unsafe_access(true); |
4227 kill_all(); |
4282 kill_all(); |
4228 } |
4283 } |
4229 return InlineUnsafeOps; |
4284 return InlineUnsafeOps; |
4230 } |
4285 } |