src/share/vm/c1/c1_GraphBuilder.cpp

changeset 8415
d109bda16490
parent 8316
626f594dffa6
parent 8368
32b682649973
child 8604
04d83ba48607
child 8652
057571442f86
child 8739
0b85ccd62409
     1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Mar 29 23:01:10 2016 +0100
     1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Apr 05 08:55:39 2016 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -975,7 +975,19 @@
    1.11        (array->as_NewArray() && array->as_NewArray()->length() && array->as_NewArray()->length()->type()->is_constant())) {
    1.12      length = append(new ArrayLength(array, state_before));
    1.13    }
    1.14 -  StoreIndexed* result = new StoreIndexed(array, index, length, type, value, state_before);
    1.15 +  ciType* array_type = array->declared_type();
    1.16 +  bool check_boolean = false;
    1.17 +  if (array_type != NULL) {
    1.18 +    if (array_type->is_loaded() &&
    1.19 +      array_type->as_array_klass()->element_type()->basic_type() == T_BOOLEAN) {
    1.20 +      assert(type == T_BYTE, "boolean store uses bastore");
    1.21 +      Value mask = append(new Constant(new IntConstant(1)));
    1.22 +      value = append(new LogicOp(Bytecodes::_iand, value, mask));
    1.23 +    }
    1.24 +  } else if (type == T_BYTE) {
    1.25 +    check_boolean = true;
    1.26 +  }
    1.27 +  StoreIndexed* result = new StoreIndexed(array, index, length, type, value, state_before, check_boolean);
    1.28    append(result);
    1.29    _memory->store_value(value);
    1.30  
    1.31 @@ -1440,6 +1452,36 @@
    1.32      need_mem_bar = true;
    1.33    }
    1.34  
    1.35 +  BasicType bt = method()->return_type()->basic_type();
    1.36 +  switch (bt) {
    1.37 +    case T_BYTE:
    1.38 +    {
    1.39 +      Value shift = append(new Constant(new IntConstant(24)));
    1.40 +      x = append(new ShiftOp(Bytecodes::_ishl, x, shift));
    1.41 +      x = append(new ShiftOp(Bytecodes::_ishr, x, shift));
    1.42 +      break;
    1.43 +    }
    1.44 +    case T_SHORT:
    1.45 +    {
    1.46 +      Value shift = append(new Constant(new IntConstant(16)));
    1.47 +      x = append(new ShiftOp(Bytecodes::_ishl, x, shift));
    1.48 +      x = append(new ShiftOp(Bytecodes::_ishr, x, shift));
    1.49 +      break;
    1.50 +    }
    1.51 +    case T_CHAR:
    1.52 +    {
    1.53 +      Value mask = append(new Constant(new IntConstant(0xFFFF)));
    1.54 +      x = append(new LogicOp(Bytecodes::_iand, x, mask));
    1.55 +      break;
    1.56 +    }
    1.57 +    case T_BOOLEAN:
    1.58 +    {
    1.59 +      Value mask = append(new Constant(new IntConstant(1)));
    1.60 +      x = append(new LogicOp(Bytecodes::_iand, x, mask));
    1.61 +      break;
    1.62 +    }
    1.63 +  }
    1.64 +
    1.65    // Check to see whether we are inlining. If so, Return
    1.66    // instructions become Gotos to the continuation point.
    1.67    if (continuation() != NULL) {
    1.68 @@ -1587,6 +1629,10 @@
    1.69          if (state_before == NULL) {
    1.70            state_before = copy_state_for_exception();
    1.71          }
    1.72 +        if (field->type()->basic_type() == T_BOOLEAN) {
    1.73 +          Value mask = append(new Constant(new IntConstant(1)));
    1.74 +          val = append(new LogicOp(Bytecodes::_iand, val, mask));
    1.75 +        }
    1.76          append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
    1.77        }
    1.78        break;
    1.79 @@ -1657,6 +1703,10 @@
    1.80        if (state_before == NULL) {
    1.81          state_before = copy_state_for_exception();
    1.82        }
    1.83 +      if (field->type()->basic_type() == T_BOOLEAN) {
    1.84 +        Value mask = append(new Constant(new IntConstant(1)));
    1.85 +        val = append(new LogicOp(Bytecodes::_iand, val, mask));
    1.86 +      }
    1.87        StoreField* store = new StoreField(obj, offset, field, val, false, state_before, needs_patching);
    1.88        if (!needs_patching) store = _memory->store(store);
    1.89        if (store != NULL) {
    1.90 @@ -4222,7 +4272,12 @@
    1.91  #ifndef _LP64
    1.92      offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT)));
    1.93  #endif
    1.94 -    Instruction* op = append(new UnsafePutObject(t, args->at(1), offset, args->at(3), is_volatile));
    1.95 +    Value val = args->at(3);
    1.96 +    if (t == T_BOOLEAN) {
    1.97 +      Value mask = append(new Constant(new IntConstant(1)));
    1.98 +      val = append(new LogicOp(Bytecodes::_iand, val, mask));
    1.99 +    }
   1.100 +    Instruction* op = append(new UnsafePutObject(t, args->at(1), offset, val, is_volatile));
   1.101      compilation()->set_has_unsafe_access(true);
   1.102      kill_all();
   1.103    }

mercurial