Merge

Tue, 05 Apr 2016 08:55:39 -0700

author
asaha
date
Tue, 05 Apr 2016 08:55:39 -0700
changeset 8415
d109bda16490
parent 8332
b5b3db42efca
parent 8414
dfe33f6d046b
child 8416
d957cf0b00ac

Merge

.hgtags file | annotate | diff | comparison | revisions
src/cpu/x86/vm/c1_LIRGenerator_x86.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_Canonicalizer.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_GraphBuilder.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_LIRGenerator.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_LIRGenerator.hpp file | annotate | diff | comparison | revisions
src/share/vm/classfile/classFileParser.cpp file | annotate | diff | comparison | revisions
src/share/vm/interpreter/templateInterpreter.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/parse1.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/parse2.cpp file | annotate | diff | comparison | revisions
src/share/vm/prims/jvmtiEnvBase.cpp file | annotate | diff | comparison | revisions
src/share/vm/prims/jvmtiExport.cpp file | annotate | diff | comparison | revisions
src/share/vm/prims/unsafe.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Tue Mar 29 23:01:10 2016 +0100
     1.2 +++ b/.hgtags	Tue Apr 05 08:55:39 2016 -0700
     1.3 @@ -670,6 +670,7 @@
     1.4  20bad8c6c7b406c3603b4e22b15cd990840a9d62 jdk8u51-b31
     1.5  e51afd2a1fc17de59ff3c79003210a40a28ac960 jdk8u51-b32
     1.6  b2427357cc98aeb2716ee2e89e733794afb4057b jdk8u51-b33
     1.7 +4b722db6d38583ee3e71c43d9996bf1ebb8a412e jdk8u51-b34
     1.8  d9349fa8822336e0244da0a8448f3e6b2d62741d jdk8u60-b00
     1.9  d9349fa8822336e0244da0a8448f3e6b2d62741d hs25.60-b00
    1.10  ebf89088c08ab0508b9002b48dd3d68a340259af hs25.60-b01
    1.11 @@ -763,6 +764,11 @@
    1.12  a6f2a7ba281291f5dab79fa494f7cfaa6232c88b jdk8u66-b17
    1.13  9ae2a5adabba97d9ebf79e13b325f1ff368ce014 jdk8u66-b18
    1.14  527f62b70faee4a0c15f365def024b87012e6934 jdk8u66-b31
    1.15 +d8be40462cfb6de441818aec8c30e03077189010 jdk8u66-b32
    1.16 +6a0b19c56d797c2975f0cf505190e8f5d69b0b7a jdk8u66-b33
    1.17 +3d55b1055c782375e39ebbddba2887379bc3531c jdk8u66-b34
    1.18 +95b0e04287fb443a4eee64504e0f18bc324c7abd jdk8u66-b35
    1.19 +dce99debdba26def128cd8b2d3eae93d7d789ee2 jdk8u66-b36
    1.20  9a158a0c243beb610dbaabd63d6218d3ce5825f1 jdk8u71-b00
    1.21  67df26e363fb7e722032fd286673642fc999957c jdk8u71-b01
    1.22  1a799d49de23d84f658ade1d3805a1924e7e1e84 jdk8u71-b02
    1.23 @@ -801,6 +807,26 @@
    1.24  451dda77f6c29bd3260e87f847a9eadae122a759 jdk8u74-b00
    1.25  c1031a924f2c910fad078838b88a2f0146f2de98 jdk8u74-b01
    1.26  ca9cae9aa9e989bbe6713c91d55c913edeaecce4 jdk8u74-b02
    1.27 +da43260704c28b9f19cb652090ae65c258220fd6 jdk8u72-b31
    1.28 +c0242ea4bde19d72be5149feda112a39e8c89b0a jdk8u75-b00
    1.29 +ca3b8c8e390ab0540b0cc2e5def869b38e460d86 jdk8u75-b01
    1.30 +9aef5b5e0a68f20059cfa9e2806b4ff0e11a3d31 jdk8u75-b02
    1.31 +2df9fe896819362b9075a670b78106b249e50d6d jdk8u75-b03
    1.32 +32b682649973231b54740c09b10889660f6ebde5 jdk8u75-b04
    1.33 +1f43bd4fab06d2ca5d1964611df14d8506d6b36e jdk8u75-b05
    1.34 +916712f178c39d0acbc590f38802133fc86a7346 jdk8u75-b06
    1.35 +8c791dd1c24d85ebd18b03d49185c2a25263c129 jdk8u75-b07
    1.36 +e4a935cb6f7178912fd653e2a9514eadec7935ab jdk8u75-b08
    1.37 +e97c45c377eb8d022cfe24b73737fa312107e0a5 jdk8u75-b09
    1.38 +d44c7e324682a30e064503ef9582d83a41f4173e jdk8u75-b10
    1.39 +cc78c97abff85062d6844fa253081e26a0a60150 jdk8u75-b12
    1.40 +1b6d4fd2730e58f17820930f797938dc182117c4 jdk8u77-b00
    1.41 +ddd297e340b1170d3cec011ee64e729f8b493c86 jdk8u77-b01
    1.42 +1b4072e4bb3ad54c4e894998486a8b33f0689160 jdk8u77-b02
    1.43 +223b64a19e94222dd97b92bb40abcfbc0bf6ef1f jdk8u77-b03
    1.44 +bbbb05e91c629f8d9eef2ba43933767f68a898b0 jdk8u91-b00
    1.45 +e36b6ade0499eadfd8673fe62ef0a613af2e6d67 jdk8u91-b13
    1.46 +fa8991ccf6e5b74890a0b5672440b3c09d8d8732 jdk8u91-b14
    1.47  1b6d4fd2730e58f17820930f797938dc182117c4 jdk8u77-b00
    1.48  ddd297e340b1170d3cec011ee64e729f8b493c86 jdk8u77-b01
    1.49  1b4072e4bb3ad54c4e894998486a8b33f0689160 jdk8u77-b02
    1.50 @@ -810,6 +836,17 @@
    1.51  218483967e52b419d885d34af4488a81c5133804 jdk8u76-b02
    1.52  2a2720daacaa8d9a3ba9435cfaaf9751241d2062 jdk8u76-b03
    1.53  16f7b676725aadafb79ea105b22df112e2593a78 jdk8u76-b04
    1.54 +35bfaf7f9021b5c1e86effbeac075753a82e9a0c jdk8u76-b05
    1.55 +6449ee3bf707225372709ac830524c00984c601f jdk8u76-b06
    1.56 +7d1074c74d6000ec8257917ebfcee3fed4249f7d jdk8u76-b07
    1.57 +392f8722fc513e28f78c5c563d51af7dc8466b29 jdk8u76-b08
    1.58 +3bf0f5b8a892defd0bf9731b4e15926881fcda74 jdk8u76-b09
    1.59 +a2b0ee820059a44be558a2d435b7d85ed5a8b63a jdk8u76-b10
    1.60 +16aa1f621ec67db1a55ebf6527750164ab63088d jdk8u76-b11
    1.61 +9a87701e22b3cae79fdfd8cdb732051e02a710fa jdk8u76-b12
    1.62 +481dcde745b6aec035781ed9f6797cfc93719f71 jdk8u92-b00
    1.63 +f3e1e734e2d29101a9537ddeb71ecad413fcd352 jdk8u92-b13
    1.64 +24a09407d71bb2cc4848bfa21660c890b4d722b1 jdk8u92-b14
    1.65  d6c92b9e192ef97305a699e868387d55821c81ad jdk8u102-b00
    1.66  d6c92b9e192ef97305a699e868387d55821c81ad jdk8u82-b00
    1.67  516a64e6d7c2dc29fd932bf3b8313e560a01bcd0 jdk8u102-b01
     2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/interpreter/Bytecodes.java	Tue Mar 29 23:01:10 2016 +0100
     2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/interpreter/Bytecodes.java	Tue Apr 05 08:55:39 2016 -0700
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -253,29 +253,30 @@
    2.11    public static final int _fast_sgetfield       = 210;
    2.12    public static final int _fast_aputfield       = 211;
    2.13    public static final int _fast_bputfield       = 212;
    2.14 -  public static final int _fast_cputfield       = 213;
    2.15 -  public static final int _fast_dputfield       = 214;
    2.16 -  public static final int _fast_fputfield       = 215;
    2.17 -  public static final int _fast_iputfield       = 216;
    2.18 -  public static final int _fast_lputfield       = 217;
    2.19 -  public static final int _fast_sputfield       = 218;
    2.20 -  public static final int _fast_aload_0         = 219;
    2.21 -  public static final int _fast_iaccess_0       = 220;
    2.22 -  public static final int _fast_aaccess_0       = 221;
    2.23 -  public static final int _fast_faccess_0       = 222;
    2.24 -  public static final int _fast_iload           = 223;
    2.25 -  public static final int _fast_iload2          = 224;
    2.26 -  public static final int _fast_icaload         = 225;
    2.27 -  public static final int _fast_invokevfinal    = 226;
    2.28 -  public static final int _fast_linearswitch    = 227;
    2.29 -  public static final int _fast_binaryswitch    = 228;
    2.30 -  public static final int _fast_aldc            = 229;
    2.31 -  public static final int _fast_aldc_w          = 230;
    2.32 -  public static final int _return_register_finalizer = 231;
    2.33 -  public static final int _invokehandle         = 232;
    2.34 -  public static final int _shouldnotreachhere   = 233; // For debugging
    2.35 +  public static final int _fast_zputfield       = 213;
    2.36 +  public static final int _fast_cputfield       = 214;
    2.37 +  public static final int _fast_dputfield       = 215;
    2.38 +  public static final int _fast_fputfield       = 216;
    2.39 +  public static final int _fast_iputfield       = 217;
    2.40 +  public static final int _fast_lputfield       = 218;
    2.41 +  public static final int _fast_sputfield       = 219;
    2.42 +  public static final int _fast_aload_0         = 220;
    2.43 +  public static final int _fast_iaccess_0       = 221;
    2.44 +  public static final int _fast_aaccess_0       = 222;
    2.45 +  public static final int _fast_faccess_0       = 223;
    2.46 +  public static final int _fast_iload           = 224;
    2.47 +  public static final int _fast_iload2          = 225;
    2.48 +  public static final int _fast_icaload         = 226;
    2.49 +  public static final int _fast_invokevfinal    = 227;
    2.50 +  public static final int _fast_linearswitch    = 228;
    2.51 +  public static final int _fast_binaryswitch    = 229;
    2.52 +  public static final int _fast_aldc            = 230;
    2.53 +  public static final int _fast_aldc_w          = 231;
    2.54 +  public static final int _return_register_finalizer = 232;
    2.55 +  public static final int _invokehandle         = 233;
    2.56 +  public static final int _shouldnotreachhere   = 234; // For debugging
    2.57  
    2.58 -  public static final int number_of_codes       = 234;
    2.59 +  public static final int number_of_codes       = 235;
    2.60  
    2.61    // Flag bits derived from format strings, can_trap, can_rewrite, etc.:
    2.62    // semantic flags:
    2.63 @@ -776,6 +777,7 @@
    2.64  
    2.65      def(_fast_aputfield      , "fast_aputfield"      , "bJJ"  , null    , BasicType.getTObject() ,  0, true , _putfield       );
    2.66      def(_fast_bputfield      , "fast_bputfield"      , "bJJ"  , null    , BasicType.getTInt()    ,  0, true , _putfield       );
    2.67 +    def(_fast_zputfield      , "fast_zputfield"      , "bJJ"  , null    , BasicType.getTInt()    ,  0, true , _putfield       );
    2.68      def(_fast_cputfield      , "fast_cputfield"      , "bJJ"  , null    , BasicType.getTChar()   ,  0, true , _putfield       );
    2.69      def(_fast_dputfield      , "fast_dputfield"      , "bJJ"  , null    , BasicType.getTDouble() ,  0, true , _putfield       );
    2.70      def(_fast_fputfield      , "fast_fputfield"      , "bJJ"  , null    , BasicType.getTFloat()  ,  0, true , _putfield       );
     3.1 --- a/src/cpu/ppc/vm/interp_masm_ppc_64.cpp	Tue Mar 29 23:01:10 2016 +0100
     3.2 +++ b/src/cpu/ppc/vm/interp_masm_ppc_64.cpp	Tue Apr 05 08:55:39 2016 -0700
     3.3 @@ -174,6 +174,7 @@
     3.4      case ltos: ld(R17_tos, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState);
     3.5                 break;
     3.6      case btos: // fall through
     3.7 +    case ztos: // fall through
     3.8      case ctos: // fall through
     3.9      case stos: // fall through
    3.10      case itos: lwz(R17_tos, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState);
    3.11 @@ -302,6 +303,7 @@
    3.12    switch (state) {
    3.13      case atos: push_ptr();                break;
    3.14      case btos:
    3.15 +    case ztos:
    3.16      case ctos:
    3.17      case stos:
    3.18      case itos: push_i();                  break;
    3.19 @@ -317,6 +319,7 @@
    3.20    switch (state) {
    3.21      case atos: pop_ptr();            break;
    3.22      case btos:
    3.23 +    case ztos:
    3.24      case ctos:
    3.25      case stos:
    3.26      case itos: pop_i();              break;
    3.27 @@ -751,6 +754,43 @@
    3.28    stdux(Rscratch2, R1_SP, Rscratch1); // atomically set *(SP = top_frame_sp) = **SP
    3.29  }
    3.30  
    3.31 +void InterpreterMacroAssembler::narrow(Register result) {
    3.32 +  Register ret_type = R11_scratch1;
    3.33 +  ld(R11_scratch1, in_bytes(Method::const_offset()), R19_method);
    3.34 +  lbz(ret_type, in_bytes(ConstMethod::result_type_offset()), R11_scratch1);
    3.35 +
    3.36 +  Label notBool, notByte, notChar, done;
    3.37 +
    3.38 +  // common case first
    3.39 +  cmpwi(CCR0, ret_type, T_INT);
    3.40 +  beq(CCR0, done);
    3.41 +
    3.42 +  cmpwi(CCR0, ret_type, T_BOOLEAN);
    3.43 +  bne(CCR0, notBool);
    3.44 +  andi(result, result, 0x1);
    3.45 +  b(done);
    3.46 +
    3.47 +  bind(notBool);
    3.48 +  cmpwi(CCR0, ret_type, T_BYTE);
    3.49 +  bne(CCR0, notByte);
    3.50 +  extsb(result, result);
    3.51 +  b(done);
    3.52 +
    3.53 +  bind(notByte);
    3.54 +  cmpwi(CCR0, ret_type, T_CHAR);
    3.55 +  bne(CCR0, notChar);
    3.56 +  andi(result, result, 0xffff);
    3.57 +  b(done);
    3.58 +
    3.59 +  bind(notChar);
    3.60 +  // cmpwi(CCR0, ret_type, T_SHORT);  // all that's left
    3.61 +  // bne(CCR0, done);
    3.62 +  extsh(result, result);
    3.63 +
    3.64 +  // Nothing to do for T_INT
    3.65 +  bind(done);
    3.66 +}
    3.67 +
    3.68  // Remove activation.
    3.69  //
    3.70  // Unlock the receiver if this is a synchronized method.
     4.1 --- a/src/cpu/ppc/vm/interp_masm_ppc_64.hpp	Tue Mar 29 23:01:10 2016 +0100
     4.2 +++ b/src/cpu/ppc/vm/interp_masm_ppc_64.hpp	Tue Apr 05 08:55:39 2016 -0700
     4.3 @@ -149,6 +149,8 @@
     4.4    void get_cpool_and_tags(Register Rcpool, Register Rtags);
     4.5    void is_a(Label& L);
     4.6  
     4.7 +  void narrow(Register result);
     4.8 +
     4.9    // Java Call Helpers
    4.10    void call_from_interpreter(Register Rtarget_method, Register Rret_addr, Register Rscratch1, Register Rscratch2);
    4.11  
     5.1 --- a/src/cpu/ppc/vm/interpreter_ppc.cpp	Tue Mar 29 23:01:10 2016 +0100
     5.2 +++ b/src/cpu/ppc/vm/interpreter_ppc.cpp	Tue Apr 05 08:55:39 2016 -0700
     5.3 @@ -640,6 +640,16 @@
     5.4      __ blr();
     5.5    }
     5.6  
     5.7 +  if (branch_table[ztos] == 0) { // generate only once
     5.8 +    __ align(32, 28, 28); // align load
     5.9 +    __ fence(); // volatile entry point (one instruction before non-volatile_entry point)
    5.10 +    branch_table[ztos] = __ pc(); // non-volatile_entry point
    5.11 +    __ lbzx(R3_RET, Rclass_or_obj, Roffset);
    5.12 +    __ extsb(R3_RET, R3_RET);
    5.13 +    __ beq(CCR6, Lacquire);
    5.14 +    __ blr();
    5.15 +  }
    5.16 +
    5.17    if (branch_table[ctos] == 0) { // generate only once
    5.18      __ align(32, 28, 28); // align load
    5.19      __ fence(); // volatile entry point (one instruction before non-volatile_entry point)
     6.1 --- a/src/cpu/ppc/vm/templateInterpreter_ppc.cpp	Tue Mar 29 23:01:10 2016 +0100
     6.2 +++ b/src/cpu/ppc/vm/templateInterpreter_ppc.cpp	Tue Apr 05 08:55:39 2016 -0700
     6.3 @@ -154,6 +154,7 @@
     6.4    switch (state) {
     6.5      case ltos:
     6.6      case btos:
     6.7 +    case ztos:
     6.8      case ctos:
     6.9      case stos:
    6.10      case atos:
    6.11 @@ -200,6 +201,7 @@
    6.12    switch (state) {
    6.13      case ltos:
    6.14      case btos:
    6.15 +    case ztos:
    6.16      case ctos:
    6.17      case stos:
    6.18      case atos:
    6.19 @@ -1642,12 +1644,14 @@
    6.20    // Copied from TemplateTable::_return.
    6.21    // Restoration of lr done by remove_activation.
    6.22    switch (state) {
    6.23 +    // Narrow result if state is itos but result type is smaller.
    6.24 +    case itos: __ narrow(R17_tos); /* fall through */
    6.25      case ltos:
    6.26      case btos:
    6.27 +    case ztos:
    6.28      case ctos:
    6.29      case stos:
    6.30 -    case atos:
    6.31 -    case itos: __ mr(R3_RET, R17_tos); break;
    6.32 +    case atos: __ mr(R3_RET, R17_tos); break;
    6.33      case ftos:
    6.34      case dtos: __ fmr(F1_RET, F15_ftos); break;
    6.35      case vtos: // This might be a constructor. Final fields (and volatile fields on PPC64) need
    6.36 @@ -1717,6 +1721,10 @@
    6.37      bname = "trace_code_btos {";
    6.38      tsize = 2;
    6.39      break;
    6.40 +  case ztos:
    6.41 +    bname = "trace_code_ztos {";
    6.42 +    tsize = 2;
    6.43 +    break;
    6.44    case ctos:
    6.45      bname = "trace_code_ctos {";
    6.46      tsize = 2;
     7.1 --- a/src/cpu/ppc/vm/templateTable_ppc_64.cpp	Tue Mar 29 23:01:10 2016 +0100
     7.2 +++ b/src/cpu/ppc/vm/templateTable_ppc_64.cpp	Tue Apr 05 08:55:39 2016 -0700
     7.3 @@ -173,6 +173,7 @@
     7.4    switch (new_bc) {
     7.5      case Bytecodes::_fast_aputfield:
     7.6      case Bytecodes::_fast_bputfield:
     7.7 +    case Bytecodes::_fast_zputfield:
     7.8      case Bytecodes::_fast_cputfield:
     7.9      case Bytecodes::_fast_dputfield:
    7.10      case Bytecodes::_fast_fputfield:
    7.11 @@ -969,9 +970,21 @@
    7.12                   Rarray   = R12_scratch2,
    7.13                   Rscratch = R3_ARG1;
    7.14    __ pop_i(Rindex);
    7.15 +  __ pop_ptr(Rarray);
    7.16    // tos: val
    7.17 -  // Rarray: array ptr (popped by index_check)
    7.18 -  __ index_check(Rarray, Rindex, 0, Rscratch, Rarray);
    7.19 +
    7.20 +  // Need to check whether array is boolean or byte
    7.21 +  // since both types share the bastore bytecode.
    7.22 +  __ load_klass(Rscratch, Rarray);
    7.23 +  __ lwz(Rscratch, in_bytes(Klass::layout_helper_offset()), Rscratch);
    7.24 +  int diffbit = exact_log2(Klass::layout_helper_boolean_diffbit());
    7.25 +  __ testbitdi(CCR0, R0, Rscratch, diffbit);
    7.26 +  Label L_skip;
    7.27 +  __ bfalse(CCR0, L_skip);
    7.28 +  __ andi(R17_tos, R17_tos, 1);  // if it is a T_BOOLEAN array, mask the stored value to 0/1
    7.29 +  __ bind(L_skip);
    7.30 +
    7.31 +  __ index_check_without_pop(Rarray, Rindex, 0, Rscratch, Rarray);
    7.32    __ stb(R17_tos, arrayOopDesc::base_offset_in_bytes(T_BYTE), Rarray);
    7.33  }
    7.34  
    7.35 @@ -2100,12 +2113,16 @@
    7.36    __ remove_activation(state, /* throw_monitor_exception */ true);
    7.37    // Restoration of lr done by remove_activation.
    7.38    switch (state) {
    7.39 +    // Narrow result if state is itos but result type is smaller.
    7.40 +    // Need to narrow in the return bytecode rather than in generate_return_entry
    7.41 +    // since compiled code callers expect the result to already be narrowed.
    7.42 +    case itos: __ narrow(R17_tos); /* fall through */
    7.43      case ltos:
    7.44      case btos:
    7.45 +    case ztos:
    7.46      case ctos:
    7.47      case stos:
    7.48 -    case atos:
    7.49 -    case itos: __ mr(R3_RET, R17_tos); break;
    7.50 +    case atos: __ mr(R3_RET, R17_tos); break;
    7.51      case ftos:
    7.52      case dtos: __ fmr(F1_RET, F15_ftos); break;
    7.53      case vtos: // This might be a constructor. Final fields (and volatile fields on PPC64) need
    7.54 @@ -2501,6 +2518,21 @@
    7.55    __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
    7.56  
    7.57    __ align(32, 28, 28); // Align load.
    7.58 +  // __ bind(Lztos); (same code as btos)
    7.59 +  __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
    7.60 +  assert(branch_table[ztos] == 0, "can't compute twice");
    7.61 +  branch_table[ztos] = __ pc(); // non-volatile_entry point
    7.62 +  __ lbzx(R17_tos, Rclass_or_obj, Roffset);
    7.63 +  __ extsb(R17_tos, R17_tos);
    7.64 +  __ push(ztos);
    7.65 +  if (!is_static) {
    7.66 +    // use btos rewriting, no truncating to t/f bit is needed for getfield.
    7.67 +    patch_bytecode(Bytecodes::_fast_bgetfield, Rbc, Rscratch);
    7.68 +  }
    7.69 +  __ beq(CCR6, Lacquire); // Volatile?
    7.70 +  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
    7.71 +
    7.72 +  __ align(32, 28, 28); // Align load.
    7.73    // __ bind(Lctos);
    7.74    __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
    7.75    assert(branch_table[ctos] == 0, "can't compute twice");
    7.76 @@ -2590,6 +2622,7 @@
    7.77          case Bytecodes::_fast_aputfield: __ push_ptr(); offs+= Interpreter::stackElementSize; break;
    7.78          case Bytecodes::_fast_iputfield: // Fall through
    7.79          case Bytecodes::_fast_bputfield: // Fall through
    7.80 +        case Bytecodes::_fast_zputfield: // Fall through
    7.81          case Bytecodes::_fast_cputfield: // Fall through
    7.82          case Bytecodes::_fast_sputfield: __ push_i(); offs+=  Interpreter::stackElementSize; break;
    7.83          case Bytecodes::_fast_lputfield: __ push_l(); offs+=2*Interpreter::stackElementSize; break;
    7.84 @@ -2630,6 +2663,7 @@
    7.85        case Bytecodes::_fast_aputfield: __ pop_ptr(); break;
    7.86        case Bytecodes::_fast_iputfield: // Fall through
    7.87        case Bytecodes::_fast_bputfield: // Fall through
    7.88 +      case Bytecodes::_fast_zputfield: // Fall through
    7.89        case Bytecodes::_fast_cputfield: // Fall through
    7.90        case Bytecodes::_fast_sputfield: __ pop_i(); break;
    7.91        case Bytecodes::_fast_lputfield: __ pop_l(); break;
    7.92 @@ -2781,6 +2815,21 @@
    7.93    __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
    7.94  
    7.95    __ align(32, 28, 28); // Align pop.
    7.96 +  // __ bind(Lztos);
    7.97 +  __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
    7.98 +  assert(branch_table[ztos] == 0, "can't compute twice");
    7.99 +  branch_table[ztos] = __ pc(); // non-volatile_entry point
   7.100 +  __ pop(ztos);
   7.101 +  if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
   7.102 +  __ andi(R17_tos, R17_tos, 0x1);
   7.103 +  __ stbx(R17_tos, Rclass_or_obj, Roffset);
   7.104 +  if (!is_static) { patch_bytecode(Bytecodes::_fast_zputfield, Rbc, Rscratch, true, byte_no); }
   7.105 +  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
   7.106 +    __ beq(CR_is_vol, Lvolatile); // Volatile?
   7.107 +  }
   7.108 +  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
   7.109 +
   7.110 +  __ align(32, 28, 28); // Align pop.
   7.111    // __ bind(Lctos);
   7.112    __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
   7.113    assert(branch_table[ctos] == 0, "can't compute twice");
   7.114 @@ -2895,6 +2944,9 @@
   7.115        __ stdx(R17_tos, Rclass_or_obj, Roffset);
   7.116        break;
   7.117  
   7.118 +    case Bytecodes::_fast_zputfield:
   7.119 +      __ andi(R17_tos, R17_tos, 0x1);  // boolean is true if LSB is 1
   7.120 +      // fall through to bputfield
   7.121      case Bytecodes::_fast_bputfield:
   7.122        __ stbx(R17_tos, Rclass_or_obj, Roffset);
   7.123        break;
     8.1 --- a/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Tue Mar 29 23:01:10 2016 +0100
     8.2 +++ b/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Tue Apr 05 08:55:39 2016 -0700
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
     8.6 + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
     8.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8   *
     8.9   * This code is free software; you can redistribute it and/or modify it
    8.10 @@ -343,7 +343,7 @@
    8.11      length.set_instruction(x->length());
    8.12      length.load_item();
    8.13    }
    8.14 -  if (needs_store_check) {
    8.15 +  if (needs_store_check || x->check_boolean()) {
    8.16      value.load_item();
    8.17    } else {
    8.18      value.load_for_store(x->elt_type());
    8.19 @@ -388,7 +388,8 @@
    8.20      pre_barrier(LIR_OprFact::address(array_addr), LIR_OprFact::illegalOpr /* pre_val */,
    8.21                  true /* do_load */, false /* patch */, NULL);
    8.22    }
    8.23 -  __ move(value.result(), array_addr, null_check_info);
    8.24 +  LIR_Opr result = maybe_mask_boolean(x, array.result(), value.result(), null_check_info);
    8.25 +  __ move(result, array_addr, null_check_info);
    8.26    if (obj_store) {
    8.27      // Precise card mark
    8.28      post_barrier(LIR_OprFact::address(array_addr), value.result());
     9.1 --- a/src/cpu/sparc/vm/cppInterpreter_sparc.cpp	Tue Mar 29 23:01:10 2016 +0100
     9.2 +++ b/src/cpu/sparc/vm/cppInterpreter_sparc.cpp	Tue Apr 05 08:55:39 2016 -0700
     9.3 @@ -1,5 +1,5 @@
     9.4  /*
     9.5 - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
     9.6 + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
     9.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.8   *
     9.9   * This code is free software; you can redistribute it and/or modify it
    9.10 @@ -539,6 +539,9 @@
    9.11      __ cmp(G1_scratch, btos);
    9.12      __ br(Assembler::equal, true, Assembler::pt, xreturn_path);
    9.13      __ delayed()->ldsb(Otos_i, G3_scratch, Otos_i);
    9.14 +    __ cmp(G1_scratch, ztos);
    9.15 +    __ br(Assembler::equal, true, Assembler::pt, xreturn_path);
    9.16 +    __ delayed()->ldsb(Otos_i, G3_scratch, Otos_i);
    9.17      __ should_not_reach_here();
    9.18  #endif
    9.19      __ ldsb(Otos_i, G3_scratch, Otos_i);
    10.1 --- a/src/cpu/sparc/vm/interp_masm_sparc.cpp	Tue Mar 29 23:01:10 2016 +0100
    10.2 +++ b/src/cpu/sparc/vm/interp_masm_sparc.cpp	Tue Apr 05 08:55:39 2016 -0700
    10.3 @@ -1,5 +1,5 @@
    10.4  /*
    10.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    10.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    10.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.8   *
    10.9   * This code is free software; you can redistribute it and/or modify it
   10.10 @@ -211,6 +211,7 @@
   10.11    case atos: ld_ptr(oop_addr, Otos_l);
   10.12               st_ptr(G0, oop_addr);                        break;
   10.13    case btos:                                           // fall through
   10.14 +  case ztos:                                           // fall through
   10.15    case ctos:                                           // fall through
   10.16    case stos:                                           // fall through
   10.17    case itos: ld(val_addr, Otos_l1);                       break;
   10.18 @@ -459,9 +460,10 @@
   10.19    interp_verify_oop(Otos_i, state, __FILE__, __LINE__);
   10.20    switch (state) {
   10.21      case atos: push_ptr();            break;
   10.22 -    case btos: push_i();              break;
   10.23 -    case ctos:
   10.24 -    case stos: push_i();              break;
   10.25 +    case btos:                        // fall through
   10.26 +    case ztos:                        // fall through
   10.27 +    case ctos:                        // fall through
   10.28 +    case stos:                        // fall through
   10.29      case itos: push_i();              break;
   10.30      case ltos: push_l();              break;
   10.31      case ftos: push_f();              break;
   10.32 @@ -475,9 +477,10 @@
   10.33  void InterpreterMacroAssembler::pop(TosState state) {
   10.34    switch (state) {
   10.35      case atos: pop_ptr();            break;
   10.36 -    case btos: pop_i();              break;
   10.37 -    case ctos:
   10.38 -    case stos: pop_i();              break;
   10.39 +    case btos:                       // fall through
   10.40 +    case ztos:                       // fall through
   10.41 +    case ctos:                       // fall through
   10.42 +    case stos:                       // fall through
   10.43      case itos: pop_i();              break;
   10.44      case ltos: pop_l();              break;
   10.45      case ftos: pop_f();              break;
   10.46 @@ -1111,6 +1114,49 @@
   10.47    interp_verify_oop(Otos_i, state, __FILE__, __LINE__);
   10.48  }
   10.49  
   10.50 +void InterpreterMacroAssembler::narrow(Register result) {
   10.51 +
   10.52 +  ld_ptr(Address(Lmethod, Method::const_offset()), G3_scratch);
   10.53 +  ldub(G3_scratch, in_bytes(ConstMethod::result_type_offset()), G3_scratch);
   10.54 +
   10.55 +  Label notBool, notByte, notChar, done;
   10.56 +
   10.57 +  // common case first
   10.58 +  cmp(G3_scratch, T_INT);
   10.59 +  br(Assembler::equal, true, pn, done);
   10.60 +  delayed()->nop();
   10.61 +
   10.62 +  cmp(G3_scratch, T_BOOLEAN);
   10.63 +  br(Assembler::notEqual, true, pn, notBool);
   10.64 +  delayed()->cmp(G3_scratch, T_BYTE);
   10.65 +  and3(result, 1, result);
   10.66 +  ba(done);
   10.67 +  delayed()->nop();
   10.68 +
   10.69 +  bind(notBool);
   10.70 +  // cmp(G3_scratch, T_BYTE);
   10.71 +  br(Assembler::notEqual, true, pn, notByte);
   10.72 +  delayed()->cmp(G3_scratch, T_CHAR);
   10.73 +  sll(result, 24, result);
   10.74 +  sra(result, 24, result);
   10.75 +  ba(done);
   10.76 +  delayed()->nop();
   10.77 +
   10.78 +  bind(notByte);
   10.79 +  // cmp(G3_scratch, T_CHAR);
   10.80 +  sll(result, 16, result);
   10.81 +  br(Assembler::notEqual, true, pn, done);
   10.82 +  delayed()->sra(result, 16, result);
   10.83 +  // sll(result, 16, result);
   10.84 +  srl(result, 16, result);
   10.85 +
   10.86 +  // bind(notChar);
   10.87 +  // must be short, instructions already executed in delay slot
   10.88 +  // sll(result, 16, result);
   10.89 +  // sra(result, 16, result);
   10.90 +
   10.91 +  bind(done);
   10.92 +}
   10.93  
   10.94  // remove activation
   10.95  //
   10.96 @@ -1146,6 +1192,7 @@
   10.97    case ltos: mov(Otos_l2, Otos_l2->after_save()); // fall through  // O1 -> I1
   10.98  #endif
   10.99    case btos:                                      // fall through
  10.100 +  case ztos:                                      // fall through
  10.101    case ctos:
  10.102    case stos:                                      // fall through
  10.103    case atos:                                      // fall through
    11.1 --- a/src/cpu/sparc/vm/interp_masm_sparc.hpp	Tue Mar 29 23:01:10 2016 +0100
    11.2 +++ b/src/cpu/sparc/vm/interp_masm_sparc.hpp	Tue Apr 05 08:55:39 2016 -0700
    11.3 @@ -1,5 +1,5 @@
    11.4  /*
    11.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    11.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    11.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.8   *
    11.9   * This code is free software; you can redistribute it and/or modify it
   11.10 @@ -105,6 +105,8 @@
   11.11    void dispatch_via (TosState state, address* table);
   11.12  
   11.13  
   11.14 +  void narrow(Register result);
   11.15 +
   11.16    // Removes the current activation (incl. unlocking of monitors).
   11.17    // Additionally this code is used for earlyReturn in which case we
   11.18    // want to skip throwing an exception and installing an exception.
    12.1 --- a/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Tue Mar 29 23:01:10 2016 +0100
    12.2 +++ b/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Tue Apr 05 08:55:39 2016 -0700
    12.3 @@ -1,5 +1,5 @@
    12.4  /*
    12.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    12.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    12.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.8   *
    12.9   * This code is free software; you can redistribute it and/or modify it
   12.10 @@ -711,6 +711,9 @@
   12.11      __ cmp(G1_scratch, btos);
   12.12      __ br(Assembler::equal, true, Assembler::pt, xreturn_path);
   12.13      __ delayed()->ldsb(Otos_i, G3_scratch, Otos_i);
   12.14 +    __ cmp(G1_scratch, ztos);
   12.15 +    __ br(Assembler::equal, true, Assembler::pt, xreturn_path);
   12.16 +    __ delayed()->ldsb(Otos_i, G3_scratch, Otos_i);
   12.17      __ should_not_reach_here();
   12.18  #endif
   12.19      __ ldsb(Otos_i, G3_scratch, Otos_i);
    13.1 --- a/src/cpu/sparc/vm/templateTable_sparc.cpp	Tue Mar 29 23:01:10 2016 +0100
    13.2 +++ b/src/cpu/sparc/vm/templateTable_sparc.cpp	Tue Apr 05 08:55:39 2016 -0700
    13.3 @@ -1,5 +1,5 @@
    13.4  /*
    13.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    13.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    13.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.8   *
    13.9   * This code is free software; you can redistribute it and/or modify it
   13.10 @@ -167,6 +167,7 @@
   13.11    switch (bc) {
   13.12    case Bytecodes::_fast_aputfield:
   13.13    case Bytecodes::_fast_bputfield:
   13.14 +  case Bytecodes::_fast_zputfield:
   13.15    case Bytecodes::_fast_cputfield:
   13.16    case Bytecodes::_fast_dputfield:
   13.17    case Bytecodes::_fast_fputfield:
   13.18 @@ -913,8 +914,20 @@
   13.19    transition(itos, vtos);
   13.20    __ pop_i(O2); // index
   13.21    // Otos_i: val
   13.22 +  // O2: index
   13.23    // O3: array
   13.24    __ index_check(O3, O2, 0, G3_scratch, O2);
   13.25 +  // Need to check whether array is boolean or byte
   13.26 +  // since both types share the bastore bytecode.
   13.27 +  __ load_klass(O3, G4_scratch);
   13.28 +  __ ld(G4_scratch, in_bytes(Klass::layout_helper_offset()), G4_scratch);
   13.29 +  __ set(Klass::layout_helper_boolean_diffbit(), G3_scratch);
   13.30 +  __ andcc(G3_scratch, G4_scratch, G0);
   13.31 +  Label L_skip;
   13.32 +  __ br(Assembler::zero, false, Assembler::pn, L_skip);
   13.33 +  __ delayed()->nop();
   13.34 +  __ and3(Otos_i, 1, Otos_i);  // if it is a T_BOOLEAN array, mask the stored value to 0/1
   13.35 +  __ bind(L_skip);
   13.36    __ stb(Otos_i, O2, arrayOopDesc::base_offset_in_bytes(T_BYTE));
   13.37  }
   13.38  
   13.39 @@ -1997,6 +2010,12 @@
   13.40      __ bind(skip_register_finalizer);
   13.41    }
   13.42  
   13.43 +  // Narrow result if state is itos but result type is smaller.
   13.44 +  // Need to narrow in the return bytecode rather than in generate_return_entry
   13.45 +  // since compiled code callers expect the result to already be narrowed.
   13.46 +  if (state == itos) {
   13.47 +    __ narrow(Otos_i);
   13.48 +  }
   13.49    __ remove_activation(state, /* throw_monitor_exception */ true);
   13.50  
   13.51    // The caller's SP was adjusted upon method entry to accomodate
   13.52 @@ -2216,7 +2235,7 @@
   13.53    Label checkVolatile;
   13.54  
   13.55    // compute field type
   13.56 -  Label notByte, notInt, notShort, notChar, notLong, notFloat, notObj;
   13.57 +  Label notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj;
   13.58    __ srl(Rflags, ConstantPoolCacheEntry::tos_state_shift, Rflags);
   13.59    // Make sure we don't need to mask Rflags after the above shift
   13.60    ConstantPoolCacheEntry::verify_tos_state_shift();
   13.61 @@ -2271,7 +2290,7 @@
   13.62  
   13.63    // cmp(Rflags, btos);
   13.64    __ br(Assembler::notEqual, false, Assembler::pt, notByte);
   13.65 -  __ delayed() ->cmp(Rflags, ctos);
   13.66 +  __ delayed() ->cmp(Rflags, ztos);
   13.67  
   13.68    // btos
   13.69    __ ldsb(Rclass, Roffset, Otos_i);
   13.70 @@ -2284,6 +2303,22 @@
   13.71  
   13.72    __ bind(notByte);
   13.73  
   13.74 +  // cmp(Rflags, ztos);
   13.75 +  __ br(Assembler::notEqual, false, Assembler::pt, notBool);
   13.76 +  __ delayed() ->cmp(Rflags, ctos);
   13.77 +
   13.78 +  // ztos
   13.79 +  __ ldsb(Rclass, Roffset, Otos_i);
   13.80 +  __ push(itos);
   13.81 +  if (!is_static) {
   13.82 +    // use btos rewriting, no truncating to t/f bit is needed for getfield.
   13.83 +    patch_bytecode(Bytecodes::_fast_bgetfield, G3_scratch, G4_scratch);
   13.84 +  }
   13.85 +  __ ba(checkVolatile);
   13.86 +  __ delayed()->tst(Lscratch);
   13.87 +
   13.88 +  __ bind(notBool);
   13.89 +
   13.90    // cmp(Rflags, ctos);
   13.91    __ br(Assembler::notEqual, false, Assembler::pt, notChar);
   13.92    __ delayed() ->cmp(Rflags, stos);
   13.93 @@ -2445,6 +2480,7 @@
   13.94      switch (bytecode()) {  // save tos values before call_VM() clobbers them
   13.95      case Bytecodes::_fast_aputfield: __ push_ptr(Otos_i); break;
   13.96      case Bytecodes::_fast_bputfield: // fall through
   13.97 +    case Bytecodes::_fast_zputfield: // fall through
   13.98      case Bytecodes::_fast_sputfield: // fall through
   13.99      case Bytecodes::_fast_cputfield: // fall through
  13.100      case Bytecodes::_fast_iputfield: __ push_i(Otos_i); break;
  13.101 @@ -2462,6 +2498,7 @@
  13.102      switch (bytecode()) {             // restore tos values
  13.103      case Bytecodes::_fast_aputfield: __ pop_ptr(Otos_i); break;
  13.104      case Bytecodes::_fast_bputfield: // fall through
  13.105 +    case Bytecodes::_fast_zputfield: // fall through
  13.106      case Bytecodes::_fast_sputfield: // fall through
  13.107      case Bytecodes::_fast_cputfield: // fall through
  13.108      case Bytecodes::_fast_iputfield: __ pop_i(Otos_i); break;
  13.109 @@ -2577,7 +2614,7 @@
  13.110    ConstantPoolCacheEntry::verify_tos_state_shift();
  13.111  
  13.112    // compute field type
  13.113 -  Label notInt, notShort, notChar, notObj, notByte, notLong, notFloat;
  13.114 +  Label notInt, notShort, notChar, notObj, notByte, notBool, notLong, notFloat;
  13.115  
  13.116    if (is_static) {
  13.117      // putstatic with object type most likely, check that first
  13.118 @@ -2645,7 +2682,7 @@
  13.119  
  13.120    // cmp(Rflags, btos);
  13.121    __ br(Assembler::notEqual, false, Assembler::pt, notByte);
  13.122 -  __ delayed()->cmp(Rflags, ltos);
  13.123 +  __ delayed()->cmp(Rflags, ztos);
  13.124  
  13.125    // btos
  13.126    {
  13.127 @@ -2660,6 +2697,25 @@
  13.128    }
  13.129  
  13.130    __ bind(notByte);
  13.131 +
  13.132 +  // cmp(Rflags, btos);
  13.133 +  __ br(Assembler::notEqual, false, Assembler::pt, notBool);
  13.134 +  __ delayed()->cmp(Rflags, ltos);
  13.135 +
  13.136 +  // ztos
  13.137 +  {
  13.138 +    __ pop_i();
  13.139 +    if (!is_static) pop_and_check_object(Rclass);
  13.140 +    __ and3(Otos_i, 1, Otos_i);
  13.141 +    __ stb(Otos_i, Rclass, Roffset);
  13.142 +    if (!is_static) {
  13.143 +      patch_bytecode(Bytecodes::_fast_zputfield, G3_scratch, G4_scratch, true, byte_no);
  13.144 +    }
  13.145 +    __ ba(checkVolatile);
  13.146 +    __ delayed()->tst(Lscratch);
  13.147 +  }
  13.148 +
  13.149 +  __ bind(notBool);
  13.150    // cmp(Rflags, ltos);
  13.151    __ br(Assembler::notEqual, false, Assembler::pt, notLong);
  13.152    __ delayed()->cmp(Rflags, ctos);
  13.153 @@ -2783,6 +2839,7 @@
  13.154    pop_and_check_object(Rclass);
  13.155  
  13.156    switch (bytecode()) {
  13.157 +    case Bytecodes::_fast_zputfield: __ and3(Otos_i, 1, Otos_i);  // fall through to bputfield
  13.158      case Bytecodes::_fast_bputfield: __ stb(Otos_i, Rclass, Roffset); break;
  13.159      case Bytecodes::_fast_cputfield: /* fall through */
  13.160      case Bytecodes::_fast_sputfield: __ sth(Otos_i, Rclass, Roffset); break;
    14.1 --- a/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Tue Mar 29 23:01:10 2016 +0100
    14.2 +++ b/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Tue Apr 05 08:55:39 2016 -0700
    14.3 @@ -1,5 +1,5 @@
    14.4  /*
    14.5 - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
    14.6 + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
    14.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.8   *
    14.9   * This code is free software; you can redistribute it and/or modify it
   14.10 @@ -283,7 +283,7 @@
   14.11      length.load_item();
   14.12  
   14.13    }
   14.14 -  if (needs_store_check) {
   14.15 +  if (needs_store_check || x->check_boolean()) {
   14.16      value.load_item();
   14.17    } else {
   14.18      value.load_for_store(x->elt_type());
   14.19 @@ -331,7 +331,8 @@
   14.20      // Seems to be a precise
   14.21      post_barrier(LIR_OprFact::address(array_addr), value.result());
   14.22    } else {
   14.23 -    __ move(value.result(), array_addr, null_check_info);
   14.24 +    LIR_Opr result = maybe_mask_boolean(x, array.result(), value.result(), null_check_info);
   14.25 +    __ move(result, array_addr, null_check_info);
   14.26    }
   14.27  }
   14.28  
    15.1 --- a/src/cpu/x86/vm/cppInterpreter_x86.cpp	Tue Mar 29 23:01:10 2016 +0100
    15.2 +++ b/src/cpu/x86/vm/cppInterpreter_x86.cpp	Tue Apr 05 08:55:39 2016 -0700
    15.3 @@ -1,5 +1,5 @@
    15.4  /*
    15.5 - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
    15.6 + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
    15.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.8   *
    15.9   * This code is free software; you can redistribute it and/or modify it
   15.10 @@ -870,7 +870,7 @@
   15.11                      rdx,
   15.12                      Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()));
   15.13  
   15.14 -    Label notByte, notShort, notChar;
   15.15 +    Label notByte, notBool, notShort, notChar;
   15.16      const Address field_address (rax, rcx, Address::times_1);
   15.17  
   15.18      // Need to differentiate between igetfield, agetfield, bgetfield etc.
   15.19 @@ -889,6 +889,11 @@
   15.20  
   15.21      __ bind(notObj);
   15.22  #endif // _LP64
   15.23 +    __ cmpl(rdx, ztos);
   15.24 +    __ jcc(Assembler::notEqual, notBool);
   15.25 +    __ load_signed_byte(rax, field_address);
   15.26 +    __ jmp(xreturn_path);
   15.27 +
   15.28      __ cmpl(rdx, btos);
   15.29      __ jcc(Assembler::notEqual, notByte);
   15.30      __ load_signed_byte(rax, field_address);
    16.1 --- a/src/cpu/x86/vm/interp_masm_x86.cpp	Tue Mar 29 23:01:10 2016 +0100
    16.2 +++ b/src/cpu/x86/vm/interp_masm_x86.cpp	Tue Apr 05 08:55:39 2016 -0700
    16.3 @@ -1,5 +1,5 @@
    16.4  /*
    16.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    16.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    16.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.8   *
    16.9   * This code is free software; you can redistribute it and/or modify it
   16.10 @@ -27,6 +27,54 @@
   16.11  #include "interpreter/interpreter.hpp"
   16.12  #include "oops/methodData.hpp"
   16.13  
   16.14 +
   16.15 +// 8u does not have InterpreterMacroAssembler::load_earlyret_value here
   16.16 +
   16.17 +void InterpreterMacroAssembler::narrow(Register result) {
   16.18 +
   16.19 +  // Get method->_constMethod->_result_type
   16.20 +  movptr(rcx, Address(rbp, frame::interpreter_frame_method_offset * wordSize));
   16.21 +  movptr(rcx, Address(rcx, Method::const_offset()));
   16.22 +  load_unsigned_byte(rcx, Address(rcx, ConstMethod::result_type_offset()));
   16.23 +
   16.24 +  Label done, notBool, notByte, notChar;
   16.25 +
   16.26 +  // common case first
   16.27 +  cmpl(rcx, T_INT);
   16.28 +  jcc(Assembler::equal, done);
   16.29 +
   16.30 +  // mask integer result to narrower return type.
   16.31 +  cmpl(rcx, T_BOOLEAN);
   16.32 +  jcc(Assembler::notEqual, notBool);
   16.33 +  andl(result, 0x1);
   16.34 +  jmp(done);
   16.35 +
   16.36 +  bind(notBool);
   16.37 +  cmpl(rcx, T_BYTE);
   16.38 +  jcc(Assembler::notEqual, notByte);
   16.39 +  LP64_ONLY(movsbl(result, result);)
   16.40 +  NOT_LP64(shll(result, 24);)      // truncate upper 24 bits
   16.41 +  NOT_LP64(sarl(result, 24);)      // and sign-extend byte
   16.42 +  jmp(done);
   16.43 +
   16.44 +  bind(notByte);
   16.45 +  cmpl(rcx, T_CHAR);
   16.46 +  jcc(Assembler::notEqual, notChar);
   16.47 +  LP64_ONLY(movzwl(result, result);)
   16.48 +  NOT_LP64(andl(result, 0xFFFF);)  // truncate upper 16 bits
   16.49 +  jmp(done);
   16.50 +
   16.51 +  bind(notChar);
   16.52 +  // cmpl(rcx, T_SHORT);  // all that's left
   16.53 +  // jcc(Assembler::notEqual, done);
   16.54 +  LP64_ONLY(movswl(result, result);)
   16.55 +  NOT_LP64(shll(result, 16);)      // truncate upper 16 bits
   16.56 +  NOT_LP64(sarl(result, 16);)      // and sign-extend short
   16.57 +
   16.58 +  // Nothing to do for T_INT
   16.59 +  bind(done);
   16.60 +}
   16.61 +
   16.62  #ifndef CC_INTERP
   16.63  void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) {
   16.64    Label update, next, none;
    17.1 --- a/src/cpu/x86/vm/interp_masm_x86.hpp	Tue Mar 29 23:01:10 2016 +0100
    17.2 +++ b/src/cpu/x86/vm/interp_masm_x86.hpp	Tue Apr 05 08:55:39 2016 -0700
    17.3 @@ -1,5 +1,5 @@
    17.4  /*
    17.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    17.6 + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
    17.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.8   *
    17.9   * This code is free software; you can redistribute it and/or modify it
   17.10 @@ -48,6 +48,9 @@
   17.11    Register _bcp_register; // register that contains the bcp
   17.12  
   17.13   public:
   17.14 +  // narrow int return value
   17.15 +  void narrow(Register result);
   17.16 +
   17.17  #ifndef CC_INTERP
   17.18    void profile_obj_type(Register obj, const Address& mdo_addr);
   17.19    void profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual);
    18.1 --- a/src/cpu/x86/vm/interp_masm_x86_32.cpp	Tue Mar 29 23:01:10 2016 +0100
    18.2 +++ b/src/cpu/x86/vm/interp_masm_x86_32.cpp	Tue Apr 05 08:55:39 2016 -0700
    18.3 @@ -1,5 +1,5 @@
    18.4  /*
    18.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    18.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    18.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.8   *
    18.9   * This code is free software; you can redistribute it and/or modify it
   18.10 @@ -151,6 +151,7 @@
   18.11      case ltos:
   18.12                 movl(rdx, val_addr1);               // fall through
   18.13      case btos:                                     // fall through
   18.14 +    case ztos:                                     // fall through
   18.15      case ctos:                                     // fall through
   18.16      case stos:                                     // fall through
   18.17      case itos: movl(rax, val_addr);                   break;
   18.18 @@ -362,6 +363,7 @@
   18.19    switch (state) {
   18.20      case atos: pop_ptr(rax);                                 break;
   18.21      case btos:                                               // fall through
   18.22 +    case ztos:                                               // fall through
   18.23      case ctos:                                               // fall through
   18.24      case stos:                                               // fall through
   18.25      case itos: pop_i(rax);                                   break;
   18.26 @@ -405,6 +407,7 @@
   18.27    switch (state) {
   18.28      case atos: push_ptr(rax); break;
   18.29      case btos:                                               // fall through
   18.30 +    case ztos:                                               // fall through
   18.31      case ctos:                                               // fall through
   18.32      case stos:                                               // fall through
   18.33      case itos: push_i(rax);                                    break;
    19.1 --- a/src/cpu/x86/vm/interp_masm_x86_64.cpp	Tue Mar 29 23:01:10 2016 +0100
    19.2 +++ b/src/cpu/x86/vm/interp_masm_x86_64.cpp	Tue Apr 05 08:55:39 2016 -0700
    19.3 @@ -1,5 +1,5 @@
    19.4  /*
    19.5 - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
    19.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    19.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.8   *
    19.9   * This code is free software; you can redistribute it and/or modify it
   19.10 @@ -149,6 +149,7 @@
   19.11                 verify_oop(rax, state);              break;
   19.12      case ltos: movptr(rax, val_addr);                 break;
   19.13      case btos:                                   // fall through
   19.14 +    case ztos:                                   // fall through
   19.15      case ctos:                                   // fall through
   19.16      case stos:                                   // fall through
   19.17      case itos: movl(rax, val_addr);                 break;
   19.18 @@ -387,6 +388,7 @@
   19.19    switch (state) {
   19.20    case atos: pop_ptr();                 break;
   19.21    case btos:
   19.22 +  case ztos:
   19.23    case ctos:
   19.24    case stos:
   19.25    case itos: pop_i();                   break;
   19.26 @@ -404,6 +406,7 @@
   19.27    switch (state) {
   19.28    case atos: push_ptr();                break;
   19.29    case btos:
   19.30 +  case ztos:
   19.31    case ctos:
   19.32    case stos:
   19.33    case itos: push_i();                  break;
    20.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Tue Mar 29 23:01:10 2016 +0100
    20.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Tue Apr 05 08:55:39 2016 -0700
    20.3 @@ -1,5 +1,5 @@
    20.4  /*
    20.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    20.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    20.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.8   *
    20.9   * This code is free software; you can redistribute it and/or modify it
   20.10 @@ -713,7 +713,7 @@
   20.11                      rdx,
   20.12                      Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()));
   20.13  
   20.14 -    Label notByte, notShort, notChar;
   20.15 +    Label notByte, notBool, notShort, notChar;
   20.16      const Address field_address (rax, rcx, Address::times_1);
   20.17  
   20.18      // Need to differentiate between igetfield, agetfield, bgetfield etc.
   20.19 @@ -728,6 +728,12 @@
   20.20      __ jmp(xreturn_path);
   20.21  
   20.22      __ bind(notByte);
   20.23 +    __ cmpl(rdx, ztos);
   20.24 +    __ jcc(Assembler::notEqual, notBool);
   20.25 +    __ load_signed_byte(rax, field_address);
   20.26 +    __ jmp(xreturn_path);
   20.27 +
   20.28 +    __ bind(notBool);
   20.29      __ cmpl(rdx, stos);
   20.30      __ jcc(Assembler::notEqual, notShort);
   20.31      __ load_signed_short(rax, field_address);
    21.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Tue Mar 29 23:01:10 2016 +0100
    21.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Tue Apr 05 08:55:39 2016 -0700
    21.3 @@ -1,5 +1,5 @@
    21.4  /*
    21.5 - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
    21.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    21.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.8   *
    21.9   * This code is free software; you can redistribute it and/or modify it
   21.10 @@ -680,7 +680,7 @@
   21.11                      ConstantPoolCache::base_offset() +
   21.12                      ConstantPoolCacheEntry::flags_offset()));
   21.13  
   21.14 -    Label notObj, notInt, notByte, notShort;
   21.15 +    Label notObj, notInt, notByte, notBool, notShort;
   21.16      const Address field_address(rax, rcx, Address::times_1);
   21.17  
   21.18      // Need to differentiate between igetfield, agetfield, bgetfield etc.
   21.19 @@ -711,6 +711,13 @@
   21.20      __ jmp(xreturn_path);
   21.21  
   21.22      __ bind(notByte);
   21.23 +    __ cmpl(rdx, ztos);
   21.24 +    __ jcc(Assembler::notEqual, notBool);
   21.25 +    // ztos
   21.26 +    __ load_signed_byte(rax, field_address);
   21.27 +    __ jmp(xreturn_path);
   21.28 +
   21.29 +    __ bind(notBool);
   21.30      __ cmpl(rdx, stos);
   21.31      __ jcc(Assembler::notEqual, notShort);
   21.32      // stos
    22.1 --- a/src/cpu/x86/vm/templateTable_x86_32.cpp	Tue Mar 29 23:01:10 2016 +0100
    22.2 +++ b/src/cpu/x86/vm/templateTable_x86_32.cpp	Tue Apr 05 08:55:39 2016 -0700
    22.3 @@ -1,5 +1,5 @@
    22.4  /*
    22.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    22.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    22.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.8   *
    22.9   * This code is free software; you can redistribute it and/or modify it
   22.10 @@ -212,6 +212,7 @@
   22.11    switch (bc) {
   22.12    case Bytecodes::_fast_aputfield:
   22.13    case Bytecodes::_fast_bputfield:
   22.14 +  case Bytecodes::_fast_zputfield:
   22.15    case Bytecodes::_fast_cputfield:
   22.16    case Bytecodes::_fast_dputfield:
   22.17    case Bytecodes::_fast_fputfield:
   22.18 @@ -988,11 +989,21 @@
   22.19  void TemplateTable::bastore() {
   22.20    transition(itos, vtos);
   22.21    __ pop_i(rbx);
   22.22 -  // rax,: value
   22.23 +  // rax: value
   22.24 +  // rbx: index
   22.25    // rdx: array
   22.26 -  index_check(rdx, rbx);  // prefer index in rbx,
   22.27 -  // rbx,: index
   22.28 -  __ movb(Address(rdx, rbx, Address::times_1, arrayOopDesc::base_offset_in_bytes(T_BYTE)), rax);
   22.29 +  index_check(rdx, rbx);  // prefer index in rbx
   22.30 +  // Need to check whether array is boolean or byte
   22.31 +  // since both types share the bastore bytecode.
   22.32 +  __ load_klass(rcx, rdx);
   22.33 +  __ movl(rcx, Address(rcx, Klass::layout_helper_offset()));
   22.34 +  int diffbit = Klass::layout_helper_boolean_diffbit();
   22.35 +  __ testl(rcx, diffbit);
   22.36 +  Label L_skip;
   22.37 +  __ jccb(Assembler::zero, L_skip);
   22.38 +  __ andl(rax, 1);  // if it is a T_BOOLEAN array, mask the stored value to 0/1
   22.39 +  __ bind(L_skip);
   22.40 + __ movb(Address(rdx, rbx, Address::times_1, arrayOopDesc::base_offset_in_bytes(T_BYTE)), rax);
   22.41  }
   22.42  
   22.43  
   22.44 @@ -2037,7 +2048,14 @@
   22.45      __ bind(skip_register_finalizer);
   22.46    }
   22.47  
   22.48 +  // Narrow result if state is itos but result type is smaller.
   22.49 +  // Need to narrow in the return bytecode rather than in generate_return_entry
   22.50 +  // since compiled code callers expect the result to already be narrowed.
   22.51 +  if (state == itos) {
   22.52 +    __ narrow(rax);
   22.53 +  }
   22.54    __ remove_activation(state, rsi);
   22.55 +
   22.56    __ jmp(rsi);
   22.57  }
   22.58  
   22.59 @@ -2234,7 +2252,7 @@
   22.60    const Address lo(obj, off, Address::times_1, 0*wordSize);
   22.61    const Address hi(obj, off, Address::times_1, 1*wordSize);
   22.62  
   22.63 -  Label Done, notByte, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble;
   22.64 +  Label Done, notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble;
   22.65  
   22.66    __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift);
   22.67    assert(btos == 0, "change code, btos != 0");
   22.68 @@ -2251,6 +2269,22 @@
   22.69    __ jmp(Done);
   22.70  
   22.71    __ bind(notByte);
   22.72 +
   22.73 +  __ cmpl(flags, ztos);
   22.74 +  __ jcc(Assembler::notEqual, notBool);
   22.75 +
   22.76 +  // ztos (same code as btos)
   22.77 +  __ load_signed_byte(rax, lo);
   22.78 +  __ push(ztos);
   22.79 +  // Rewrite bytecode to be faster
   22.80 +  if (!is_static) {
   22.81 +    // use btos rewriting, no truncating to t/f bit is needed for getfield.
   22.82 +    patch_bytecode(Bytecodes::_fast_bgetfield, rcx, rbx);
   22.83 +  }
   22.84 +  __ jmp(Done);
   22.85 +
   22.86 +  __ bind(notBool);
   22.87 +
   22.88    // itos
   22.89    __ cmpl(flags, itos );
   22.90    __ jcc(Assembler::notEqual, notInt);
   22.91 @@ -2450,7 +2484,7 @@
   22.92    const Address lo(obj, off, Address::times_1, 0*wordSize);
   22.93    const Address hi(obj, off, Address::times_1, 1*wordSize);
   22.94  
   22.95 -  Label notByte, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble;
   22.96 +  Label notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble;
   22.97  
   22.98    __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift);
   22.99    assert(btos == 0, "change code, btos != 0");
  22.100 @@ -2469,6 +2503,22 @@
  22.101    }
  22.102  
  22.103    __ bind(notByte);
  22.104 +  __ cmpl(flags, ztos);
  22.105 +  __ jcc(Assembler::notEqual, notBool);
  22.106 +
  22.107 +  // ztos
  22.108 +  {
  22.109 +    __ pop(ztos);
  22.110 +    if (!is_static) pop_and_check_object(obj);
  22.111 +    __ andl(rax, 0x1);
  22.112 +    __ movb(lo, rax);
  22.113 +    if (!is_static) {
  22.114 +      patch_bytecode(Bytecodes::_fast_zputfield, rcx, rbx, true, byte_no);
  22.115 +    }
  22.116 +    __ jmp(Done);
  22.117 +  }
  22.118 +
  22.119 +  __ bind(notBool);
  22.120    __ cmpl(flags, itos);
  22.121    __ jcc(Assembler::notEqual, notInt);
  22.122  
  22.123 @@ -2640,6 +2690,7 @@
  22.124       switch (bytecode()) {          // load values into the jvalue object
  22.125       case Bytecodes::_fast_aputfield: __ push_ptr(rax); break;
  22.126       case Bytecodes::_fast_bputfield: // fall through
  22.127 +     case Bytecodes::_fast_zputfield: // fall through
  22.128       case Bytecodes::_fast_sputfield: // fall through
  22.129       case Bytecodes::_fast_cputfield: // fall through
  22.130       case Bytecodes::_fast_iputfield: __ push_i(rax); break;
  22.131 @@ -2662,6 +2713,7 @@
  22.132       switch (bytecode()) {             // restore tos values
  22.133       case Bytecodes::_fast_aputfield: __ pop_ptr(rax); break;
  22.134       case Bytecodes::_fast_bputfield: // fall through
  22.135 +     case Bytecodes::_fast_zputfield: // fall through
  22.136       case Bytecodes::_fast_sputfield: // fall through
  22.137       case Bytecodes::_fast_cputfield: // fall through
  22.138       case Bytecodes::_fast_iputfield: __ pop_i(rax); break;
  22.139 @@ -2712,6 +2764,8 @@
  22.140  
  22.141    // access field
  22.142    switch (bytecode()) {
  22.143 +    case Bytecodes::_fast_zputfield: __ andl(rax, 0x1);  // boolean is true if LSB is 1
  22.144 +    // fall through to bputfield
  22.145      case Bytecodes::_fast_bputfield: __ movb(lo, rax); break;
  22.146      case Bytecodes::_fast_sputfield: // fall through
  22.147      case Bytecodes::_fast_cputfield: __ movw(lo, rax); break;
  22.148 @@ -2746,6 +2800,8 @@
  22.149  
  22.150    // access field
  22.151    switch (bytecode()) {
  22.152 +    case Bytecodes::_fast_zputfield: __ andl(rax, 0x1);  // boolean is true if LSB is 1
  22.153 +    // fall through to bputfield
  22.154      case Bytecodes::_fast_bputfield: __ movb(lo, rax); break;
  22.155      case Bytecodes::_fast_sputfield: // fall through
  22.156      case Bytecodes::_fast_cputfield: __ movw(lo, rax); break;
    23.1 --- a/src/cpu/x86/vm/templateTable_x86_64.cpp	Tue Mar 29 23:01:10 2016 +0100
    23.2 +++ b/src/cpu/x86/vm/templateTable_x86_64.cpp	Tue Apr 05 08:55:39 2016 -0700
    23.3 @@ -1,5 +1,5 @@
    23.4  /*
    23.5 - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
    23.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    23.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.8   *
    23.9   * This code is free software; you can redistribute it and/or modify it
   23.10 @@ -219,6 +219,7 @@
   23.11    switch (bc) {
   23.12    case Bytecodes::_fast_aputfield:
   23.13    case Bytecodes::_fast_bputfield:
   23.14 +  case Bytecodes::_fast_zputfield:
   23.15    case Bytecodes::_fast_cputfield:
   23.16    case Bytecodes::_fast_dputfield:
   23.17    case Bytecodes::_fast_fputfield:
   23.18 @@ -1018,6 +1019,16 @@
   23.19    // ebx: index
   23.20    // rdx: array
   23.21    index_check(rdx, rbx); // prefer index in ebx
   23.22 +  // Need to check whether array is boolean or byte
   23.23 +  // since both types share the bastore bytecode.
   23.24 +  __ load_klass(rcx, rdx);
   23.25 +  __ movl(rcx, Address(rcx, Klass::layout_helper_offset()));
   23.26 +  int diffbit = Klass::layout_helper_boolean_diffbit();
   23.27 +  __ testl(rcx, diffbit);
   23.28 +  Label L_skip;
   23.29 +  __ jccb(Assembler::zero, L_skip);
   23.30 +  __ andl(rax, 1);  // if it is a T_BOOLEAN array, mask the stored value to 0/1
   23.31 +  __ bind(L_skip);
   23.32    __ movb(Address(rdx, rbx,
   23.33                    Address::times_1,
   23.34                    arrayOopDesc::base_offset_in_bytes(T_BYTE)),
   23.35 @@ -2071,7 +2082,14 @@
   23.36      __ bind(skip_register_finalizer);
   23.37    }
   23.38  
   23.39 +  // Narrow result if state is itos but result type is smaller.
   23.40 +  // Need to narrow in the return bytecode rather than in generate_return_entry
   23.41 +  // since compiled code callers expect the result to already be narrowed.
   23.42 +  if (state == itos) {
   23.43 +    __ narrow(rax);
   23.44 +  }
   23.45    __ remove_activation(state, r13);
   23.46 +
   23.47    __ jmp(r13);
   23.48  }
   23.49  
   23.50 @@ -2289,7 +2307,7 @@
   23.51  
   23.52    const Address field(obj, off, Address::times_1);
   23.53  
   23.54 -  Label Done, notByte, notInt, notShort, notChar,
   23.55 +  Label Done, notByte, notBool, notInt, notShort, notChar,
   23.56                notLong, notFloat, notObj, notDouble;
   23.57  
   23.58    __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift);
   23.59 @@ -2308,6 +2326,20 @@
   23.60    __ jmp(Done);
   23.61  
   23.62    __ bind(notByte);
   23.63 +  __ cmpl(flags, ztos);
   23.64 +  __ jcc(Assembler::notEqual, notBool);
   23.65 +
   23.66 +  // ztos (same code as btos)
   23.67 +  __ load_signed_byte(rax, field);
   23.68 +  __ push(ztos);
   23.69 +  // Rewrite bytecode to be faster
   23.70 +  if (!is_static) {
   23.71 +    // use btos rewriting, no truncating to t/f bit is needed for getfield.
   23.72 +    patch_bytecode(Bytecodes::_fast_bgetfield, bc, rbx);
   23.73 +  }
   23.74 +  __ jmp(Done);
   23.75 +
   23.76 +  __ bind(notBool);
   23.77    __ cmpl(flags, atos);
   23.78    __ jcc(Assembler::notEqual, notObj);
   23.79    // atos
   23.80 @@ -2497,7 +2529,7 @@
   23.81    // field address
   23.82    const Address field(obj, off, Address::times_1);
   23.83  
   23.84 -  Label notByte, notInt, notShort, notChar,
   23.85 +  Label notByte, notBool, notInt, notShort, notChar,
   23.86          notLong, notFloat, notObj, notDouble;
   23.87  
   23.88    __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift);
   23.89 @@ -2518,6 +2550,22 @@
   23.90    }
   23.91  
   23.92    __ bind(notByte);
   23.93 +  __ cmpl(flags, ztos);
   23.94 +  __ jcc(Assembler::notEqual, notBool);
   23.95 +
   23.96 +  // ztos
   23.97 +  {
   23.98 +    __ pop(ztos);
   23.99 +    if (!is_static) pop_and_check_object(obj);
  23.100 +    __ andl(rax, 0x1);
  23.101 +    __ movb(field, rax);
  23.102 +    if (!is_static) {
  23.103 +      patch_bytecode(Bytecodes::_fast_zputfield, bc, rbx, true, byte_no);
  23.104 +    }
  23.105 +    __ jmp(Done);
  23.106 +  }
  23.107 +
  23.108 +  __ bind(notBool);
  23.109    __ cmpl(flags, atos);
  23.110    __ jcc(Assembler::notEqual, notObj);
  23.111  
  23.112 @@ -2666,6 +2714,7 @@
  23.113      switch (bytecode()) {          // load values into the jvalue object
  23.114      case Bytecodes::_fast_aputfield: __ push_ptr(rax); break;
  23.115      case Bytecodes::_fast_bputfield: // fall through
  23.116 +    case Bytecodes::_fast_zputfield: // fall through
  23.117      case Bytecodes::_fast_sputfield: // fall through
  23.118      case Bytecodes::_fast_cputfield: // fall through
  23.119      case Bytecodes::_fast_iputfield: __ push_i(rax); break;
  23.120 @@ -2691,6 +2740,7 @@
  23.121      switch (bytecode()) {             // restore tos values
  23.122      case Bytecodes::_fast_aputfield: __ pop_ptr(rax); break;
  23.123      case Bytecodes::_fast_bputfield: // fall through
  23.124 +    case Bytecodes::_fast_zputfield: // fall through
  23.125      case Bytecodes::_fast_sputfield: // fall through
  23.126      case Bytecodes::_fast_cputfield: // fall through
  23.127      case Bytecodes::_fast_iputfield: __ pop_i(rax); break;
  23.128 @@ -2746,6 +2796,9 @@
  23.129    case Bytecodes::_fast_iputfield:
  23.130      __ movl(field, rax);
  23.131      break;
  23.132 +  case Bytecodes::_fast_zputfield:
  23.133 +    __ andl(rax, 0x1);  // boolean is true if LSB is 1
  23.134 +    // fall through to bputfield
  23.135    case Bytecodes::_fast_bputfield:
  23.136      __ movb(field, rax);
  23.137      break;
    24.1 --- a/src/cpu/zero/vm/cppInterpreter_zero.cpp	Tue Mar 29 23:01:10 2016 +0100
    24.2 +++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp	Tue Apr 05 08:55:39 2016 -0700
    24.3 @@ -1,5 +1,5 @@
    24.4  /*
    24.5 - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
    24.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    24.7   * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
    24.8   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.9   *
   24.10 @@ -81,6 +81,30 @@
   24.11    return 0;
   24.12  }
   24.13  
   24.14 +intptr_t narrow(BasicType type, intptr_t result) {
   24.15 +  // mask integer result to narrower return type.
   24.16 +  switch (type) {
   24.17 +    case T_BOOLEAN:
   24.18 +      return result&1;
   24.19 +    case T_BYTE:
   24.20 +      return (intptr_t)(jbyte)result;
   24.21 +    case T_CHAR:
   24.22 +      return (intptr_t)(uintptr_t)(jchar)result;
   24.23 +    case T_SHORT:
   24.24 +      return (intptr_t)(jshort)result;
   24.25 +    case T_OBJECT:  // nothing to do fall through
   24.26 +    case T_ARRAY:
   24.27 +    case T_LONG:
   24.28 +    case T_INT:
   24.29 +    case T_FLOAT:
   24.30 +    case T_DOUBLE:
   24.31 +    case T_VOID:
   24.32 +      return result;
   24.33 +    default  : ShouldNotReachHere();
   24.34 +  }
   24.35 +}
   24.36 +
   24.37 +
   24.38  void CppInterpreter::main_loop(int recurse, TRAPS) {
   24.39    JavaThread *thread = (JavaThread *) THREAD;
   24.40    ZeroStack *stack = thread->zero_stack();
   24.41 @@ -160,7 +184,7 @@
   24.42      }
   24.43      else if (istate->msg() == BytecodeInterpreter::return_from_method) {
   24.44        // Copy the result into the caller's frame
   24.45 -      result_slots = type2size[result_type_of(method)];
   24.46 +      result_slots = type2size[method->result_type()];
   24.47        assert(result_slots >= 0 && result_slots <= 2, "what?");
   24.48        result = istate->stack() + result_slots;
   24.49        break;
   24.50 @@ -194,8 +218,14 @@
   24.51    stack->set_sp(stack->sp() + method->max_locals());
   24.52  
   24.53    // Push our result
   24.54 -  for (int i = 0; i < result_slots; i++)
   24.55 -    stack->push(result[-i]);
   24.56 +  for (int i = 0; i < result_slots; i++) {
   24.57 +    // Adjust result to smaller
   24.58 +    intptr_t res = result[-i];
   24.59 +    if (result_slots == 1) {
   24.60 +      res = narrow(method->result_type(), res);
   24.61 +    }
   24.62 +    stack->push(res);
   24.63 +  }
   24.64  }
   24.65  
   24.66  int CppInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
   24.67 @@ -406,7 +436,7 @@
   24.68  
   24.69    // Push our result
   24.70    if (!HAS_PENDING_EXCEPTION) {
   24.71 -    BasicType type = result_type_of(method);
   24.72 +    BasicType type = method->result_type();
   24.73      stack->set_sp(stack->sp() - type2size[type]);
   24.74  
   24.75      switch (type) {
   24.76 @@ -528,6 +558,7 @@
   24.77        break;
   24.78  
   24.79      case btos:
   24.80 +    case ztos:
   24.81        SET_LOCALS_INT(object->byte_field_acquire(entry->f2_as_index()), 0);
   24.82        break;
   24.83  
   24.84 @@ -566,6 +597,7 @@
   24.85        break;
   24.86  
   24.87      case btos:
   24.88 +    case ztos:
   24.89        SET_LOCALS_INT(object->byte_field(entry->f2_as_index()), 0);
   24.90        break;
   24.91  
   24.92 @@ -764,26 +796,6 @@
   24.93    return i;
   24.94  }
   24.95  
   24.96 -BasicType CppInterpreter::result_type_of(Method* method) {
   24.97 -  BasicType t;
   24.98 -  switch (method->result_index()) {
   24.99 -    case 0 : t = T_BOOLEAN; break;
  24.100 -    case 1 : t = T_CHAR;    break;
  24.101 -    case 2 : t = T_BYTE;    break;
  24.102 -    case 3 : t = T_SHORT;   break;
  24.103 -    case 4 : t = T_INT;     break;
  24.104 -    case 5 : t = T_LONG;    break;
  24.105 -    case 6 : t = T_VOID;    break;
  24.106 -    case 7 : t = T_FLOAT;   break;
  24.107 -    case 8 : t = T_DOUBLE;  break;
  24.108 -    case 9 : t = T_OBJECT;  break;
  24.109 -    default: ShouldNotReachHere();
  24.110 -  }
  24.111 -  assert(AbstractInterpreter::BasicType_as_index(t) == method->result_index(),
  24.112 -         "out of step with AbstractInterpreter::BasicType_as_index");
  24.113 -  return t;
  24.114 -}
  24.115 -
  24.116  address InterpreterGenerator::generate_empty_entry() {
  24.117    if (!UseFastEmptyMethods)
  24.118      return NULL;
    25.1 --- a/src/cpu/zero/vm/cppInterpreter_zero.hpp	Tue Mar 29 23:01:10 2016 +0100
    25.2 +++ b/src/cpu/zero/vm/cppInterpreter_zero.hpp	Tue Apr 05 08:55:39 2016 -0700
    25.3 @@ -1,5 +1,5 @@
    25.4  /*
    25.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    25.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    25.7   * Copyright 2007, 2008, 2010, 2011 Red Hat, Inc.
    25.8   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.9   *
   25.10 @@ -49,8 +49,4 @@
   25.11    static intptr_t* calculate_unwind_sp(ZeroStack* stack, oop method_handle);
   25.12    static void throw_exception(JavaThread* thread, Symbol* name,char *msg=NULL);
   25.13  
   25.14 - private:
   25.15 -  // Fast result type determination
   25.16 -  static BasicType result_type_of(Method* method);
   25.17 -
   25.18  #endif // CPU_ZERO_VM_CPPINTERPRETER_ZERO_HPP
    26.1 --- a/src/share/vm/c1/c1_Canonicalizer.cpp	Tue Mar 29 23:01:10 2016 +0100
    26.2 +++ b/src/share/vm/c1/c1_Canonicalizer.cpp	Tue Apr 05 08:55:39 2016 -0700
    26.3 @@ -1,5 +1,5 @@
    26.4  /*
    26.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    26.6 + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
    26.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.8   *
    26.9   * This code is free software; you can redistribute it and/or modify it
   26.10 @@ -265,7 +265,8 @@
   26.11      // limit this optimization to current block
   26.12      if (value != NULL && in_current_block(conv)) {
   26.13        set_canonical(new StoreIndexed(x->array(), x->index(), x->length(),
   26.14 -                                     x->elt_type(), value, x->state_before()));
   26.15 +                                     x->elt_type(), value, x->state_before(),
   26.16 +                                     x->check_boolean()));
   26.17        return;
   26.18      }
   26.19    }
    27.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Mar 29 23:01:10 2016 +0100
    27.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Apr 05 08:55:39 2016 -0700
    27.3 @@ -1,5 +1,5 @@
    27.4  /*
    27.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    27.6 + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
    27.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    27.8   *
    27.9   * This code is free software; you can redistribute it and/or modify it
   27.10 @@ -975,7 +975,19 @@
   27.11        (array->as_NewArray() && array->as_NewArray()->length() && array->as_NewArray()->length()->type()->is_constant())) {
   27.12      length = append(new ArrayLength(array, state_before));
   27.13    }
   27.14 -  StoreIndexed* result = new StoreIndexed(array, index, length, type, value, state_before);
   27.15 +  ciType* array_type = array->declared_type();
   27.16 +  bool check_boolean = false;
   27.17 +  if (array_type != NULL) {
   27.18 +    if (array_type->is_loaded() &&
   27.19 +      array_type->as_array_klass()->element_type()->basic_type() == T_BOOLEAN) {
   27.20 +      assert(type == T_BYTE, "boolean store uses bastore");
   27.21 +      Value mask = append(new Constant(new IntConstant(1)));
   27.22 +      value = append(new LogicOp(Bytecodes::_iand, value, mask));
   27.23 +    }
   27.24 +  } else if (type == T_BYTE) {
   27.25 +    check_boolean = true;
   27.26 +  }
   27.27 +  StoreIndexed* result = new StoreIndexed(array, index, length, type, value, state_before, check_boolean);
   27.28    append(result);
   27.29    _memory->store_value(value);
   27.30  
   27.31 @@ -1440,6 +1452,36 @@
   27.32      need_mem_bar = true;
   27.33    }
   27.34  
   27.35 +  BasicType bt = method()->return_type()->basic_type();
   27.36 +  switch (bt) {
   27.37 +    case T_BYTE:
   27.38 +    {
   27.39 +      Value shift = append(new Constant(new IntConstant(24)));
   27.40 +      x = append(new ShiftOp(Bytecodes::_ishl, x, shift));
   27.41 +      x = append(new ShiftOp(Bytecodes::_ishr, x, shift));
   27.42 +      break;
   27.43 +    }
   27.44 +    case T_SHORT:
   27.45 +    {
   27.46 +      Value shift = append(new Constant(new IntConstant(16)));
   27.47 +      x = append(new ShiftOp(Bytecodes::_ishl, x, shift));
   27.48 +      x = append(new ShiftOp(Bytecodes::_ishr, x, shift));
   27.49 +      break;
   27.50 +    }
   27.51 +    case T_CHAR:
   27.52 +    {
   27.53 +      Value mask = append(new Constant(new IntConstant(0xFFFF)));
   27.54 +      x = append(new LogicOp(Bytecodes::_iand, x, mask));
   27.55 +      break;
   27.56 +    }
   27.57 +    case T_BOOLEAN:
   27.58 +    {
   27.59 +      Value mask = append(new Constant(new IntConstant(1)));
   27.60 +      x = append(new LogicOp(Bytecodes::_iand, x, mask));
   27.61 +      break;
   27.62 +    }
   27.63 +  }
   27.64 +
   27.65    // Check to see whether we are inlining. If so, Return
   27.66    // instructions become Gotos to the continuation point.
   27.67    if (continuation() != NULL) {
   27.68 @@ -1587,6 +1629,10 @@
   27.69          if (state_before == NULL) {
   27.70            state_before = copy_state_for_exception();
   27.71          }
   27.72 +        if (field->type()->basic_type() == T_BOOLEAN) {
   27.73 +          Value mask = append(new Constant(new IntConstant(1)));
   27.74 +          val = append(new LogicOp(Bytecodes::_iand, val, mask));
   27.75 +        }
   27.76          append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
   27.77        }
   27.78        break;
   27.79 @@ -1657,6 +1703,10 @@
   27.80        if (state_before == NULL) {
   27.81          state_before = copy_state_for_exception();
   27.82        }
   27.83 +      if (field->type()->basic_type() == T_BOOLEAN) {
   27.84 +        Value mask = append(new Constant(new IntConstant(1)));
   27.85 +        val = append(new LogicOp(Bytecodes::_iand, val, mask));
   27.86 +      }
   27.87        StoreField* store = new StoreField(obj, offset, field, val, false, state_before, needs_patching);
   27.88        if (!needs_patching) store = _memory->store(store);
   27.89        if (store != NULL) {
   27.90 @@ -4222,7 +4272,12 @@
   27.91  #ifndef _LP64
   27.92      offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT)));
   27.93  #endif
   27.94 -    Instruction* op = append(new UnsafePutObject(t, args->at(1), offset, args->at(3), is_volatile));
   27.95 +    Value val = args->at(3);
   27.96 +    if (t == T_BOOLEAN) {
   27.97 +      Value mask = append(new Constant(new IntConstant(1)));
   27.98 +      val = append(new LogicOp(Bytecodes::_iand, val, mask));
   27.99 +    }
  27.100 +    Instruction* op = append(new UnsafePutObject(t, args->at(1), offset, val, is_volatile));
  27.101      compilation()->set_has_unsafe_access(true);
  27.102      kill_all();
  27.103    }
    28.1 --- a/src/share/vm/c1/c1_Instruction.hpp	Tue Mar 29 23:01:10 2016 +0100
    28.2 +++ b/src/share/vm/c1/c1_Instruction.hpp	Tue Apr 05 08:55:39 2016 -0700
    28.3 @@ -1,5 +1,5 @@
    28.4  /*
    28.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    28.6 + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
    28.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.8   *
    28.9   * This code is free software; you can redistribute it and/or modify it
   28.10 @@ -976,11 +976,13 @@
   28.11  
   28.12    ciMethod* _profiled_method;
   28.13    int       _profiled_bci;
   28.14 +  bool      _check_boolean;
   28.15 +
   28.16   public:
   28.17    // creation
   28.18 -  StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before)
   28.19 +  StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before, bool check_boolean)
   28.20    : AccessIndexed(array, index, length, elt_type, state_before)
   28.21 -  , _value(value), _profiled_method(NULL), _profiled_bci(0)
   28.22 +  , _value(value), _profiled_method(NULL), _profiled_bci(0), _check_boolean(check_boolean)
   28.23    {
   28.24      set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object()));
   28.25      set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object()));
   28.26 @@ -992,6 +994,7 @@
   28.27    Value value() const                            { return _value; }
   28.28    bool needs_write_barrier() const               { return check_flag(NeedsWriteBarrierFlag); }
   28.29    bool needs_store_check() const                 { return check_flag(NeedsStoreCheckFlag); }
   28.30 +  bool check_boolean() const                     { return _check_boolean; }
   28.31    // Helpers for MethodData* profiling
   28.32    void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
   28.33    void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
    29.1 --- a/src/share/vm/c1/c1_LIRGenerator.cpp	Tue Mar 29 23:01:10 2016 +0100
    29.2 +++ b/src/share/vm/c1/c1_LIRGenerator.cpp	Tue Apr 05 08:55:39 2016 -0700
    29.3 @@ -1,5 +1,5 @@
    29.4  /*
    29.5 - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
    29.6 + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
    29.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    29.8   *
    29.9   * This code is free software; you can redistribute it and/or modify it
   29.10 @@ -3646,3 +3646,26 @@
   29.11      }
   29.12    }
   29.13  }
   29.14 +
   29.15 +LIR_Opr LIRGenerator::maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info) {
   29.16 +  if (x->check_boolean()) {
   29.17 +    LIR_Opr value_fixed = rlock_byte(T_BYTE);
   29.18 +    if (TwoOperandLIRForm) {
   29.19 +      __ move(value, value_fixed);
   29.20 +      __ logical_and(value_fixed, LIR_OprFact::intConst(1), value_fixed);
   29.21 +    } else {
   29.22 +      __ logical_and(value, LIR_OprFact::intConst(1), value_fixed);
   29.23 +    }
   29.24 +    LIR_Opr klass = new_register(T_METADATA);
   29.25 +    __ move(new LIR_Address(array, oopDesc::klass_offset_in_bytes(), T_ADDRESS), klass, null_check_info);
   29.26 +    null_check_info = NULL;
   29.27 +    LIR_Opr layout = new_register(T_INT);
   29.28 +    __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
   29.29 +    int diffbit = Klass::layout_helper_boolean_diffbit();
   29.30 +    __ logical_and(layout, LIR_OprFact::intConst(diffbit), layout);
   29.31 +    __ cmp(lir_cond_notEqual, layout, LIR_OprFact::intConst(0));
   29.32 +    __ cmove(lir_cond_notEqual, value_fixed, value, value_fixed, T_BYTE);
   29.33 +    value = value_fixed;
   29.34 +  }
   29.35 +  return value;
   29.36 +}
    30.1 --- a/src/share/vm/c1/c1_LIRGenerator.hpp	Tue Mar 29 23:01:10 2016 +0100
    30.2 +++ b/src/share/vm/c1/c1_LIRGenerator.hpp	Tue Apr 05 08:55:39 2016 -0700
    30.3 @@ -1,5 +1,5 @@
    30.4  /*
    30.5 - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
    30.6 + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
    30.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.8   *
    30.9   * This code is free software; you can redistribute it and/or modify it
   30.10 @@ -446,6 +446,7 @@
   30.11    void profile_arguments(ProfileCall* x);
   30.12    void profile_parameters(Base* x);
   30.13    void profile_parameters_at_call(ProfileCall* x);
   30.14 +  LIR_Opr maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info);
   30.15  
   30.16   public:
   30.17    Compilation*  compilation() const              { return _compilation; }
    31.1 --- a/src/share/vm/classfile/classFileParser.cpp	Tue Mar 29 23:01:10 2016 +0100
    31.2 +++ b/src/share/vm/classfile/classFileParser.cpp	Tue Apr 05 08:55:39 2016 -0700
    31.3 @@ -1,5 +1,5 @@
    31.4  /*
    31.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    31.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    31.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    31.8   *
    31.9   * This code is free software; you can redistribute it and/or modify it
   31.10 @@ -2417,11 +2417,9 @@
   31.11    m->set_constants(_cp);
   31.12    m->set_name_index(name_index);
   31.13    m->set_signature_index(signature_index);
   31.14 -#ifdef CC_INTERP
   31.15 -  // hmm is there a gc issue here??
   31.16 +
   31.17    ResultTypeFinder rtf(_cp->symbol_at(signature_index));
   31.18 -  m->set_result_index(rtf.type());
   31.19 -#endif
   31.20 +  m->constMethod()->set_result_type(rtf.type());
   31.21  
   31.22    if (args_size >= 0) {
   31.23      m->set_size_of_parameters(args_size);
    32.1 --- a/src/share/vm/classfile/defaultMethods.cpp	Tue Mar 29 23:01:10 2016 +0100
    32.2 +++ b/src/share/vm/classfile/defaultMethods.cpp	Tue Apr 05 08:55:39 2016 -0700
    32.3 @@ -1,5 +1,5 @@
    32.4  /*
    32.5 - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
    32.6 + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
    32.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    32.8   *
    32.9   * This code is free software; you can redistribute it and/or modify it
   32.10 @@ -892,10 +892,8 @@
   32.11    m->set_constants(NULL); // This will get filled in later
   32.12    m->set_name_index(cp->utf8(name));
   32.13    m->set_signature_index(cp->utf8(sig));
   32.14 -#ifdef CC_INTERP
   32.15    ResultTypeFinder rtf(sig);
   32.16 -  m->set_result_index(rtf.type());
   32.17 -#endif
   32.18 +  m->constMethod()->set_result_type(rtf.type());
   32.19    m->set_size_of_parameters(params);
   32.20    m->set_max_stack(max_stack);
   32.21    m->set_max_locals(params);
    33.1 --- a/src/share/vm/interpreter/bytecodeInterpreter.cpp	Tue Mar 29 23:01:10 2016 +0100
    33.2 +++ b/src/share/vm/interpreter/bytecodeInterpreter.cpp	Tue Apr 05 08:55:39 2016 -0700
    33.3 @@ -1,5 +1,5 @@
    33.4  /*
    33.5 - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
    33.6 + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
    33.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.8   *
    33.9   * This code is free software; you can redistribute it and/or modify it
   33.10 @@ -1780,8 +1780,19 @@
   33.11            ((objArrayOop) arrObj)->obj_at_put(index, rhsObject);
   33.12            UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
   33.13        }
   33.14 -      CASE(_bastore):
   33.15 -          ARRAY_STOREFROM32(T_BYTE, jbyte,  "%d",   STACK_INT, 0);
   33.16 +      CASE(_bastore): {
   33.17 +          ARRAY_INTRO(-3);
   33.18 +          int item = STACK_INT(-1);
   33.19 +          // if it is a T_BOOLEAN array, mask the stored value to 0/1
   33.20 +          if (arrObj->klass() == Universe::boolArrayKlassObj()) {
   33.21 +            item &= 1;
   33.22 +          } else {
   33.23 +            assert(arrObj->klass() == Universe::byteArrayKlassObj(),
   33.24 +                   "should be byte array otherwise");
   33.25 +          }
   33.26 +          ((typeArrayOop)arrObj)->byte_at_put(index, item);
   33.27 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
   33.28 +      }
   33.29        CASE(_castore):
   33.30            ARRAY_STOREFROM32(T_CHAR, jchar,  "%d",   STACK_INT, 0);
   33.31        CASE(_sastore):
   33.32 @@ -2012,7 +2023,7 @@
   33.33              } else if (tos_type == ltos) {
   33.34                SET_STACK_LONG(obj->long_field_acquire(field_offset), 0);
   33.35                MORE_STACK(1);
   33.36 -            } else if (tos_type == btos) {
   33.37 +            } else if (tos_type == btos || tos_type == ztos) {
   33.38                SET_STACK_INT(obj->byte_field_acquire(field_offset), -1);
   33.39              } else if (tos_type == ctos) {
   33.40                SET_STACK_INT(obj->char_field_acquire(field_offset), -1);
   33.41 @@ -2033,7 +2044,7 @@
   33.42              } else if (tos_type == ltos) {
   33.43                SET_STACK_LONG(obj->long_field(field_offset), 0);
   33.44                MORE_STACK(1);
   33.45 -            } else if (tos_type == btos) {
   33.46 +            } else if (tos_type == btos || tos_type == ztos) {
   33.47                SET_STACK_INT(obj->byte_field(field_offset), -1);
   33.48              } else if (tos_type == ctos) {
   33.49                SET_STACK_INT(obj->char_field(field_offset), -1);
   33.50 @@ -2122,6 +2133,9 @@
   33.51                obj->release_obj_field_put(field_offset, STACK_OBJECT(-1));
   33.52              } else if (tos_type == btos) {
   33.53                obj->release_byte_field_put(field_offset, STACK_INT(-1));
   33.54 +            } else if (tos_type == ztos) {
   33.55 +              int bool_field = STACK_INT(-1);  // only store LSB
   33.56 +              obj->release_byte_field_put(field_offset, (bool_field & 1));
   33.57              } else if (tos_type == ltos) {
   33.58                obj->release_long_field_put(field_offset, STACK_LONG(-1));
   33.59              } else if (tos_type == ctos) {
   33.60 @@ -2142,6 +2156,9 @@
   33.61                obj->obj_field_put(field_offset, STACK_OBJECT(-1));
   33.62              } else if (tos_type == btos) {
   33.63                obj->byte_field_put(field_offset, STACK_INT(-1));
   33.64 +            } else if (tos_type == ztos) {
   33.65 +              int bool_field = STACK_INT(-1);  // only store LSB
   33.66 +              obj->byte_field_put(field_offset, (bool_field & 1));
   33.67              } else if (tos_type == ltos) {
   33.68                obj->long_field_put(field_offset, STACK_LONG(-1));
   33.69              } else if (tos_type == ctos) {
    34.1 --- a/src/share/vm/interpreter/bytecodes.cpp	Tue Mar 29 23:01:10 2016 +0100
    34.2 +++ b/src/share/vm/interpreter/bytecodes.cpp	Tue Apr 05 08:55:39 2016 -0700
    34.3 @@ -1,5 +1,5 @@
    34.4  /*
    34.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    34.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    34.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    34.8   *
    34.9   * This code is free software; you can redistribute it and/or modify it
   34.10 @@ -510,6 +510,7 @@
   34.11  
   34.12    def(_fast_aputfield      , "fast_aputfield"      , "bJJ"  , NULL    , T_OBJECT ,  0, true , _putfield       );
   34.13    def(_fast_bputfield      , "fast_bputfield"      , "bJJ"  , NULL    , T_INT    ,  0, true , _putfield       );
   34.14 +  def(_fast_zputfield      , "fast_zputfield"      , "bJJ"  , NULL    , T_INT    ,  0, true , _putfield       );
   34.15    def(_fast_cputfield      , "fast_cputfield"      , "bJJ"  , NULL    , T_CHAR   ,  0, true , _putfield       );
   34.16    def(_fast_dputfield      , "fast_dputfield"      , "bJJ"  , NULL    , T_DOUBLE ,  0, true , _putfield       );
   34.17    def(_fast_fputfield      , "fast_fputfield"      , "bJJ"  , NULL    , T_FLOAT  ,  0, true , _putfield       );
    35.1 --- a/src/share/vm/interpreter/bytecodes.hpp	Tue Mar 29 23:01:10 2016 +0100
    35.2 +++ b/src/share/vm/interpreter/bytecodes.hpp	Tue Apr 05 08:55:39 2016 -0700
    35.3 @@ -1,5 +1,5 @@
    35.4  /*
    35.5 - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
    35.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    35.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    35.8   *
    35.9   * This code is free software; you can redistribute it and/or modify it
   35.10 @@ -256,6 +256,7 @@
   35.11  
   35.12      _fast_aputfield       ,
   35.13      _fast_bputfield       ,
   35.14 +    _fast_zputfield       ,
   35.15      _fast_cputfield       ,
   35.16      _fast_dputfield       ,
   35.17      _fast_fputfield       ,
    36.1 --- a/src/share/vm/interpreter/interpreterRuntime.cpp	Tue Mar 29 23:01:10 2016 +0100
    36.2 +++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Tue Apr 05 08:55:39 2016 -0700
    36.3 @@ -1,5 +1,5 @@
    36.4  /*
    36.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    36.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    36.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    36.8   *
    36.9   * This code is free software; you can redistribute it and/or modify it
   36.10 @@ -1011,6 +1011,7 @@
   36.11  
   36.12    switch(cp_entry->flag_state()) {
   36.13      case btos:    // fall through
   36.14 +    case ztos:    // fall through
   36.15      case ctos:    // fall through
   36.16      case stos:    // fall through
   36.17      case itos:    // fall through
   36.18 @@ -1047,7 +1048,8 @@
   36.19    char sig_type = '\0';
   36.20  
   36.21    switch(cp_entry->flag_state()) {
   36.22 -    case btos: sig_type = 'Z'; break;
   36.23 +    case btos: sig_type = 'B'; break;
   36.24 +    case ztos: sig_type = 'Z'; break;
   36.25      case ctos: sig_type = 'C'; break;
   36.26      case stos: sig_type = 'S'; break;
   36.27      case itos: sig_type = 'I'; break;
    37.1 --- a/src/share/vm/interpreter/templateInterpreter.cpp	Tue Mar 29 23:01:10 2016 +0100
    37.2 +++ b/src/share/vm/interpreter/templateInterpreter.cpp	Tue Apr 05 08:55:39 2016 -0700
    37.3 @@ -1,5 +1,5 @@
    37.4  /*
    37.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    37.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    37.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    37.8   *
    37.9   * This code is free software; you can redistribute it and/or modify it
   37.10 @@ -61,8 +61,9 @@
   37.11  // Implementation of EntryPoint
   37.12  
   37.13  EntryPoint::EntryPoint() {
   37.14 -  assert(number_of_states == 9, "check the code below");
   37.15 +  assert(number_of_states == 10, "check the code below");
   37.16    _entry[btos] = NULL;
   37.17 +  _entry[ztos] = NULL;
   37.18    _entry[ctos] = NULL;
   37.19    _entry[stos] = NULL;
   37.20    _entry[atos] = NULL;
   37.21 @@ -74,9 +75,10 @@
   37.22  }
   37.23  
   37.24  
   37.25 -EntryPoint::EntryPoint(address bentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry) {
   37.26 -  assert(number_of_states == 9, "check the code below");
   37.27 +EntryPoint::EntryPoint(address bentry, address zentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry) {
   37.28 +  assert(number_of_states == 10, "check the code below");
   37.29    _entry[btos] = bentry;
   37.30 +  _entry[ztos] = zentry;
   37.31    _entry[ctos] = centry;
   37.32    _entry[stos] = sentry;
   37.33    _entry[atos] = aentry;
   37.34 @@ -127,6 +129,7 @@
   37.35    return
   37.36      EntryPoint(
   37.37        _table[btos][i],
   37.38 +      _table[ztos][i],
   37.39        _table[ctos][i],
   37.40        _table[stos][i],
   37.41        _table[atos][i],
   37.42 @@ -141,8 +144,9 @@
   37.43  
   37.44  void DispatchTable::set_entry(int i, EntryPoint& entry) {
   37.45    assert(0 <= i && i < length, "index out of bounds");
   37.46 -  assert(number_of_states == 9, "check the code below");
   37.47 +  assert(number_of_states == 10, "check the code below");
   37.48    _table[btos][i] = entry.entry(btos);
   37.49 +  _table[ztos][i] = entry.entry(ztos);
   37.50    _table[ctos][i] = entry.entry(ctos);
   37.51    _table[stos][i] = entry.entry(stos);
   37.52    _table[atos][i] = entry.entry(atos);
   37.53 @@ -225,6 +229,7 @@
   37.54      Interpreter::_trace_code =
   37.55        EntryPoint(
   37.56          generate_trace_code(btos),
   37.57 +        generate_trace_code(ztos),
   37.58          generate_trace_code(ctos),
   37.59          generate_trace_code(stos),
   37.60          generate_trace_code(atos),
   37.61 @@ -245,6 +250,7 @@
   37.62            generate_return_entry_for(itos, i, index_size),
   37.63            generate_return_entry_for(itos, i, index_size),
   37.64            generate_return_entry_for(itos, i, index_size),
   37.65 +          generate_return_entry_for(itos, i, index_size),
   37.66            generate_return_entry_for(atos, i, index_size),
   37.67            generate_return_entry_for(itos, i, index_size),
   37.68            generate_return_entry_for(ltos, i, index_size),
   37.69 @@ -256,13 +262,16 @@
   37.70    }
   37.71  
   37.72    { CodeletMark cm(_masm, "invoke return entry points");
   37.73 -    const TosState states[] = {itos, itos, itos, itos, ltos, ftos, dtos, atos, vtos};
   37.74 +    // These states are in order specified in TosState, except btos/ztos/ctos/stos are
   37.75 +    // really the same as itos since there is no top of stack optimization for these types
   37.76 +    const TosState states[] = {itos, itos, itos, itos, itos, ltos, ftos, dtos, atos, vtos, ilgl};
   37.77      const int invoke_length = Bytecodes::length_for(Bytecodes::_invokestatic);
   37.78      const int invokeinterface_length = Bytecodes::length_for(Bytecodes::_invokeinterface);
   37.79      const int invokedynamic_length = Bytecodes::length_for(Bytecodes::_invokedynamic);
   37.80  
   37.81      for (int i = 0; i < Interpreter::number_of_return_addrs; i++) {
   37.82        TosState state = states[i];
   37.83 +      assert(state != ilgl, "states array is wrong above");
   37.84        Interpreter::_invoke_return_entry[i] = generate_return_entry_for(state, invoke_length, sizeof(u2));
   37.85        Interpreter::_invokeinterface_return_entry[i] = generate_return_entry_for(state, invokeinterface_length, sizeof(u2));
   37.86        Interpreter::_invokedynamic_return_entry[i] = generate_return_entry_for(state, invokedynamic_length, sizeof(u4));
   37.87 @@ -273,6 +282,7 @@
   37.88      Interpreter::_earlyret_entry =
   37.89        EntryPoint(
   37.90          generate_earlyret_entry_for(btos),
   37.91 +        generate_earlyret_entry_for(ztos),
   37.92          generate_earlyret_entry_for(ctos),
   37.93          generate_earlyret_entry_for(stos),
   37.94          generate_earlyret_entry_for(atos),
   37.95 @@ -291,6 +301,7 @@
   37.96            generate_deopt_entry_for(itos, i),
   37.97            generate_deopt_entry_for(itos, i),
   37.98            generate_deopt_entry_for(itos, i),
   37.99 +          generate_deopt_entry_for(itos, i),
  37.100            generate_deopt_entry_for(atos, i),
  37.101            generate_deopt_entry_for(itos, i),
  37.102            generate_deopt_entry_for(ltos, i),
  37.103 @@ -318,6 +329,7 @@
  37.104      Interpreter::_continuation_entry =
  37.105        EntryPoint(
  37.106          generate_continuation_for(btos),
  37.107 +        generate_continuation_for(ztos),
  37.108          generate_continuation_for(ctos),
  37.109          generate_continuation_for(stos),
  37.110          generate_continuation_for(atos),
  37.111 @@ -333,6 +345,7 @@
  37.112      Interpreter::_safept_entry =
  37.113        EntryPoint(
  37.114          generate_safept_entry_for(btos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
  37.115 +        generate_safept_entry_for(ztos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
  37.116          generate_safept_entry_for(ctos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
  37.117          generate_safept_entry_for(stos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
  37.118          generate_safept_entry_for(atos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
  37.119 @@ -436,7 +449,7 @@
  37.120  
  37.121  void TemplateInterpreterGenerator::set_unimplemented(int i) {
  37.122    address e = _unimplemented_bytecode;
  37.123 -  EntryPoint entry(e, e, e, e, e, e, e, e, e);
  37.124 +  EntryPoint entry(e, e, e, e, e, e, e, e, e, e);
  37.125    Interpreter::_normal_table.set_entry(i, entry);
  37.126    Interpreter::_wentry_point[i] = _unimplemented_bytecode;
  37.127  }
  37.128 @@ -448,6 +461,7 @@
  37.129    assert(_unimplemented_bytecode    != NULL, "should have been generated before");
  37.130    assert(_illegal_bytecode_sequence != NULL, "should have been generated before");
  37.131    address bep = _illegal_bytecode_sequence;
  37.132 +  address zep = _illegal_bytecode_sequence;
  37.133    address cep = _illegal_bytecode_sequence;
  37.134    address sep = _illegal_bytecode_sequence;
  37.135    address aep = _illegal_bytecode_sequence;
  37.136 @@ -469,7 +483,7 @@
  37.137      set_wide_entry_point(t, wep);
  37.138    }
  37.139    // set entry points
  37.140 -  EntryPoint entry(bep, cep, sep, aep, iep, lep, fep, dep, vep);
  37.141 +  EntryPoint entry(bep, zep, cep, sep, aep, iep, lep, fep, dep, vep);
  37.142    Interpreter::_normal_table.set_entry(code, entry);
  37.143    Interpreter::_wentry_point[code] = wep;
  37.144  }
  37.145 @@ -486,6 +500,7 @@
  37.146    assert(t->is_valid(), "template must exist");
  37.147    switch (t->tos_in()) {
  37.148      case btos:
  37.149 +    case ztos:
  37.150      case ctos:
  37.151      case stos:
  37.152        ShouldNotReachHere();  // btos/ctos/stos should use itos.
    38.1 --- a/src/share/vm/interpreter/templateInterpreter.hpp	Tue Mar 29 23:01:10 2016 +0100
    38.2 +++ b/src/share/vm/interpreter/templateInterpreter.hpp	Tue Apr 05 08:55:39 2016 -0700
    38.3 @@ -1,5 +1,5 @@
    38.4  /*
    38.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    38.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    38.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    38.8   *
    38.9   * This code is free software; you can redistribute it and/or modify it
   38.10 @@ -44,7 +44,7 @@
   38.11   public:
   38.12    // Construction
   38.13    EntryPoint();
   38.14 -  EntryPoint(address bentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry);
   38.15 +  EntryPoint(address bentry, address zentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry);
   38.16  
   38.17    // Attributes
   38.18    address entry(TosState state) const;                // return target address for a given tosca state
    39.1 --- a/src/share/vm/interpreter/templateTable.cpp	Tue Mar 29 23:01:10 2016 +0100
    39.2 +++ b/src/share/vm/interpreter/templateTable.cpp	Tue Apr 05 08:55:39 2016 -0700
    39.3 @@ -1,5 +1,5 @@
    39.4  /*
    39.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    39.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    39.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.8   *
    39.9   * This code is free software; you can redistribute it and/or modify it
   39.10 @@ -488,6 +488,7 @@
   39.11  
   39.12    def(Bytecodes::_fast_aputfield      , ubcp|____|____|____, atos, vtos, fast_storefield ,   atos        );
   39.13    def(Bytecodes::_fast_bputfield      , ubcp|____|____|____, itos, vtos, fast_storefield ,   itos        );
   39.14 +  def(Bytecodes::_fast_zputfield      , ubcp|____|____|____, itos, vtos, fast_storefield ,   itos        );
   39.15    def(Bytecodes::_fast_cputfield      , ubcp|____|____|____, itos, vtos, fast_storefield  ,  itos        );
   39.16    def(Bytecodes::_fast_dputfield      , ubcp|____|____|____, dtos, vtos, fast_storefield  ,  dtos        );
   39.17    def(Bytecodes::_fast_fputfield      , ubcp|____|____|____, ftos, vtos, fast_storefield  ,  ftos        );
    40.1 --- a/src/share/vm/oops/constMethod.cpp	Tue Mar 29 23:01:10 2016 +0100
    40.2 +++ b/src/share/vm/oops/constMethod.cpp	Tue Apr 05 08:55:39 2016 -0700
    40.3 @@ -1,5 +1,5 @@
    40.4  /*
    40.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
    40.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    40.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    40.8   *
    40.9   * This code is free software; you can redistribute it and/or modify it
   40.10 @@ -65,6 +65,7 @@
   40.11    set_max_locals(0);
   40.12    set_method_idnum(0);
   40.13    set_size_of_parameters(0);
   40.14 +  set_result_type(T_VOID);
   40.15  }
   40.16  
   40.17  // Accessor that copies to metadata.
    41.1 --- a/src/share/vm/oops/constMethod.hpp	Tue Mar 29 23:01:10 2016 +0100
    41.2 +++ b/src/share/vm/oops/constMethod.hpp	Tue Apr 05 08:55:39 2016 -0700
    41.3 @@ -1,5 +1,5 @@
    41.4  /*
    41.5 - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
    41.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    41.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    41.8   *
    41.9   * This code is free software; you can redistribute it and/or modify it
   41.10 @@ -211,6 +211,7 @@
   41.11  
   41.12    int               _constMethod_size;
   41.13    u2                _flags;
   41.14 +  u1                _result_type;                 // BasicType of result
   41.15  
   41.16    // Size of Java bytecodes allocated immediately after Method*.
   41.17    u2                _code_size;
   41.18 @@ -469,6 +470,8 @@
   41.19    static ByteSize size_of_parameters_offset()
   41.20                              { return byte_offset_of(ConstMethod, _size_of_parameters); }
   41.21  
   41.22 +  static ByteSize result_type_offset()
   41.23 +                            { return byte_offset_of(ConstMethod, _result_type); }
   41.24  
   41.25    // Unique id for the method
   41.26    static const u2 MAX_IDNUM;
   41.27 @@ -491,6 +494,8 @@
   41.28    int  size_of_parameters() const                { return _size_of_parameters; }
   41.29    void set_size_of_parameters(int size)          { _size_of_parameters = size; }
   41.30  
   41.31 +  void set_result_type(BasicType rt)             { assert(rt < 16, "result type too large");
   41.32 +                                                   _result_type = (u1)rt; }
   41.33    // Deallocation for RedefineClasses
   41.34    void deallocate_contents(ClassLoaderData* loader_data);
   41.35    bool is_klass() const { return false; }
    42.1 --- a/src/share/vm/oops/cpCache.hpp	Tue Mar 29 23:01:10 2016 +0100
    42.2 +++ b/src/share/vm/oops/cpCache.hpp	Tue Apr 05 08:55:39 2016 -0700
    42.3 @@ -1,5 +1,5 @@
    42.4  /*
    42.5 - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
    42.6 + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
    42.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    42.8   *
    42.9   * This code is free software; you can redistribute it and/or modify it
   42.10 @@ -77,18 +77,19 @@
   42.11  // f2 flag true if f2 contains an oop (e.g., virtual final method)
   42.12  // fv flag true if invokeinterface used for method in class Object
   42.13  //
   42.14 -// The flags 31, 30, 29, 28 together build a 4 bit number 0 to 8 with the
   42.15 +// The flags 31, 30, 29, 28 together build a 4 bit number 0 to 16 with the
   42.16  // following mapping to the TosState states:
   42.17  //
   42.18  // btos: 0
   42.19 -// ctos: 1
   42.20 -// stos: 2
   42.21 -// itos: 3
   42.22 -// ltos: 4
   42.23 -// ftos: 5
   42.24 -// dtos: 6
   42.25 -// atos: 7
   42.26 -// vtos: 8
   42.27 +// ztos: 1
   42.28 +// ctos: 2
   42.29 +// stos: 3
   42.30 +// itos: 4
   42.31 +// ltos: 5
   42.32 +// ftos: 6
   42.33 +// dtos: 7
   42.34 +// atos: 8
   42.35 +// vtos: 9
   42.36  //
   42.37  // Entry specific: field entries:
   42.38  // _indices = get (b1 section) and put (b2 section) bytecodes, original constant pool index
   42.39 @@ -351,14 +352,8 @@
   42.40    bool has_method_type() const                   { return (!is_f1_null()) && (_flags & (1 << has_method_type_shift))   != 0; }
   42.41    bool is_method_entry() const                   { return (_flags & (1 << is_field_entry_shift))    == 0; }
   42.42    bool is_field_entry() const                    { return (_flags & (1 << is_field_entry_shift))    != 0; }
   42.43 -  bool is_byte() const                           { return flag_state() == btos; }
   42.44 -  bool is_char() const                           { return flag_state() == ctos; }
   42.45 -  bool is_short() const                          { return flag_state() == stos; }
   42.46 -  bool is_int() const                            { return flag_state() == itos; }
   42.47    bool is_long() const                           { return flag_state() == ltos; }
   42.48 -  bool is_float() const                          { return flag_state() == ftos; }
   42.49    bool is_double() const                         { return flag_state() == dtos; }
   42.50 -  bool is_object() const                         { return flag_state() == atos; }
   42.51    TosState flag_state() const                    { assert((uint)number_of_states <= (uint)tos_state_mask+1, "");
   42.52                                                     return (TosState)((_flags >> tos_state_shift) & tos_state_mask); }
   42.53  
    43.1 --- a/src/share/vm/oops/klass.hpp	Tue Mar 29 23:01:10 2016 +0100
    43.2 +++ b/src/share/vm/oops/klass.hpp	Tue Apr 05 08:55:39 2016 -0700
    43.3 @@ -1,5 +1,5 @@
    43.4  /*
    43.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    43.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    43.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    43.8   *
    43.9   * This code is free software; you can redistribute it and/or modify it
   43.10 @@ -370,6 +370,21 @@
   43.11      assert(btvalue >= T_BOOLEAN && btvalue <= T_OBJECT, "sanity");
   43.12      return (BasicType) btvalue;
   43.13    }
   43.14 +
   43.15 +  // Want a pattern to quickly diff against layout header in register
   43.16 +  // find something less clever!
   43.17 +  static int layout_helper_boolean_diffbit() {
   43.18 +    jint zlh = array_layout_helper(T_BOOLEAN);
   43.19 +    jint blh = array_layout_helper(T_BYTE);
   43.20 +    assert(zlh != blh, "array layout helpers must differ");
   43.21 +    int diffbit = 1;
   43.22 +    while ((diffbit & (zlh ^ blh)) == 0 && (diffbit & zlh) == 0) {
   43.23 +      diffbit <<= 1;
   43.24 +      assert(diffbit != 0, "make sure T_BOOLEAN has a different bit than T_BYTE");
   43.25 +    }
   43.26 +    return diffbit;
   43.27 +  }
   43.28 +
   43.29    static int layout_helper_log2_element_size(jint lh) {
   43.30      assert(lh < (jint)_lh_neutral_value, "must be array");
   43.31      int l2esz = (lh >> _lh_log2_element_size_shift) & _lh_log2_element_size_mask;
    44.1 --- a/src/share/vm/oops/method.cpp	Tue Mar 29 23:01:10 2016 +0100
    44.2 +++ b/src/share/vm/oops/method.cpp	Tue Apr 05 08:55:39 2016 -0700
    44.3 @@ -1,5 +1,5 @@
    44.4  /*
    44.5 - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
    44.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    44.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44.8   *
    44.9   * This code is free software; you can redistribute it and/or modify it
   44.10 @@ -84,9 +84,6 @@
   44.11    set_constMethod(xconst);
   44.12    set_access_flags(access_flags);
   44.13    set_method_size(size);
   44.14 -#ifdef CC_INTERP
   44.15 -  set_result_index(T_VOID);
   44.16 -#endif
   44.17    set_intrinsic_id(vmIntrinsics::_none);
   44.18    set_jfr_towrite(false);
   44.19    set_force_inline(false);
   44.20 @@ -412,12 +409,6 @@
   44.21    set_size_of_parameters(asc.size() + (is_static() ? 0 : 1));
   44.22  }
   44.23  
   44.24 -#ifdef CC_INTERP
   44.25 -void Method::set_result_index(BasicType type)          {
   44.26 -  _result_index = Interpreter::BasicType_as_index(type);
   44.27 -}
   44.28 -#endif
   44.29 -
   44.30  BasicType Method::result_type() const {
   44.31    ResultTypeFinder rtf(signature());
   44.32    return rtf.type();
   44.33 @@ -1123,10 +1114,8 @@
   44.34    m->set_signature_index(_imcp_invoke_signature);
   44.35    assert(MethodHandles::is_signature_polymorphic_name(m->name()), "");
   44.36    assert(m->signature() == signature, "");
   44.37 -#ifdef CC_INTERP
   44.38    ResultTypeFinder rtf(signature);
   44.39 -  m->set_result_index(rtf.type());
   44.40 -#endif
   44.41 +  m->constMethod()->set_result_type(rtf.type());
   44.42    m->compute_size_of_parameters(THREAD);
   44.43    m->init_intrinsic_id();
   44.44    assert(m->is_method_handle_intrinsic(), "");
    45.1 --- a/src/share/vm/oops/method.hpp	Tue Mar 29 23:01:10 2016 +0100
    45.2 +++ b/src/share/vm/oops/method.hpp	Tue Apr 05 08:55:39 2016 -0700
    45.3 @@ -1,5 +1,5 @@
    45.4  /*
    45.5 - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
    45.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    45.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    45.8   *
    45.9   * This code is free software; you can redistribute it and/or modify it
   45.10 @@ -105,9 +105,6 @@
   45.11    AccessFlags       _access_flags;               // Access flags
   45.12    int               _vtable_index;               // vtable index of this method (see VtableIndexFlag)
   45.13                                                   // note: can have vtables with >2**16 elements (because of inheritance)
   45.14 -#ifdef CC_INTERP
   45.15 -  int               _result_index;               // C++ interpreter needs for converting results to/from stack
   45.16 -#endif
   45.17    u2                _method_size;                // size of this object
   45.18    u1                _intrinsic_id;               // vmSymbols::intrinsic_id (0 == _none)
   45.19    u1                _jfr_towrite          : 1,   // Flags
   45.20 @@ -202,11 +199,6 @@
   45.21      return constMethod()->type_annotations();
   45.22    }
   45.23  
   45.24 -#ifdef CC_INTERP
   45.25 -  void set_result_index(BasicType type);
   45.26 -  int  result_index()                            { return _result_index; }
   45.27 -#endif
   45.28 -
   45.29    // Helper routine: get klass name + "." + method name + signature as
   45.30    // C string, for the purpose of providing more useful NoSuchMethodErrors
   45.31    // and fatal error handling. The string is allocated in resource
   45.32 @@ -559,7 +551,6 @@
   45.33    void compute_size_of_parameters(Thread *thread); // word size of parameters (receiver if any + arguments)
   45.34    Symbol* klass_name() const;                    // returns the name of the method holder
   45.35    BasicType result_type() const;                 // type of the method result
   45.36 -  int result_type_index() const;                 // type index of the method result
   45.37    bool is_returning_oop() const                  { BasicType r = result_type(); return (r == T_OBJECT || r == T_ARRAY); }
   45.38    bool is_returning_fp() const                   { BasicType r = result_type(); return (r == T_FLOAT || r == T_DOUBLE); }
   45.39  
   45.40 @@ -652,9 +643,6 @@
   45.41    // interpreter support
   45.42    static ByteSize const_offset()                 { return byte_offset_of(Method, _constMethod       ); }
   45.43    static ByteSize access_flags_offset()          { return byte_offset_of(Method, _access_flags      ); }
   45.44 -#ifdef CC_INTERP
   45.45 -  static ByteSize result_index_offset()          { return byte_offset_of(Method, _result_index ); }
   45.46 -#endif /* CC_INTERP */
   45.47    static ByteSize from_compiled_offset()         { return byte_offset_of(Method, _from_compiled_entry); }
   45.48    static ByteSize code_offset()                  { return byte_offset_of(Method, _code); }
   45.49    static ByteSize method_data_offset()           {
    46.1 --- a/src/share/vm/oops/oop.inline.hpp	Tue Mar 29 23:01:10 2016 +0100
    46.2 +++ b/src/share/vm/oops/oop.inline.hpp	Tue Apr 05 08:55:39 2016 -0700
    46.3 @@ -1,5 +1,5 @@
    46.4  /*
    46.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    46.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    46.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    46.8   *
    46.9   * This code is free software; you can redistribute it and/or modify it
   46.10 @@ -339,7 +339,7 @@
   46.11  inline void oopDesc::byte_field_put(int offset, jbyte contents)     { *byte_field_addr(offset) = (jint) contents; }
   46.12  
   46.13  inline jboolean oopDesc::bool_field(int offset) const               { return (jboolean) *bool_field_addr(offset); }
   46.14 -inline void oopDesc::bool_field_put(int offset, jboolean contents)  { *bool_field_addr(offset) = (jint) contents; }
   46.15 +inline void oopDesc::bool_field_put(int offset, jboolean contents)  { *bool_field_addr(offset) = (( (jint) contents) & 1); }
   46.16  
   46.17  inline jchar oopDesc::char_field(int offset) const                  { return (jchar) *char_field_addr(offset);    }
   46.18  inline void oopDesc::char_field_put(int offset, jchar contents)     { *char_field_addr(offset) = (jint) contents; }
   46.19 @@ -379,7 +379,7 @@
   46.20  inline void oopDesc::release_byte_field_put(int offset, jbyte contents)     { OrderAccess::release_store(byte_field_addr(offset), contents); }
   46.21  
   46.22  inline jboolean oopDesc::bool_field_acquire(int offset) const               { return OrderAccess::load_acquire(bool_field_addr(offset));     }
   46.23 -inline void oopDesc::release_bool_field_put(int offset, jboolean contents)  { OrderAccess::release_store(bool_field_addr(offset), contents); }
   46.24 +inline void oopDesc::release_bool_field_put(int offset, jboolean contents)  { OrderAccess::release_store(bool_field_addr(offset), (contents & 1)); }
   46.25  
   46.26  inline jchar oopDesc::char_field_acquire(int offset) const                  { return OrderAccess::load_acquire(char_field_addr(offset));     }
   46.27  inline void oopDesc::release_char_field_put(int offset, jchar contents)     { OrderAccess::release_store(char_field_addr(offset), contents); }
    47.1 --- a/src/share/vm/oops/typeArrayOop.hpp	Tue Mar 29 23:01:10 2016 +0100
    47.2 +++ b/src/share/vm/oops/typeArrayOop.hpp	Tue Apr 05 08:55:39 2016 -0700
    47.3 @@ -96,7 +96,7 @@
    47.4    void byte_at_put(int which, jbyte contents)     { *byte_at_addr(which) = contents; }
    47.5  
    47.6    jboolean bool_at(int which) const               { return *bool_at_addr(which); }
    47.7 -  void bool_at_put(int which, jboolean contents)  { *bool_at_addr(which) = contents; }
    47.8 +  void bool_at_put(int which, jboolean contents)  { *bool_at_addr(which) = (((jint)contents) & 1); }
    47.9  
   47.10    jchar char_at(int which) const                  { return *char_at_addr(which); }
   47.11    void char_at_put(int which, jchar contents)     { *char_at_addr(which) = contents; }
    48.1 --- a/src/share/vm/opto/memnode.cpp	Tue Mar 29 23:01:10 2016 +0100
    48.2 +++ b/src/share/vm/opto/memnode.cpp	Tue Apr 05 08:55:39 2016 -0700
    48.3 @@ -1,5 +1,5 @@
    48.4  /*
    48.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    48.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    48.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    48.8   *
    48.9   * This code is free software; you can redistribute it and/or modify it
   48.10 @@ -2370,7 +2370,7 @@
   48.11           ctl != NULL, "raw memory operations should have control edge");
   48.12  
   48.13    switch (bt) {
   48.14 -  case T_BOOLEAN:
   48.15 +  case T_BOOLEAN: val = gvn.transform(new (C) AndINode(val, gvn.intcon(0x1))); // Fall through to T_BYTE case
   48.16    case T_BYTE:    return new (C) StoreBNode(ctl, mem, adr, adr_type, val, mo);
   48.17    case T_INT:     return new (C) StoreINode(ctl, mem, adr, adr_type, val, mo);
   48.18    case T_CHAR:
    49.1 --- a/src/share/vm/opto/parse1.cpp	Tue Mar 29 23:01:10 2016 +0100
    49.2 +++ b/src/share/vm/opto/parse1.cpp	Tue Apr 05 08:55:39 2016 -0700
    49.3 @@ -1,5 +1,5 @@
    49.4  /*
    49.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    49.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    49.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    49.8   *
    49.9   * This code is free software; you can redistribute it and/or modify it
   49.10 @@ -717,6 +717,27 @@
   49.11  #endif
   49.12  }
   49.13  
   49.14 +static Node* mask_int_value(Node* v, BasicType bt, PhaseGVN* gvn) {
   49.15 +  Compile* C = gvn->C;
   49.16 +  switch (bt) {
   49.17 +  case T_BYTE:
   49.18 +    v = gvn->transform(new (C) LShiftINode(v, gvn->intcon(24)));
   49.19 +    v = gvn->transform(new (C) RShiftINode(v, gvn->intcon(24)));
   49.20 +    break;
   49.21 +  case T_SHORT:
   49.22 +    v = gvn->transform(new (C) LShiftINode(v, gvn->intcon(16)));
   49.23 +    v = gvn->transform(new (C) RShiftINode(v, gvn->intcon(16)));
   49.24 +    break;
   49.25 +  case T_CHAR:
   49.26 +    v = gvn->transform(new (C) AndINode(v, gvn->intcon(0xFFFF)));
   49.27 +    break;
   49.28 +  case T_BOOLEAN:
   49.29 +    v = gvn->transform(new (C) AndINode(v, gvn->intcon(0x1)));
   49.30 +    break;
   49.31 +  }
   49.32 +  return v;
   49.33 +}
   49.34 +
   49.35  //-------------------------------build_exits----------------------------------
   49.36  // Build normal and exceptional exit merge points.
   49.37  void Parse::build_exits() {
   49.38 @@ -741,6 +762,16 @@
   49.39    // Add a return value to the exit state.  (Do not push it yet.)
   49.40    if (tf()->range()->cnt() > TypeFunc::Parms) {
   49.41      const Type* ret_type = tf()->range()->field_at(TypeFunc::Parms);
   49.42 +    if (ret_type->isa_int()) {
   49.43 +      BasicType ret_bt = method()->return_type()->basic_type();
   49.44 +      if (ret_bt == T_BOOLEAN ||
   49.45 +          ret_bt == T_CHAR ||
   49.46 +          ret_bt == T_BYTE ||
   49.47 +          ret_bt == T_SHORT) {
   49.48 +        ret_type = TypeInt::INT;
   49.49 +      }
   49.50 +    }
   49.51 +
   49.52      // Don't "bind" an unloaded return klass to the ret_phi. If the klass
   49.53      // becomes loaded during the subsequent parsing, the loaded and unloaded
   49.54      // types will not join when we transform and push in do_exits().
   49.55 @@ -958,6 +989,10 @@
   49.56      const Type* ret_type = tf()->range()->field_at(TypeFunc::Parms);
   49.57      Node*       ret_phi  = _gvn.transform( _exits.argument(0) );
   49.58      assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty(), "return value must be well defined");
   49.59 +    if (ret_type->isa_int()) {
   49.60 +      BasicType ret_bt = method()->return_type()->basic_type();
   49.61 +      ret_phi = mask_int_value(ret_phi, ret_bt, &_gvn);
   49.62 +    }
   49.63      _exits.push_node(ret_type->basic_type(), ret_phi);
   49.64    }
   49.65  
    50.1 --- a/src/share/vm/opto/parse2.cpp	Tue Mar 29 23:01:10 2016 +0100
    50.2 +++ b/src/share/vm/opto/parse2.cpp	Tue Apr 05 08:55:39 2016 -0700
    50.3 @@ -1,5 +1,5 @@
    50.4  /*
    50.5 - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
    50.6 + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
    50.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    50.8   *
    50.9   * This code is free software; you can redistribute it and/or modify it
   50.10 @@ -57,11 +57,15 @@
   50.11  
   50.12  //--------------------------------array_store----------------------------------
   50.13  void Parse::array_store(BasicType elem_type) {
   50.14 -  Node* adr = array_addressing(elem_type, 1);
   50.15 +  const Type* elem = Type::TOP;
   50.16 +  Node* adr = array_addressing(elem_type, 1, &elem);
   50.17    if (stopped())  return;     // guaranteed null or range check
   50.18    Node* val = pop();
   50.19    dec_sp(2);                  // Pop array and index
   50.20    const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
   50.21 +  if (elem == TypeInt::BOOL) {
   50.22 +    elem_type = T_BOOLEAN;
   50.23 +  }
   50.24    store_to_memory(control(), adr, val, elem_type, adr_type, StoreNode::release_if_reference(elem_type));
   50.25  }
   50.26  
    51.1 --- a/src/share/vm/opto/type.cpp	Tue Mar 29 23:01:10 2016 +0100
    51.2 +++ b/src/share/vm/opto/type.cpp	Tue Apr 05 08:55:39 2016 -0700
    51.3 @@ -1,5 +1,5 @@
    51.4  /*
    51.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    51.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    51.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    51.8   *
    51.9   * This code is free software; you can redistribute it and/or modify it
   51.10 @@ -1767,13 +1767,15 @@
   51.11        break;
   51.12      case T_OBJECT:
   51.13      case T_ARRAY:
   51.14 +    case T_FLOAT:
   51.15 +    case T_INT:
   51.16 +      field_array[pos++] = get_const_type(type);
   51.17 +      break;
   51.18      case T_BOOLEAN:
   51.19      case T_CHAR:
   51.20 -    case T_FLOAT:
   51.21      case T_BYTE:
   51.22      case T_SHORT:
   51.23 -    case T_INT:
   51.24 -      field_array[pos++] = get_const_type(type);
   51.25 +      field_array[pos++] = TypeInt::INT;
   51.26        break;
   51.27      default:
   51.28        ShouldNotReachHere();
    52.1 --- a/src/share/vm/prims/jni.cpp	Tue Mar 29 23:01:10 2016 +0100
    52.2 +++ b/src/share/vm/prims/jni.cpp	Tue Apr 05 08:55:39 2016 -0700
    52.3 @@ -1,5 +1,5 @@
    52.4  /*
    52.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    52.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    52.7   * Copyright (c) 2012 Red Hat, Inc.
    52.8   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    52.9   *
   52.10 @@ -1121,7 +1121,14 @@
   52.11   protected:
   52.12    va_list _ap;
   52.13  
   52.14 -  inline void get_bool()   { _arguments->push_int(va_arg(_ap, jint)); } // bool is coerced to int when using va_arg
   52.15 +  inline void get_bool()   {
   52.16 +    // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
   52.17 +    // 0 to JNI_FALSE.  Boolean return values from native are normalized the same in
   52.18 +    // TemplateInterpreterGenerator::generate_result_handler_for and
   52.19 +    // SharedRuntime::generate_native_wrapper.
   52.20 +    jboolean b = va_arg(_ap, jint);
   52.21 +    _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
   52.22 +  }
   52.23    inline void get_char()   { _arguments->push_int(va_arg(_ap, jint)); } // char is coerced to int when using va_arg
   52.24    inline void get_short()  { _arguments->push_int(va_arg(_ap, jint)); } // short is coerced to int when using va_arg
   52.25    inline void get_byte()   { _arguments->push_int(va_arg(_ap, jint)); } // byte is coerced to int when using va_arg
   52.26 @@ -1167,9 +1174,17 @@
   52.27        while ( 1 ) {
   52.28          switch ( fingerprint & parameter_feature_mask ) {
   52.29            case bool_parm:
   52.30 +            get_bool();
   52.31 +            break;
   52.32            case char_parm:
   52.33 +            get_char();
   52.34 +            break;
   52.35            case short_parm:
   52.36 +            get_short();
   52.37 +            break;
   52.38            case byte_parm:
   52.39 +            get_byte();
   52.40 +            break;
   52.41            case int_parm:
   52.42              get_int();
   52.43              break;
   52.44 @@ -1203,7 +1218,14 @@
   52.45   protected:
   52.46    const jvalue *_ap;
   52.47  
   52.48 -  inline void get_bool()   { _arguments->push_int((jint)(_ap++)->z); }
   52.49 +  inline void get_bool()   {
   52.50 +    // Normalize boolean arguments from native code by converting 1-255 to JNI_TRUE and
   52.51 +    // 0 to JNI_FALSE.  Boolean return values from native are normalized the same in
   52.52 +    // TemplateInterpreterGenerator::generate_result_handler_for and
   52.53 +    // SharedRuntime::generate_native_wrapper.
   52.54 +    jboolean b = (_ap++)->z;
   52.55 +    _arguments->push_int((jint)(b == 0 ? JNI_FALSE : JNI_TRUE));
   52.56 +  }
   52.57    inline void get_char()   { _arguments->push_int((jint)(_ap++)->c); }
   52.58    inline void get_short()  { _arguments->push_int((jint)(_ap++)->s); }
   52.59    inline void get_byte()   { _arguments->push_int((jint)(_ap++)->b); }
   52.60 @@ -2828,6 +2850,7 @@
   52.61      field_value.unionType = value; \
   52.62      o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \
   52.63    } \
   52.64 +  if (SigType == 'Z') { value = ((jboolean)value) & 1; } \
   52.65    o->Fieldname##_field_put(offset, value); \
   52.66    ReturnProbe; \
   52.67  JNI_END
   52.68 @@ -3132,6 +3155,7 @@
   52.69      field_value.unionType = value; \
   52.70      JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \
   52.71    } \
   52.72 +  if (SigType == 'Z') { value = ((jboolean)value) & 1; } \
   52.73    id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \
   52.74    ReturnProbe;\
   52.75  JNI_END
    53.1 --- a/src/share/vm/prims/jvmtiEnvBase.cpp	Tue Mar 29 23:01:10 2016 +0100
    53.2 +++ b/src/share/vm/prims/jvmtiEnvBase.cpp	Tue Apr 05 08:55:39 2016 -0700
    53.3 @@ -1,5 +1,5 @@
    53.4  /*
    53.5 - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
    53.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    53.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    53.8   *
    53.9   * This code is free software; you can redistribute it and/or modify it
   53.10 @@ -1348,7 +1348,7 @@
   53.11    ResultTypeFinder rtf(signature);
   53.12    TosState fr_tos = as_TosState(rtf.type());
   53.13    if (fr_tos != tos) {
   53.14 -    if (tos != itos || (fr_tos != btos && fr_tos != ctos && fr_tos != stos)) {
   53.15 +    if (tos != itos || (fr_tos != btos && fr_tos != ztos && fr_tos != ctos && fr_tos != stos)) {
   53.16        return JVMTI_ERROR_TYPE_MISMATCH;
   53.17      }
   53.18    }
    54.1 --- a/src/share/vm/prims/jvmtiExport.cpp	Tue Mar 29 23:01:10 2016 +0100
    54.2 +++ b/src/share/vm/prims/jvmtiExport.cpp	Tue Apr 05 08:55:39 2016 -0700
    54.3 @@ -1,5 +1,5 @@
    54.4  /*
    54.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
    54.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
    54.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    54.8   *
    54.9   * This code is free software; you can redistribute it and/or modify it
   54.10 @@ -1588,7 +1588,7 @@
   54.11    address location, KlassHandle field_klass, Handle object, jfieldID field,
   54.12    char sig_type, jvalue *value) {
   54.13  
   54.14 -  if (sig_type == 'I' || sig_type == 'Z' || sig_type == 'C' || sig_type == 'S') {
   54.15 +  if (sig_type == 'I' || sig_type == 'Z' || sig_type == 'B' || sig_type == 'C' || sig_type == 'S') {
   54.16      // 'I' instructions are used for byte, char, short and int.
   54.17      // determine which it really is, and convert
   54.18      fieldDescriptor fd;
    55.1 --- a/src/share/vm/prims/unsafe.cpp	Tue Mar 29 23:01:10 2016 +0100
    55.2 +++ b/src/share/vm/prims/unsafe.cpp	Tue Apr 05 08:55:39 2016 -0700
    55.3 @@ -1,5 +1,5 @@
    55.4  /*
    55.5 - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
    55.6 + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    55.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    55.8   *
    55.9   * This code is free software; you can redistribute it and/or modify it
   55.10 @@ -156,13 +156,22 @@
   55.11  
   55.12  ///// Data in the Java heap.
   55.13  
   55.14 +#define truncate_jboolean(x) ((x) & 1)
   55.15 +#define truncate_jbyte(x) (x)
   55.16 +#define truncate_jshort(x) (x)
   55.17 +#define truncate_jchar(x) (x)
   55.18 +#define truncate_jint(x) (x)
   55.19 +#define truncate_jlong(x) (x)
   55.20 +#define truncate_jfloat(x) (x)
   55.21 +#define truncate_jdouble(x) (x)
   55.22 +
   55.23  #define GET_FIELD(obj, offset, type_name, v) \
   55.24    oop p = JNIHandles::resolve(obj); \
   55.25    type_name v = *(type_name*)index_oop_from_field_offset_long(p, offset)
   55.26  
   55.27  #define SET_FIELD(obj, offset, type_name, x) \
   55.28    oop p = JNIHandles::resolve(obj); \
   55.29 -  *(type_name*)index_oop_from_field_offset_long(p, offset) = x
   55.30 +  *(type_name*)index_oop_from_field_offset_long(p, offset) = truncate_##type_name(x)
   55.31  
   55.32  #define GET_FIELD_VOLATILE(obj, offset, type_name, v) \
   55.33    oop p = JNIHandles::resolve(obj); \
   55.34 @@ -173,7 +182,7 @@
   55.35  
   55.36  #define SET_FIELD_VOLATILE(obj, offset, type_name, x) \
   55.37    oop p = JNIHandles::resolve(obj); \
   55.38 -  OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), x);
   55.39 +  OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), truncate_##type_name(x));
   55.40  
   55.41  // Macros for oops that check UseCompressedOops
   55.42  
    56.1 --- a/src/share/vm/runtime/deoptimization.cpp	Tue Mar 29 23:01:10 2016 +0100
    56.2 +++ b/src/share/vm/runtime/deoptimization.cpp	Tue Apr 05 08:55:39 2016 -0700
    56.3 @@ -1,5 +1,5 @@
    56.4  /*
    56.5 - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
    56.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    56.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    56.8   *
    56.9   * This code is free software; you can redistribute it and/or modify it
   56.10 @@ -847,13 +847,25 @@
   56.11        _obj->int_field_put(offset, (jint)*((jint*)&val));
   56.12        break;
   56.13  
   56.14 -    case T_SHORT: case T_CHAR: // 2 bytes
   56.15 +    case T_SHORT:
   56.16        assert(value->type() == T_INT, "Agreement.");
   56.17        val = value->get_int();
   56.18        _obj->short_field_put(offset, (jshort)*((jint*)&val));
   56.19        break;
   56.20  
   56.21 -    case T_BOOLEAN: case T_BYTE: // 1 byte
   56.22 +    case T_CHAR:
   56.23 +      assert(value->type() == T_INT, "Agreement.");
   56.24 +      val = value->get_int();
   56.25 +      _obj->char_field_put(offset, (jchar)*((jint*)&val));
   56.26 +      break;
   56.27 +
   56.28 +    case T_BYTE:
   56.29 +      assert(value->type() == T_INT, "Agreement.");
   56.30 +      val = value->get_int();
   56.31 +      _obj->byte_field_put(offset, (jbyte)*((jint*)&val));
   56.32 +      break;
   56.33 +
   56.34 +    case T_BOOLEAN:
   56.35        assert(value->type() == T_INT, "Agreement.");
   56.36        val = value->get_int();
   56.37        _obj->bool_field_put(offset, (jboolean)*((jint*)&val));
   56.38 @@ -899,13 +911,25 @@
   56.39        obj->int_at_put(index, (jint)*((jint*)&val));
   56.40        break;
   56.41  
   56.42 -    case T_SHORT: case T_CHAR: // 2 bytes
   56.43 +    case T_SHORT:
   56.44        assert(value->type() == T_INT, "Agreement.");
   56.45        val = value->get_int();
   56.46        obj->short_at_put(index, (jshort)*((jint*)&val));
   56.47        break;
   56.48  
   56.49 -    case T_BOOLEAN: case T_BYTE: // 1 byte
   56.50 +    case T_CHAR:
   56.51 +      assert(value->type() == T_INT, "Agreement.");
   56.52 +      val = value->get_int();
   56.53 +      obj->char_at_put(index, (jchar)*((jint*)&val));
   56.54 +      break;
   56.55 +
   56.56 +    case T_BYTE:
   56.57 +      assert(value->type() == T_INT, "Agreement.");
   56.58 +      val = value->get_int();
   56.59 +      obj->byte_at_put(index, (jbyte)*((jint*)&val));
   56.60 +      break;
   56.61 +
   56.62 +    case T_BOOLEAN:
   56.63        assert(value->type() == T_INT, "Agreement.");
   56.64        val = value->get_int();
   56.65        obj->bool_at_put(index, (jboolean)*((jint*)&val));
    57.1 --- a/src/share/vm/runtime/reflection.cpp	Tue Mar 29 23:01:10 2016 +0100
    57.2 +++ b/src/share/vm/runtime/reflection.cpp	Tue Apr 05 08:55:39 2016 -0700
    57.3 @@ -1,5 +1,5 @@
    57.4  /*
    57.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    57.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    57.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    57.8   *
    57.9   * This code is free software; you can redistribute it and/or modify it
   57.10 @@ -1101,7 +1101,7 @@
   57.11  void Reflection::narrow(jvalue* value, BasicType narrow_type, TRAPS) {
   57.12    switch (narrow_type) {
   57.13      case T_BOOLEAN:
   57.14 -     value->z = (jboolean) value->i;
   57.15 +     value->z = (jboolean) (value->i & 1);
   57.16       return;
   57.17      case T_BYTE:
   57.18       value->b = (jbyte) value->i;
    58.1 --- a/src/share/vm/utilities/globalDefinitions.hpp	Tue Mar 29 23:01:10 2016 +0100
    58.2 +++ b/src/share/vm/utilities/globalDefinitions.hpp	Tue Apr 05 08:55:39 2016 -0700
    58.3 @@ -1,5 +1,5 @@
    58.4  /*
    58.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    58.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    58.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    58.8   *
    58.9   * This code is free software; you can redistribute it and/or modify it
   58.10 @@ -796,14 +796,15 @@
   58.11  
   58.12  enum TosState {         // describes the tos cache contents
   58.13    btos = 0,             // byte, bool tos cached
   58.14 -  ctos = 1,             // char tos cached
   58.15 -  stos = 2,             // short tos cached
   58.16 -  itos = 3,             // int tos cached
   58.17 -  ltos = 4,             // long tos cached
   58.18 -  ftos = 5,             // float tos cached
   58.19 -  dtos = 6,             // double tos cached
   58.20 -  atos = 7,             // object cached
   58.21 -  vtos = 8,             // tos not cached
   58.22 +  ztos = 1,             // byte, bool tos cached
   58.23 +  ctos = 2,             // char tos cached
   58.24 +  stos = 3,             // short tos cached
   58.25 +  itos = 4,             // int tos cached
   58.26 +  ltos = 5,             // long tos cached
   58.27 +  ftos = 6,             // float tos cached
   58.28 +  dtos = 7,             // double tos cached
   58.29 +  atos = 8,             // object cached
   58.30 +  vtos = 9,             // tos not cached
   58.31    number_of_states,
   58.32    ilgl                  // illegal state: should not occur
   58.33  };
   58.34 @@ -812,7 +813,7 @@
   58.35  inline TosState as_TosState(BasicType type) {
   58.36    switch (type) {
   58.37      case T_BYTE   : return btos;
   58.38 -    case T_BOOLEAN: return btos; // FIXME: Add ztos
   58.39 +    case T_BOOLEAN: return ztos;
   58.40      case T_CHAR   : return ctos;
   58.41      case T_SHORT  : return stos;
   58.42      case T_INT    : return itos;
   58.43 @@ -828,8 +829,8 @@
   58.44  
   58.45  inline BasicType as_BasicType(TosState state) {
   58.46    switch (state) {
   58.47 -    //case ztos: return T_BOOLEAN;//FIXME
   58.48      case btos : return T_BYTE;
   58.49 +    case ztos : return T_BOOLEAN;
   58.50      case ctos : return T_CHAR;
   58.51      case stos : return T_SHORT;
   58.52      case itos : return T_INT;

mercurial