Merge

Fri, 27 Sep 2013 12:43:51 -0700

author
adlertz
date
Fri, 27 Sep 2013 12:43:51 -0700
changeset 5793
a07c25e4f67e
parent 5764
f637d4dc21bb
parent 5791
c9ccd7b85f20
child 5794
1c3486050433

Merge

src/share/vm/prims/jvm.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/arguments.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/globals.hpp file | annotate | diff | comparison | revisions
src/share/vm/services/attachListener.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Thu Sep 26 08:48:15 2013 +0200
     1.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Fri Sep 27 12:43:51 2013 -0700
     1.3 @@ -134,15 +134,13 @@
     1.4       private String type;
     1.5       private String name;
     1.6       private Address addr;
     1.7 -     private String kind;
     1.8 -     private int origin;
     1.9 +     private int flags;
    1.10  
    1.11 -     private Flag(String type, String name, Address addr, String kind, int origin) {
    1.12 +     private Flag(String type, String name, Address addr, int flags) {
    1.13          this.type = type;
    1.14          this.name = name;
    1.15          this.addr = addr;
    1.16 -        this.kind = kind;
    1.17 -        this.origin = origin;
    1.18 +        this.flags = flags;
    1.19       }
    1.20  
    1.21       public String getType() {
    1.22 @@ -157,12 +155,8 @@
    1.23          return addr;
    1.24       }
    1.25  
    1.26 -     public String getKind() {
    1.27 -        return kind;
    1.28 -     }
    1.29 -
    1.30       public int getOrigin() {
    1.31 -        return origin;
    1.32 +        return flags & 0xF;  // XXX can we get the mask bits from somewhere?
    1.33       }
    1.34  
    1.35       public boolean isBool() {
    1.36 @@ -173,8 +167,7 @@
    1.37          if (Assert.ASSERTS_ENABLED) {
    1.38             Assert.that(isBool(), "not a bool flag!");
    1.39          }
    1.40 -        return addr.getCIntegerAt(0, boolType.getSize(), boolType.isUnsigned())
    1.41 -               != 0;
    1.42 +        return addr.getCIntegerAt(0, boolType.getSize(), boolType.isUnsigned()) != 0;
    1.43       }
    1.44  
    1.45       public boolean isIntx() {
    1.46 @@ -843,11 +836,10 @@
    1.47  
    1.48      Address flagAddr = flagType.getAddressField("flags").getValue();
    1.49  
    1.50 -    AddressField typeFld = flagType.getAddressField("type");
    1.51 -    AddressField nameFld = flagType.getAddressField("name");
    1.52 -    AddressField addrFld = flagType.getAddressField("addr");
    1.53 -    AddressField kindFld = flagType.getAddressField("kind");
    1.54 -    CIntField originFld = new CIntField(flagType.getCIntegerField("origin"), 0);
    1.55 +    AddressField typeFld = flagType.getAddressField("_type");
    1.56 +    AddressField nameFld = flagType.getAddressField("_name");
    1.57 +    AddressField addrFld = flagType.getAddressField("_addr");
    1.58 +    CIntField flagsFld = new CIntField(flagType.getCIntegerField("_flags"), 0);
    1.59  
    1.60      long flagSize = flagType.getSize(); // sizeof(Flag)
    1.61  
    1.62 @@ -856,9 +848,8 @@
    1.63        String type = CStringUtilities.getString(typeFld.getValue(flagAddr));
    1.64        String name = CStringUtilities.getString(nameFld.getValue(flagAddr));
    1.65        Address addr = addrFld.getValue(flagAddr);
    1.66 -      String kind = CStringUtilities.getString(kindFld.getValue(flagAddr));
    1.67 -      int origin = (int)originFld.getValue(flagAddr);
    1.68 -      commandLineFlags[f] = new Flag(type, name, addr, kind, origin);
    1.69 +      int flags = (int)flagsFld.getValue(flagAddr);
    1.70 +      commandLineFlags[f] = new Flag(type, name, addr, flags);
    1.71        flagAddr = flagAddr.addOffsetTo(flagSize);
    1.72      }
    1.73  
     2.1 --- a/src/cpu/sparc/vm/sparc.ad	Thu Sep 26 08:48:15 2013 +0200
     2.2 +++ b/src/cpu/sparc/vm/sparc.ad	Fri Sep 27 12:43:51 2013 -0700
     2.3 @@ -2018,6 +2018,15 @@
     2.4    return L7_REGP_mask();
     2.5  }
     2.6  
     2.7 +const RegMask Matcher::mathExactI_result_proj_mask() {
     2.8 +  return G1_REGI_mask();
     2.9 +}
    2.10 +
    2.11 +const RegMask Matcher::mathExactI_flags_proj_mask() {
    2.12 +  return INT_FLAGS_mask();
    2.13 +}
    2.14 +
    2.15 +
    2.16  %}
    2.17  
    2.18  
    2.19 @@ -4245,12 +4254,16 @@
    2.20      greater_equal(0xB);
    2.21      less_equal(0x2);
    2.22      greater(0xA);
    2.23 +    overflow(0x7);
    2.24 +    no_overflow(0xF);
    2.25    %}
    2.26  %}
    2.27  
    2.28  // Comparison Op, unsigned
    2.29  operand cmpOpU() %{
    2.30    match(Bool);
    2.31 +  predicate(n->as_Bool()->_test._test != BoolTest::overflow &&
    2.32 +            n->as_Bool()->_test._test != BoolTest::no_overflow);
    2.33  
    2.34    format %{ "u" %}
    2.35    interface(COND_INTER) %{
    2.36 @@ -4260,12 +4273,16 @@
    2.37      greater_equal(0xD);
    2.38      less_equal(0x4);
    2.39      greater(0xC);
    2.40 +    overflow(0x7);
    2.41 +    no_overflow(0xF);
    2.42    %}
    2.43  %}
    2.44  
    2.45  // Comparison Op, pointer (same as unsigned)
    2.46  operand cmpOpP() %{
    2.47    match(Bool);
    2.48 +  predicate(n->as_Bool()->_test._test != BoolTest::overflow &&
    2.49 +            n->as_Bool()->_test._test != BoolTest::no_overflow);
    2.50  
    2.51    format %{ "p" %}
    2.52    interface(COND_INTER) %{
    2.53 @@ -4275,12 +4292,16 @@
    2.54      greater_equal(0xD);
    2.55      less_equal(0x4);
    2.56      greater(0xC);
    2.57 +    overflow(0x7);
    2.58 +    no_overflow(0xF);
    2.59    %}
    2.60  %}
    2.61  
    2.62  // Comparison Op, branch-register encoding
    2.63  operand cmpOp_reg() %{
    2.64    match(Bool);
    2.65 +  predicate(n->as_Bool()->_test._test != BoolTest::overflow &&
    2.66 +            n->as_Bool()->_test._test != BoolTest::no_overflow);
    2.67  
    2.68    format %{ "" %}
    2.69    interface(COND_INTER) %{
    2.70 @@ -4290,12 +4311,16 @@
    2.71      greater_equal(0x7);
    2.72      less_equal   (0x2);
    2.73      greater      (0x6);
    2.74 +    overflow(0x7); // not supported
    2.75 +    no_overflow(0xF); // not supported
    2.76    %}
    2.77  %}
    2.78  
    2.79  // Comparison Code, floating, unordered same as less
    2.80  operand cmpOpF() %{
    2.81    match(Bool);
    2.82 +  predicate(n->as_Bool()->_test._test != BoolTest::overflow &&
    2.83 +            n->as_Bool()->_test._test != BoolTest::no_overflow);
    2.84  
    2.85    format %{ "fl" %}
    2.86    interface(COND_INTER) %{
    2.87 @@ -4305,12 +4330,17 @@
    2.88      greater_equal(0xB);
    2.89      less_equal(0xE);
    2.90      greater(0x6);
    2.91 +
    2.92 +    overflow(0x7); // not supported
    2.93 +    no_overflow(0xF); // not supported
    2.94    %}
    2.95  %}
    2.96  
    2.97  // Used by long compare
    2.98  operand cmpOp_commute() %{
    2.99    match(Bool);
   2.100 +  predicate(n->as_Bool()->_test._test != BoolTest::overflow &&
   2.101 +            n->as_Bool()->_test._test != BoolTest::no_overflow);
   2.102  
   2.103    format %{ "" %}
   2.104    interface(COND_INTER) %{
   2.105 @@ -4320,6 +4350,8 @@
   2.106      greater_equal(0x2);
   2.107      less_equal(0xB);
   2.108      greater(0x3);
   2.109 +    overflow(0x7);
   2.110 +    no_overflow(0xF);
   2.111    %}
   2.112  %}
   2.113  
     3.1 --- a/src/cpu/x86/vm/x86_32.ad	Thu Sep 26 08:48:15 2013 +0200
     3.2 +++ b/src/cpu/x86/vm/x86_32.ad	Fri Sep 27 12:43:51 2013 -0700
     3.3 @@ -1534,6 +1534,14 @@
     3.4    return EBP_REG_mask();
     3.5  }
     3.6  
     3.7 +const RegMask Matcher::mathExactI_result_proj_mask() {
     3.8 +  return EAX_REG_mask();
     3.9 +}
    3.10 +
    3.11 +const RegMask Matcher::mathExactI_flags_proj_mask() {
    3.12 +  return INT_FLAGS_mask();
    3.13 +}
    3.14 +
    3.15  // Returns true if the high 32 bits of the value is known to be zero.
    3.16  bool is_operand_hi32_zero(Node* n) {
    3.17    int opc = n->Opcode();
    3.18 @@ -4922,6 +4930,8 @@
    3.19      greater_equal(0xD, "ge");
    3.20      less_equal(0xE, "le");
    3.21      greater(0xF, "g");
    3.22 +    overflow(0x0, "o");
    3.23 +    no_overflow(0x1, "no");
    3.24    %}
    3.25  %}
    3.26  
    3.27 @@ -4939,6 +4949,8 @@
    3.28      greater_equal(0x3, "nb");
    3.29      less_equal(0x6, "be");
    3.30      greater(0x7, "nbe");
    3.31 +    overflow(0x0, "o");
    3.32 +    no_overflow(0x1, "no");
    3.33    %}
    3.34  %}
    3.35  
    3.36 @@ -4957,6 +4969,8 @@
    3.37      greater_equal(0x3, "nb");
    3.38      less_equal(0x6, "be");
    3.39      greater(0x7, "nbe");
    3.40 +    overflow(0x0, "o");
    3.41 +    no_overflow(0x1, "no");
    3.42    %}
    3.43  %}
    3.44  
    3.45 @@ -4974,6 +4988,8 @@
    3.46      greater_equal(0x3, "nb");
    3.47      less_equal(0x6, "be");
    3.48      greater(0x7, "nbe");
    3.49 +    overflow(0x0, "o");
    3.50 +    no_overflow(0x1, "no");
    3.51    %}
    3.52  %}
    3.53  
    3.54 @@ -4981,6 +4997,8 @@
    3.55  operand cmpOp_fcmov() %{
    3.56    match(Bool);
    3.57  
    3.58 +  predicate(n->as_Bool()->_test._test != BoolTest::overflow &&
    3.59 +            n->as_Bool()->_test._test != BoolTest::no_overflow);
    3.60    format %{ "" %}
    3.61    interface(COND_INTER) %{
    3.62      equal        (0x0C8);
    3.63 @@ -4989,6 +5007,8 @@
    3.64      greater_equal(0x1C0);
    3.65      less_equal   (0x0D0);
    3.66      greater      (0x1D0);
    3.67 +    overflow(0x0, "o"); // not really supported by the instruction
    3.68 +    no_overflow(0x1, "no"); // not really supported by the instruction
    3.69    %}
    3.70  %}
    3.71  
    3.72 @@ -5004,6 +5024,8 @@
    3.73      greater_equal(0xE, "le");
    3.74      less_equal(0xD, "ge");
    3.75      greater(0xC, "l");
    3.76 +    overflow(0x0, "o");
    3.77 +    no_overflow(0x1, "no");
    3.78    %}
    3.79  %}
    3.80  
    3.81 @@ -7496,6 +7518,31 @@
    3.82  
    3.83  //----------Arithmetic Instructions--------------------------------------------
    3.84  //----------Addition Instructions----------------------------------------------
    3.85 +
    3.86 +instruct addExactI_rReg(eAXRegI dst, rRegI src, eFlagsReg cr)
    3.87 +%{
    3.88 +  match(AddExactI dst src);
    3.89 +  effect(DEF cr);
    3.90 +
    3.91 +  format %{ "ADD    $dst, $src\t# addExact int" %}
    3.92 +  ins_encode %{
    3.93 +    __ addl($dst$$Register, $src$$Register);
    3.94 +  %}
    3.95 +  ins_pipe(ialu_reg_reg);
    3.96 +%}
    3.97 +
    3.98 +instruct addExactI_rReg_imm(eAXRegI dst, immI src, eFlagsReg cr)
    3.99 +%{
   3.100 +  match(AddExactI dst src);
   3.101 +  effect(DEF cr);
   3.102 +
   3.103 +  format %{ "ADD    $dst, $src\t# addExact int" %}
   3.104 +  ins_encode %{
   3.105 +    __ addl($dst$$Register, $src$$constant);
   3.106 +  %}
   3.107 +  ins_pipe(ialu_reg_reg);
   3.108 +%}
   3.109 +
   3.110  // Integer Addition Instructions
   3.111  instruct addI_eReg(rRegI dst, rRegI src, eFlagsReg cr) %{
   3.112    match(Set dst (AddI dst src));
     4.1 --- a/src/cpu/x86/vm/x86_64.ad	Thu Sep 26 08:48:15 2013 +0200
     4.2 +++ b/src/cpu/x86/vm/x86_64.ad	Fri Sep 27 12:43:51 2013 -0700
     4.3 @@ -1649,6 +1649,14 @@
     4.4    return PTR_RBP_REG_mask();
     4.5  }
     4.6  
     4.7 +const RegMask Matcher::mathExactI_result_proj_mask() {
     4.8 +  return INT_RAX_REG_mask();
     4.9 +}
    4.10 +
    4.11 +const RegMask Matcher::mathExactI_flags_proj_mask() {
    4.12 +  return INT_FLAGS_mask();
    4.13 +}
    4.14 +
    4.15  %}
    4.16  
    4.17  //----------ENCODING BLOCK-----------------------------------------------------
    4.18 @@ -4133,6 +4141,8 @@
    4.19      greater_equal(0xD, "ge");
    4.20      less_equal(0xE, "le");
    4.21      greater(0xF, "g");
    4.22 +    overflow(0x0, "o");
    4.23 +    no_overflow(0x1, "no");
    4.24    %}
    4.25  %}
    4.26  
    4.27 @@ -4151,6 +4161,8 @@
    4.28      greater_equal(0x3, "nb");
    4.29      less_equal(0x6, "be");
    4.30      greater(0x7, "nbe");
    4.31 +    overflow(0x0, "o");
    4.32 +    no_overflow(0x1, "no");
    4.33    %}
    4.34  %}
    4.35  
    4.36 @@ -4170,6 +4182,8 @@
    4.37      greater_equal(0x3, "nb");
    4.38      less_equal(0x6, "be");
    4.39      greater(0x7, "nbe");
    4.40 +    overflow(0x0, "o");
    4.41 +    no_overflow(0x1, "no");
    4.42    %}
    4.43  %}
    4.44  
    4.45 @@ -4187,6 +4201,8 @@
    4.46      greater_equal(0x3, "nb");
    4.47      less_equal(0x6, "be");
    4.48      greater(0x7, "nbe");
    4.49 +    overflow(0x0, "o");
    4.50 +    no_overflow(0x1, "no");
    4.51    %}
    4.52  %}
    4.53  
    4.54 @@ -6922,6 +6938,30 @@
    4.55  //----------Arithmetic Instructions--------------------------------------------
    4.56  //----------Addition Instructions----------------------------------------------
    4.57  
    4.58 +instruct addExactI_rReg(rax_RegI dst, rRegI src, rFlagsReg cr)
    4.59 +%{
    4.60 +  match(AddExactI dst src);
    4.61 +  effect(DEF cr);
    4.62 +
    4.63 +  format %{ "addl    $dst, $src\t# addExact int" %}
    4.64 +  ins_encode %{
    4.65 +    __ addl($dst$$Register, $src$$Register);
    4.66 +  %}
    4.67 +  ins_pipe(ialu_reg_reg);
    4.68 +%}
    4.69 +
    4.70 +instruct addExactI_rReg_imm(rax_RegI dst, immI src, rFlagsReg cr)
    4.71 +%{
    4.72 +  match(AddExactI dst src);
    4.73 +  effect(DEF cr);
    4.74 +
    4.75 +  format %{ "addl    $dst, $src\t# addExact int" %}
    4.76 +  ins_encode %{
    4.77 +    __ addl($dst$$Register, $src$$constant);
    4.78 +  %}
    4.79 +  ins_pipe(ialu_reg_reg);
    4.80 +%}
    4.81 +
    4.82  instruct addI_rReg(rRegI dst, rRegI src, rFlagsReg cr)
    4.83  %{
    4.84    match(Set dst (AddI dst src));
     5.1 --- a/src/share/vm/adlc/adlparse.cpp	Thu Sep 26 08:48:15 2013 +0200
     5.2 +++ b/src/share/vm/adlc/adlparse.cpp	Fri Sep 27 12:43:51 2013 -0700
     5.3 @@ -3395,12 +3395,16 @@
     5.4    char *greater_equal;
     5.5    char *less_equal;
     5.6    char *greater;
     5.7 +  char *overflow;
     5.8 +  char *no_overflow;
     5.9    const char *equal_format = "eq";
    5.10    const char *not_equal_format = "ne";
    5.11    const char *less_format = "lt";
    5.12    const char *greater_equal_format = "ge";
    5.13    const char *less_equal_format = "le";
    5.14    const char *greater_format = "gt";
    5.15 +  const char *overflow_format = "o";
    5.16 +  const char *no_overflow_format = "no";
    5.17  
    5.18    if (_curchar != '%') {
    5.19      parse_err(SYNERR, "Missing '%%{' for 'cond_interface' block.\n");
    5.20 @@ -3437,6 +3441,12 @@
    5.21      else if ( strcmp(field,"greater") == 0 ) {
    5.22        greater = interface_field_parse(&greater_format);
    5.23      }
    5.24 +    else if ( strcmp(field,"overflow") == 0 ) {
    5.25 +      overflow = interface_field_parse(&overflow_format);
    5.26 +    }
    5.27 +    else if ( strcmp(field,"no_overflow") == 0 ) {
    5.28 +      no_overflow = interface_field_parse(&no_overflow_format);
    5.29 +    }
    5.30      else {
    5.31        parse_err(SYNERR, "Expected keyword, base|index|scale|disp,  or '%%}' ending interface.\n");
    5.32        return NULL;
    5.33 @@ -3455,7 +3465,9 @@
    5.34                                         less,          less_format,
    5.35                                         greater_equal, greater_equal_format,
    5.36                                         less_equal,    less_equal_format,
    5.37 -                                       greater,       greater_format);
    5.38 +                                       greater,       greater_format,
    5.39 +                                       overflow,      overflow_format,
    5.40 +                                       no_overflow,   no_overflow_format);
    5.41    return inter;
    5.42  }
    5.43  
     6.1 --- a/src/share/vm/adlc/archDesc.cpp	Thu Sep 26 08:48:15 2013 +0200
     6.2 +++ b/src/share/vm/adlc/archDesc.cpp	Fri Sep 27 12:43:51 2013 -0700
     6.3 @@ -1192,6 +1192,8 @@
     6.4           || strcmp(idealName,"CmpF") == 0
     6.5           || strcmp(idealName,"FastLock") == 0
     6.6           || strcmp(idealName,"FastUnlock") == 0
     6.7 +         || strcmp(idealName,"AddExactI") == 0
     6.8 +         || strcmp(idealName,"FlagsProj") == 0
     6.9           || strcmp(idealName,"Bool") == 0
    6.10           || strcmp(idealName,"Binary") == 0 ) {
    6.11        // Removed ConI from the must_clone list.  CPUs that cannot use
     7.1 --- a/src/share/vm/adlc/formssel.cpp	Thu Sep 26 08:48:15 2013 +0200
     7.2 +++ b/src/share/vm/adlc/formssel.cpp	Fri Sep 27 12:43:51 2013 -0700
     7.3 @@ -2757,14 +2757,18 @@
     7.4                               const char* less,          const char* less_format,
     7.5                               const char* greater_equal, const char* greater_equal_format,
     7.6                               const char* less_equal,    const char* less_equal_format,
     7.7 -                             const char* greater,       const char* greater_format)
     7.8 +                             const char* greater,       const char* greater_format,
     7.9 +                             const char* overflow,      const char* overflow_format,
    7.10 +                             const char* no_overflow,   const char* no_overflow_format)
    7.11    : Interface("COND_INTER"),
    7.12      _equal(equal),                 _equal_format(equal_format),
    7.13      _not_equal(not_equal),         _not_equal_format(not_equal_format),
    7.14      _less(less),                   _less_format(less_format),
    7.15      _greater_equal(greater_equal), _greater_equal_format(greater_equal_format),
    7.16      _less_equal(less_equal),       _less_equal_format(less_equal_format),
    7.17 -    _greater(greater),             _greater_format(greater_format) {
    7.18 +    _greater(greater),             _greater_format(greater_format),
    7.19 +    _overflow(overflow),           _overflow_format(overflow_format),
    7.20 +    _no_overflow(no_overflow),     _no_overflow_format(no_overflow_format) {
    7.21  }
    7.22  CondInterface::~CondInterface() {
    7.23    // not owner of any character arrays
    7.24 @@ -2777,12 +2781,14 @@
    7.25  // Write info to output files
    7.26  void CondInterface::output(FILE *fp) {
    7.27    Interface::output(fp);
    7.28 -  if ( _equal  != NULL )     fprintf(fp," equal       == %s\n", _equal);
    7.29 -  if ( _not_equal  != NULL ) fprintf(fp," not_equal   == %s\n", _not_equal);
    7.30 -  if ( _less  != NULL )      fprintf(fp," less        == %s\n", _less);
    7.31 -  if ( _greater_equal  != NULL ) fprintf(fp," greater_equal   == %s\n", _greater_equal);
    7.32 -  if ( _less_equal  != NULL ) fprintf(fp," less_equal  == %s\n", _less_equal);
    7.33 -  if ( _greater  != NULL )    fprintf(fp," greater     == %s\n", _greater);
    7.34 +  if ( _equal  != NULL )     fprintf(fp," equal        == %s\n", _equal);
    7.35 +  if ( _not_equal  != NULL ) fprintf(fp," not_equal    == %s\n", _not_equal);
    7.36 +  if ( _less  != NULL )      fprintf(fp," less         == %s\n", _less);
    7.37 +  if ( _greater_equal  != NULL ) fprintf(fp," greater_equal    == %s\n", _greater_equal);
    7.38 +  if ( _less_equal  != NULL ) fprintf(fp," less_equal   == %s\n", _less_equal);
    7.39 +  if ( _greater  != NULL )    fprintf(fp," greater      == %s\n", _greater);
    7.40 +  if ( _overflow != NULL )    fprintf(fp," overflow     == %s\n", _overflow);
    7.41 +  if ( _no_overflow != NULL ) fprintf(fp," no_overflow  == %s\n", _no_overflow);
    7.42    // fprintf(fp,"\n");
    7.43  }
    7.44  
     8.1 --- a/src/share/vm/adlc/formssel.hpp	Thu Sep 26 08:48:15 2013 +0200
     8.2 +++ b/src/share/vm/adlc/formssel.hpp	Fri Sep 27 12:43:51 2013 -0700
     8.3 @@ -798,12 +798,16 @@
     8.4    const char *_greater_equal;
     8.5    const char *_less_equal;
     8.6    const char *_greater;
     8.7 +  const char *_overflow;
     8.8 +  const char *_no_overflow;
     8.9    const char *_equal_format;
    8.10    const char *_not_equal_format;
    8.11    const char *_less_format;
    8.12    const char *_greater_equal_format;
    8.13    const char *_less_equal_format;
    8.14    const char *_greater_format;
    8.15 +  const char *_overflow_format;
    8.16 +  const char *_no_overflow_format;
    8.17  
    8.18    // Public Methods
    8.19    CondInterface(const char* equal,         const char* equal_format,
    8.20 @@ -811,7 +815,9 @@
    8.21                  const char* less,          const char* less_format,
    8.22                  const char* greater_equal, const char* greater_equal_format,
    8.23                  const char* less_equal,    const char* less_equal_format,
    8.24 -                const char* greater,       const char* greater_format);
    8.25 +                const char* greater,       const char* greater_format,
    8.26 +                const char* overflow,      const char* overflow_format,
    8.27 +                const char* no_overflow,   const char* no_overflow_format);
    8.28    ~CondInterface();
    8.29  
    8.30    void dump();
     9.1 --- a/src/share/vm/adlc/output_h.cpp	Thu Sep 26 08:48:15 2013 +0200
     9.2 +++ b/src/share/vm/adlc/output_h.cpp	Fri Sep 27 12:43:51 2013 -0700
     9.3 @@ -388,6 +388,8 @@
     9.4    fprintf(fp, "  else if( _c%d == BoolTest::ge ) st->print(\"%s\");\n",i,cond->_greater_equal_format);
     9.5    fprintf(fp, "  else if( _c%d == BoolTest::lt ) st->print(\"%s\");\n",i,cond->_less_format);
     9.6    fprintf(fp, "  else if( _c%d == BoolTest::gt ) st->print(\"%s\");\n",i,cond->_greater_format);
     9.7 +  fprintf(fp, "  else if( _c%d == BoolTest::overflow ) st->print(\"%s\");\n",i,cond->_overflow_format);
     9.8 +  fprintf(fp, "  else if( _c%d == BoolTest::no_overflow ) st->print(\"%s\");\n",i,cond->_no_overflow_format);
     9.9  }
    9.10  
    9.11  // Output code that dumps constant values, increment "i" if type is constant
    9.12 @@ -1208,6 +1210,8 @@
    9.13        fprintf(fp,"    case  BoolTest::ne : return not_equal();\n");
    9.14        fprintf(fp,"    case  BoolTest::le : return less_equal();\n");
    9.15        fprintf(fp,"    case  BoolTest::ge : return greater_equal();\n");
    9.16 +      fprintf(fp,"    case  BoolTest::overflow : return overflow();\n");
    9.17 +      fprintf(fp,"    case  BoolTest::no_overflow: return no_overflow();\n");
    9.18        fprintf(fp,"    default : ShouldNotReachHere(); return 0;\n");
    9.19        fprintf(fp,"    }\n");
    9.20        fprintf(fp,"  };\n");
    9.21 @@ -1373,6 +1377,14 @@
    9.22          if( greater != NULL ) {
    9.23            define_oper_interface(fp, *oper, _globalNames, "greater", greater);
    9.24          }
    9.25 +        const char *overflow = cInterface->_overflow;
    9.26 +        if( overflow != NULL ) {
    9.27 +          define_oper_interface(fp, *oper, _globalNames, "overflow", overflow);
    9.28 +        }
    9.29 +        const char *no_overflow = cInterface->_no_overflow;
    9.30 +        if( no_overflow != NULL ) {
    9.31 +          define_oper_interface(fp, *oper, _globalNames, "no_overflow", no_overflow);
    9.32 +        }
    9.33        } // end Conditional Interface
    9.34        // Check if it is a Constant Interface
    9.35        else if (oper->_interface->is_ConstInterface() != NULL ) {
    10.1 --- a/src/share/vm/classfile/vmSymbols.hpp	Thu Sep 26 08:48:15 2013 +0200
    10.2 +++ b/src/share/vm/classfile/vmSymbols.hpp	Fri Sep 27 12:43:51 2013 -0700
    10.3 @@ -631,6 +631,10 @@
    10.4    do_name(log_name,"log")       do_name(log10_name,"log10")     do_name(pow_name,"pow")                                 \
    10.5    do_name(exp_name,"exp")       do_name(min_name,"min")         do_name(max_name,"max")                                 \
    10.6                                                                                                                          \
    10.7 +  do_name(addExact_name,"addExact")                                                                                     \
    10.8 +  do_name(subtractExact_name,"subtractExact")                                                                           \
    10.9 +  do_name(multiplyExact_name,"multiplyExact")                                                                           \
   10.10 +                                                                                                                        \
   10.11    do_intrinsic(_dabs,                     java_lang_Math,         abs_name,   double_double_signature,           F_S)   \
   10.12    do_intrinsic(_dsin,                     java_lang_Math,         sin_name,   double_double_signature,           F_S)   \
   10.13    do_intrinsic(_dcos,                     java_lang_Math,         cos_name,   double_double_signature,           F_S)   \
   10.14 @@ -643,6 +647,7 @@
   10.15    do_intrinsic(_dexp,                     java_lang_Math,         exp_name,   double_double_signature,           F_S)   \
   10.16    do_intrinsic(_min,                      java_lang_Math,         min_name,   int2_int_signature,                F_S)   \
   10.17    do_intrinsic(_max,                      java_lang_Math,         max_name,   int2_int_signature,                F_S)   \
   10.18 +  do_intrinsic(_addExact,                 java_lang_Math,         addExact_name, int2_int_signature,             F_S)   \
   10.19                                                                                                                          \
   10.20    do_intrinsic(_floatToRawIntBits,        java_lang_Float,        floatToRawIntBits_name,   float_int_signature, F_S)   \
   10.21     do_name(     floatToRawIntBits_name,                          "floatToRawIntBits")                                   \
    11.1 --- a/src/share/vm/opto/c2_globals.hpp	Thu Sep 26 08:48:15 2013 +0200
    11.2 +++ b/src/share/vm/opto/c2_globals.hpp	Fri Sep 27 12:43:51 2013 -0700
    11.3 @@ -636,7 +636,9 @@
    11.4                                                                              \
    11.5    diagnostic(bool, OptimizeExpensiveOps, true,                              \
    11.6            "Find best control for expensive operations")                     \
    11.7 -
    11.8 +                                                                            \
    11.9 +  product(bool, UseMathExactIntrinsics, true,                               \
   11.10 +          "Enables intrinsification of various java.lang.Math funcitons")
   11.11  
   11.12  C2_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_EXPERIMENTAL_FLAG, DECLARE_NOTPRODUCT_FLAG)
   11.13  
    12.1 --- a/src/share/vm/opto/classes.cpp	Thu Sep 26 08:48:15 2013 +0200
    12.2 +++ b/src/share/vm/opto/classes.cpp	Fri Sep 27 12:43:51 2013 -0700
    12.3 @@ -32,6 +32,7 @@
    12.4  #include "opto/loopnode.hpp"
    12.5  #include "opto/machnode.hpp"
    12.6  #include "opto/memnode.hpp"
    12.7 +#include "opto/mathexactnode.hpp"
    12.8  #include "opto/mulnode.hpp"
    12.9  #include "opto/multnode.hpp"
   12.10  #include "opto/node.hpp"
    13.1 --- a/src/share/vm/opto/classes.hpp	Thu Sep 26 08:48:15 2013 +0200
    13.2 +++ b/src/share/vm/opto/classes.hpp	Fri Sep 27 12:43:51 2013 -0700
    13.3 @@ -29,6 +29,7 @@
    13.4  macro(AbsF)
    13.5  macro(AbsI)
    13.6  macro(AddD)
    13.7 +macro(AddExactI)
    13.8  macro(AddF)
    13.9  macro(AddI)
   13.10  macro(AddL)
   13.11 @@ -133,6 +134,7 @@
   13.12  macro(ExpD)
   13.13  macro(FastLock)
   13.14  macro(FastUnlock)
   13.15 +macro(FlagsProj)
   13.16  macro(Goto)
   13.17  macro(Halt)
   13.18  macro(If)
   13.19 @@ -167,6 +169,7 @@
   13.20  macro(LoopLimit)
   13.21  macro(Mach)
   13.22  macro(MachProj)
   13.23 +macro(MathExact)
   13.24  macro(MaxI)
   13.25  macro(MemBarAcquire)
   13.26  macro(MemBarAcquireLock)
    14.1 --- a/src/share/vm/opto/ifnode.cpp	Thu Sep 26 08:48:15 2013 +0200
    14.2 +++ b/src/share/vm/opto/ifnode.cpp	Fri Sep 27 12:43:51 2013 -0700
    14.3 @@ -76,6 +76,7 @@
    14.4    if( !i1->is_Bool() ) return NULL;
    14.5    BoolNode *b = i1->as_Bool();
    14.6    Node *cmp = b->in(1);
    14.7 +  if( cmp->is_FlagsProj() ) return NULL;
    14.8    if( !cmp->is_Cmp() ) return NULL;
    14.9    i1 = cmp->in(1);
   14.10    if( i1 == NULL || !i1->is_Phi() ) return NULL;
    15.1 --- a/src/share/vm/opto/lcm.cpp	Thu Sep 26 08:48:15 2013 +0200
    15.2 +++ b/src/share/vm/opto/lcm.cpp	Fri Sep 27 12:43:51 2013 -0700
    15.3 @@ -472,6 +472,13 @@
    15.4            break;
    15.5          }
    15.6  
    15.7 +        // For nodes that produce a FlagsProj, make the node adjacent to the
    15.8 +        // use of the FlagsProj
    15.9 +        if (use->is_FlagsProj() && get_block_for_node(use) == block) {
   15.10 +          found_machif = true;
   15.11 +          break;
   15.12 +        }
   15.13 +
   15.14          // More than this instruction pending for successor to be ready,
   15.15          // don't choose this if other opportunities are ready
   15.16          if (ready_cnt.at(use->_idx) > 1)
    16.1 --- a/src/share/vm/opto/library_call.cpp	Thu Sep 26 08:48:15 2013 +0200
    16.2 +++ b/src/share/vm/opto/library_call.cpp	Fri Sep 27 12:43:51 2013 -0700
    16.3 @@ -32,6 +32,7 @@
    16.4  #include "opto/callGenerator.hpp"
    16.5  #include "opto/cfgnode.hpp"
    16.6  #include "opto/idealKit.hpp"
    16.7 +#include "opto/mathexactnode.hpp"
    16.8  #include "opto/mulnode.hpp"
    16.9  #include "opto/parse.hpp"
   16.10  #include "opto/runtime.hpp"
   16.11 @@ -199,6 +200,8 @@
   16.12    bool inline_math_native(vmIntrinsics::ID id);
   16.13    bool inline_trig(vmIntrinsics::ID id);
   16.14    bool inline_math(vmIntrinsics::ID id);
   16.15 +  bool inline_math_mathExact(Node* math);
   16.16 +  bool inline_math_addExact();
   16.17    bool inline_exp();
   16.18    bool inline_pow();
   16.19    void finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName);
   16.20 @@ -498,6 +501,15 @@
   16.21      if (!UseCRC32Intrinsics) return NULL;
   16.22      break;
   16.23  
   16.24 +  case vmIntrinsics::_addExact:
   16.25 +    if (!Matcher::match_rule_supported(Op_AddExactI)) {
   16.26 +      return NULL;
   16.27 +    }
   16.28 +    if (!UseMathExactIntrinsics) {
   16.29 +      return NULL;
   16.30 +    }
   16.31 +    break;
   16.32 +
   16.33   default:
   16.34      assert(id <= vmIntrinsics::LAST_COMPILER_INLINE, "caller responsibility");
   16.35      assert(id != vmIntrinsics::_Object_init && id != vmIntrinsics::_invoke, "enum out of order?");
   16.36 @@ -668,6 +680,8 @@
   16.37    case vmIntrinsics::_min:
   16.38    case vmIntrinsics::_max:                      return inline_min_max(intrinsic_id());
   16.39  
   16.40 +  case vmIntrinsics::_addExact:                 return inline_math_addExact();
   16.41 +
   16.42    case vmIntrinsics::_arraycopy:                return inline_arraycopy();
   16.43  
   16.44    case vmIntrinsics::_compareTo:                return inline_string_compareTo();
   16.45 @@ -1911,6 +1925,45 @@
   16.46    return true;
   16.47  }
   16.48  
   16.49 +bool LibraryCallKit::inline_math_mathExact(Node* math) {
   16.50 +  Node* result = _gvn.transform( new(C) ProjNode(math, MathExactNode::result_proj_node));
   16.51 +  Node* flags = _gvn.transform( new(C) FlagsProjNode(math, MathExactNode::flags_proj_node));
   16.52 +
   16.53 +  Node* bol = _gvn.transform( new (C) BoolNode(flags, BoolTest::overflow) );
   16.54 +  IfNode* check = create_and_map_if(control(), bol, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN);
   16.55 +  Node* fast_path = _gvn.transform( new (C) IfFalseNode(check));
   16.56 +  Node* slow_path = _gvn.transform( new (C) IfTrueNode(check) );
   16.57 +
   16.58 +  {
   16.59 +    PreserveJVMState pjvms(this);
   16.60 +    PreserveReexecuteState preexecs(this);
   16.61 +    jvms()->set_should_reexecute(true);
   16.62 +
   16.63 +    set_control(slow_path);
   16.64 +    set_i_o(i_o());
   16.65 +
   16.66 +    uncommon_trap(Deoptimization::Reason_intrinsic,
   16.67 +                  Deoptimization::Action_none);
   16.68 +  }
   16.69 +
   16.70 +  set_control(fast_path);
   16.71 +  set_result(result);
   16.72 +  return true;
   16.73 +}
   16.74 +
   16.75 +bool LibraryCallKit::inline_math_addExact() {
   16.76 +  Node* arg1 = argument(0);
   16.77 +  Node* arg2 = argument(1);
   16.78 +
   16.79 +  Node* add = _gvn.transform( new(C) AddExactINode(NULL, arg1, arg2) );
   16.80 +  if (add->Opcode() == Op_AddExactI) {
   16.81 +    return inline_math_mathExact(add);
   16.82 +  } else {
   16.83 +    set_result(add);
   16.84 +  }
   16.85 +  return true;
   16.86 +}
   16.87 +
   16.88  Node*
   16.89  LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) {
   16.90    // These are the candidate return value:
    17.1 --- a/src/share/vm/opto/loopTransform.cpp	Thu Sep 26 08:48:15 2013 +0200
    17.2 +++ b/src/share/vm/opto/loopTransform.cpp	Fri Sep 27 12:43:51 2013 -0700
    17.3 @@ -776,6 +776,9 @@
    17.4          continue; // not RC
    17.5  
    17.6        Node *cmp = bol->in(1);
    17.7 +      if (cmp->is_FlagsProj()) {
    17.8 +        continue;
    17.9 +      }
   17.10  
   17.11        Node *rc_exp = cmp->in(1);
   17.12        Node *limit = cmp->in(2);
    18.1 --- a/src/share/vm/opto/loopopts.cpp	Thu Sep 26 08:48:15 2013 +0200
    18.2 +++ b/src/share/vm/opto/loopopts.cpp	Fri Sep 27 12:43:51 2013 -0700
    18.3 @@ -2355,7 +2355,8 @@
    18.4          opc == Op_Catch     ||
    18.5          opc == Op_CatchProj ||
    18.6          opc == Op_Jump      ||
    18.7 -        opc == Op_JumpProj) {
    18.8 +        opc == Op_JumpProj  ||
    18.9 +        opc == Op_FlagsProj) {
   18.10  #if !defined(PRODUCT)
   18.11        if (TracePartialPeeling) {
   18.12          tty->print_cr("\nExit control too complex: lp: %d", head->_idx);
    19.1 --- a/src/share/vm/opto/matcher.cpp	Thu Sep 26 08:48:15 2013 +0200
    19.2 +++ b/src/share/vm/opto/matcher.cpp	Fri Sep 27 12:43:51 2013 -0700
    19.3 @@ -1964,6 +1964,7 @@
    19.4        case Op_Catch:
    19.5        case Op_CatchProj:
    19.6        case Op_CProj:
    19.7 +      case Op_FlagsProj:
    19.8        case Op_JumpProj:
    19.9        case Op_JProj:
   19.10        case Op_NeverBranch:
    20.1 --- a/src/share/vm/opto/matcher.hpp	Thu Sep 26 08:48:15 2013 +0200
    20.2 +++ b/src/share/vm/opto/matcher.hpp	Fri Sep 27 12:43:51 2013 -0700
    20.3 @@ -337,6 +337,9 @@
    20.4    // Register for MODL projection of divmodL
    20.5    static RegMask modL_proj_mask();
    20.6  
    20.7 +  static const RegMask mathExactI_result_proj_mask();
    20.8 +  static const RegMask mathExactI_flags_proj_mask();
    20.9 +
   20.10    // Use hardware DIV instruction when it is faster than
   20.11    // a code which use multiply for division by constant.
   20.12    static bool use_asm_for_ldiv_by_con( jlong divisor );
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/src/share/vm/opto/mathexactnode.cpp	Fri Sep 27 12:43:51 2013 -0700
    21.3 @@ -0,0 +1,143 @@
    21.4 +/*
    21.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 + *
    21.8 + * This code is free software; you can redistribute it and/or modify it
    21.9 + * under the terms of the GNU General Public License version 2 only, as
   21.10 + * published by the Free Software Foundation.
   21.11 + *
   21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 + * version 2 for more details (a copy is included in the LICENSE file that
   21.16 + * accompanied this code).
   21.17 + *
   21.18 + * You should have received a copy of the GNU General Public License version
   21.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 + *
   21.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   21.23 + * or visit www.oracle.com if you need additional information or have any
   21.24 + * questions.
   21.25 + *
   21.26 + */
   21.27 +
   21.28 +#include "precompiled.hpp"
   21.29 +#include "memory/allocation.inline.hpp"
   21.30 +#include "opto/addnode.hpp"
   21.31 +#include "opto/machnode.hpp"
   21.32 +#include "opto/mathexactnode.hpp"
   21.33 +#include "opto/matcher.hpp"
   21.34 +#include "opto/subnode.hpp"
   21.35 +
   21.36 +MathExactNode::MathExactNode(Node* ctrl, Node* n1, Node* n2) : MultiNode(3) {
   21.37 +  init_req(0, ctrl);
   21.38 +  init_req(1, n1);
   21.39 +  init_req(2, n2);
   21.40 +}
   21.41 +
   21.42 +Node* AddExactINode::match(const ProjNode* proj, const Matcher* m) {
   21.43 +  uint ideal_reg = proj->ideal_reg();
   21.44 +  RegMask rm;
   21.45 +  if (proj->_con == result_proj_node) {
   21.46 +    rm = m->mathExactI_result_proj_mask();
   21.47 +  } else {
   21.48 +    assert(proj->_con == flags_proj_node, "must be result or flags");
   21.49 +    assert(ideal_reg == Op_RegFlags, "sanity");
   21.50 +    rm = m->mathExactI_flags_proj_mask();
   21.51 +  }
   21.52 +  return new (m->C) MachProjNode(this, proj->_con, rm, ideal_reg);
   21.53 +}
   21.54 +
   21.55 +// If the MathExactNode won't overflow we have to replace the
   21.56 +// FlagsProjNode and ProjNode that is generated by the MathExactNode
   21.57 +Node* MathExactNode::no_overflow(PhaseGVN *phase, Node* new_result) {
   21.58 +  PhaseIterGVN *igvn = phase->is_IterGVN();
   21.59 +  if (igvn) {
   21.60 +    ProjNode* result = result_node();
   21.61 +    ProjNode* flags = flags_node();
   21.62 +
   21.63 +    if (result != NULL) {
   21.64 +      igvn->replace_node(result, new_result);
   21.65 +    }
   21.66 +
   21.67 +    if (flags != NULL) {
   21.68 +      BoolNode* bolnode = (BoolNode *) flags->unique_out();
   21.69 +      switch (bolnode->_test._test) {
   21.70 +        case BoolTest::overflow:
   21.71 +          // if the check is for overflow - never taken
   21.72 +          igvn->replace_node(bolnode, phase->intcon(0));
   21.73 +          break;
   21.74 +        case BoolTest::no_overflow:
   21.75 +          // if the check is for no overflow - always taken
   21.76 +          igvn->replace_node(bolnode, phase->intcon(1));
   21.77 +          break;
   21.78 +        default:
   21.79 +          fatal("Unexpected value of BoolTest");
   21.80 +          break;
   21.81 +      }
   21.82 +      flags->del_req(0);
   21.83 +    }
   21.84 +  }
   21.85 +  return new_result;
   21.86 +}
   21.87 +
   21.88 +Node *AddExactINode::Ideal(PhaseGVN *phase, bool can_reshape) {
   21.89 +  Node *arg1 = in(1);
   21.90 +  Node *arg2 = in(2);
   21.91 +
   21.92 +  const Type* type1 = phase->type(arg1);
   21.93 +  const Type* type2 = phase->type(arg2);
   21.94 +
   21.95 +  if (type1 != Type::TOP && type1->singleton() &&
   21.96 +      type2 != Type::TOP && type2->singleton()) {
   21.97 +    jint val1 = arg1->get_int();
   21.98 +    jint val2 = arg2->get_int();
   21.99 +    jint result = val1 + val2;
  21.100 +    // Hacker's Delight 2-12 Overflow if both arguments have the opposite sign of the result
  21.101 +    if ( (((val1 ^ result) & (val2 ^ result)) >= 0)) {
  21.102 +      Node* con_result = ConINode::make(phase->C, result);
  21.103 +      return no_overflow(phase, con_result);
  21.104 +    }
  21.105 +    return NULL;
  21.106 +  }
  21.107 +
  21.108 +  if (type1 == TypeInt::ZERO) { // (Add 0 x) == x
  21.109 +    Node* add_result = new (phase->C) AddINode(arg1, arg2);
  21.110 +    return no_overflow(phase, add_result);
  21.111 +  }
  21.112 +
  21.113 +  if (type2 == TypeInt::ZERO) { // (Add x 0) == x
  21.114 +    Node* add_result = new (phase->C) AddINode(arg1, arg2);
  21.115 +    return no_overflow(phase, add_result);
  21.116 +  }
  21.117 +
  21.118 +  if (type2->singleton()) {
  21.119 +    return NULL; // no change - keep constant on the right
  21.120 +  }
  21.121 +
  21.122 +  if (type1->singleton()) {
  21.123 +    // Make it x + Constant - move constant to the right
  21.124 +    swap_edges(1, 2);
  21.125 +    return this;
  21.126 +  }
  21.127 +
  21.128 +  if (arg2->is_Load()) {
  21.129 +    return NULL; // no change - keep load on the right
  21.130 +  }
  21.131 +
  21.132 +  if (arg1->is_Load()) {
  21.133 +    // Make it x + Load - move load to the right
  21.134 +    swap_edges(1, 2);
  21.135 +    return this;
  21.136 +  }
  21.137 +
  21.138 +  if (arg1->_idx > arg2->_idx) {
  21.139 +    // Sort the edges
  21.140 +    swap_edges(1, 2);
  21.141 +    return this;
  21.142 +  }
  21.143 +
  21.144 +  return NULL;
  21.145 +}
  21.146 +
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/src/share/vm/opto/mathexactnode.hpp	Fri Sep 27 12:43:51 2013 -0700
    22.3 @@ -0,0 +1,81 @@
    22.4 +/*
    22.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 + *
    22.8 + * This code is free software; you can redistribute it and/or modify it
    22.9 + * under the terms of the GNU General Public License version 2 only, as
   22.10 + * published by the Free Software Foundation.
   22.11 + *
   22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 + * version 2 for more details (a copy is included in the LICENSE file that
   22.16 + * accompanied this code).
   22.17 + *
   22.18 + * You should have received a copy of the GNU General Public License version
   22.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 + *
   22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22.23 + * or visit www.oracle.com if you need additional information or have any
   22.24 + * questions.
   22.25 + *
   22.26 + */
   22.27 +
   22.28 +#ifndef SHARE_VM_OPTO_MATHEXACTNODE_HPP
   22.29 +#define SHARE_VM_OPTO_MATHEXACTNODE_HPP
   22.30 +
   22.31 +#include "opto/multnode.hpp"
   22.32 +#include "opto/node.hpp"
   22.33 +#include "opto/type.hpp"
   22.34 +
   22.35 +class Node;
   22.36 +
   22.37 +class PhaseGVN;
   22.38 +class PhaseTransform;
   22.39 +
   22.40 +class MathExactNode : public MultiNode {
   22.41 +public:
   22.42 +  MathExactNode(Node* ctrl, Node* in1, Node* in2);
   22.43 +  enum {
   22.44 +    result_proj_node = 0,
   22.45 +    flags_proj_node = 1
   22.46 +  };
   22.47 +  virtual int Opcode() const;
   22.48 +  virtual Node* Identity(PhaseTransform* phase) { return this; }
   22.49 +  virtual Node* Ideal(PhaseGVN* phase, bool can_reshape) { return NULL; }
   22.50 +  virtual const Type* Value(PhaseTransform* phase) const { return bottom_type(); }
   22.51 +  virtual uint hash() const { return Node::hash(); }
   22.52 +  virtual bool is_CFG() const { return false; }
   22.53 +  virtual uint ideal_reg() const { return NotAMachineReg; }
   22.54 +
   22.55 +  ProjNode* result_node() { return proj_out(result_proj_node); }
   22.56 +  ProjNode* flags_node() { return proj_out(flags_proj_node); }
   22.57 +protected:
   22.58 +  Node* no_overflow(PhaseGVN *phase, Node* new_result);
   22.59 +};
   22.60 +
   22.61 +class AddExactINode : public MathExactNode {
   22.62 +public:
   22.63 +  AddExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactNode(ctrl, in1, in2) {}
   22.64 +  virtual int Opcode() const;
   22.65 +  virtual const Type* bottom_type() const { return TypeTuple::INT_CC_PAIR; }
   22.66 +  virtual Node* match(const ProjNode* proj, const Matcher* m);
   22.67 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   22.68 +};
   22.69 +
   22.70 +class FlagsProjNode : public ProjNode {
   22.71 +public:
   22.72 +  FlagsProjNode(Node* src, uint con) : ProjNode(src, con) {
   22.73 +    init_class_id(Class_FlagsProj);
   22.74 +  }
   22.75 +
   22.76 +  virtual int Opcode() const;
   22.77 +  virtual bool is_CFG() const { return false; }
   22.78 +  virtual const Type* bottom_type() const { return TypeInt::CC; }
   22.79 +  virtual uint ideal_reg() const { return Op_RegFlags; }
   22.80 +};
   22.81 +
   22.82 +
   22.83 +#endif
   22.84 +
    23.1 --- a/src/share/vm/opto/multnode.cpp	Thu Sep 26 08:48:15 2013 +0200
    23.2 +++ b/src/share/vm/opto/multnode.cpp	Fri Sep 27 12:43:51 2013 -0700
    23.3 @@ -25,6 +25,7 @@
    23.4  #include "precompiled.hpp"
    23.5  #include "opto/callnode.hpp"
    23.6  #include "opto/matcher.hpp"
    23.7 +#include "opto/mathexactnode.hpp"
    23.8  #include "opto/multnode.hpp"
    23.9  #include "opto/opcodes.hpp"
   23.10  #include "opto/phaseX.hpp"
   23.11 @@ -46,15 +47,21 @@
   23.12    assert(Opcode() != Op_If || outcnt() == 2, "bad if #1");
   23.13    for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
   23.14      Node *p = fast_out(i);
   23.15 -    if( !p->is_Proj() ) {
   23.16 +    if (p->is_Proj()) {
   23.17 +      ProjNode *proj = p->as_Proj();
   23.18 +      if (proj->_con == which_proj) {
   23.19 +        assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2");
   23.20 +        return proj;
   23.21 +      }
   23.22 +    } else if (p->is_FlagsProj()) {
   23.23 +      FlagsProjNode *proj = p->as_FlagsProj();
   23.24 +      if (proj->_con == which_proj) {
   23.25 +        return proj;
   23.26 +      }
   23.27 +    } else {
   23.28        assert(p == this && this->is_Start(), "else must be proj");
   23.29        continue;
   23.30      }
   23.31 -    ProjNode *proj = p->as_Proj();
   23.32 -    if( proj->_con == which_proj ) {
   23.33 -      assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2");
   23.34 -      return proj;
   23.35 -    }
   23.36    }
   23.37    return NULL;
   23.38  }
    24.1 --- a/src/share/vm/opto/node.hpp	Thu Sep 26 08:48:15 2013 +0200
    24.2 +++ b/src/share/vm/opto/node.hpp	Fri Sep 27 12:43:51 2013 -0700
    24.3 @@ -69,6 +69,7 @@
    24.4  class EncodePKlassNode;
    24.5  class FastLockNode;
    24.6  class FastUnlockNode;
    24.7 +class FlagsProjNode;
    24.8  class IfNode;
    24.9  class IfFalseNode;
   24.10  class IfTrueNode;
   24.11 @@ -623,6 +624,7 @@
   24.12        DEFINE_CLASS_ID(Cmp,   Sub, 0)
   24.13          DEFINE_CLASS_ID(FastLock,   Cmp, 0)
   24.14          DEFINE_CLASS_ID(FastUnlock, Cmp, 1)
   24.15 +        DEFINE_CLASS_ID(FlagsProj, Cmp, 2)
   24.16  
   24.17      DEFINE_CLASS_ID(MergeMem, Node, 7)
   24.18      DEFINE_CLASS_ID(Bool,     Node, 8)
   24.19 @@ -726,6 +728,7 @@
   24.20    DEFINE_CLASS_QUERY(EncodePKlass)
   24.21    DEFINE_CLASS_QUERY(FastLock)
   24.22    DEFINE_CLASS_QUERY(FastUnlock)
   24.23 +  DEFINE_CLASS_QUERY(FlagsProj)
   24.24    DEFINE_CLASS_QUERY(If)
   24.25    DEFINE_CLASS_QUERY(IfFalse)
   24.26    DEFINE_CLASS_QUERY(IfTrue)
    25.1 --- a/src/share/vm/opto/subnode.cpp	Thu Sep 26 08:48:15 2013 +0200
    25.2 +++ b/src/share/vm/opto/subnode.cpp	Fri Sep 27 12:43:51 2013 -0700
    25.3 @@ -1064,7 +1064,7 @@
    25.4  // Print special per-node info
    25.5  #ifndef PRODUCT
    25.6  void BoolTest::dump_on(outputStream *st) const {
    25.7 -  const char *msg[] = {"eq","gt","??","lt","ne","le","??","ge"};
    25.8 +  const char *msg[] = {"eq","gt","of","lt","ne","le","nof","ge"};
    25.9    st->print(msg[_test]);
   25.10  }
   25.11  #endif
   25.12 @@ -1126,7 +1126,7 @@
   25.13    Node *cmp = in(1);
   25.14    if( !cmp->is_Sub() ) return NULL;
   25.15    int cop = cmp->Opcode();
   25.16 -  if( cop == Op_FastLock || cop == Op_FastUnlock ) return NULL;
   25.17 +  if( cop == Op_FastLock || cop == Op_FastUnlock || cop == Op_FlagsProj) return NULL;
   25.18    Node *cmp1 = cmp->in(1);
   25.19    Node *cmp2 = cmp->in(2);
   25.20    if( !cmp1 ) return NULL;
    26.1 --- a/src/share/vm/opto/subnode.hpp	Thu Sep 26 08:48:15 2013 +0200
    26.2 +++ b/src/share/vm/opto/subnode.hpp	Fri Sep 27 12:43:51 2013 -0700
    26.3 @@ -263,16 +263,16 @@
    26.4  // We pick the values as 3 bits; the low order 2 bits we compare against the
    26.5  // condition codes, the high bit flips the sense of the result.
    26.6  struct BoolTest VALUE_OBJ_CLASS_SPEC {
    26.7 -  enum mask { eq = 0, ne = 4, le = 5, ge = 7, lt = 3, gt = 1, illegal = 8 };
    26.8 +  enum mask { eq = 0, ne = 4, le = 5, ge = 7, lt = 3, gt = 1, overflow = 2, no_overflow = 6, illegal = 8 };
    26.9    mask _test;
   26.10    BoolTest( mask btm ) : _test(btm) {}
   26.11    const Type *cc2logical( const Type *CC ) const;
   26.12    // Commute the test.  I use a small table lookup.  The table is created as
   26.13    // a simple char array where each element is the ASCII version of a 'mask'
   26.14    // enum from above.
   26.15 -  mask commute( ) const { return mask("038147858"[_test]-'0'); }
   26.16 +  mask commute( ) const { return mask("032147658"[_test]-'0'); }
   26.17    mask negate( ) const { return mask(_test^4); }
   26.18 -  bool is_canonical( ) const { return (_test == BoolTest::ne || _test == BoolTest::lt || _test == BoolTest::le); }
   26.19 +  bool is_canonical( ) const { return (_test == BoolTest::ne || _test == BoolTest::lt || _test == BoolTest::le || _test == BoolTest::overflow); }
   26.20  #ifndef PRODUCT
   26.21    void dump_on(outputStream *st) const;
   26.22  #endif
    27.1 --- a/src/share/vm/opto/type.cpp	Thu Sep 26 08:48:15 2013 +0200
    27.2 +++ b/src/share/vm/opto/type.cpp	Fri Sep 27 12:43:51 2013 -0700
    27.3 @@ -430,6 +430,11 @@
    27.4    longpair[1] = TypeLong::LONG;
    27.5    TypeTuple::LONG_PAIR = TypeTuple::make(2, longpair);
    27.6  
    27.7 +  const Type **intccpair = TypeTuple::fields(2);
    27.8 +  intccpair[0] = TypeInt::INT;
    27.9 +  intccpair[1] = TypeInt::CC;
   27.10 +  TypeTuple::INT_CC_PAIR = TypeTuple::make(2, intccpair);
   27.11 +
   27.12    _const_basic_type[T_NARROWOOP]   = TypeNarrowOop::BOTTOM;
   27.13    _const_basic_type[T_NARROWKLASS] = Type::BOTTOM;
   27.14    _const_basic_type[T_BOOLEAN]     = TypeInt::BOOL;
   27.15 @@ -1646,6 +1651,7 @@
   27.16  const TypeTuple *TypeTuple::START_I2C;
   27.17  const TypeTuple *TypeTuple::INT_PAIR;
   27.18  const TypeTuple *TypeTuple::LONG_PAIR;
   27.19 +const TypeTuple *TypeTuple::INT_CC_PAIR;
   27.20  
   27.21  
   27.22  //------------------------------make-------------------------------------------
    28.1 --- a/src/share/vm/opto/type.hpp	Thu Sep 26 08:48:15 2013 +0200
    28.2 +++ b/src/share/vm/opto/type.hpp	Fri Sep 27 12:43:51 2013 -0700
    28.3 @@ -584,6 +584,7 @@
    28.4    static const TypeTuple *START_I2C;
    28.5    static const TypeTuple *INT_PAIR;
    28.6    static const TypeTuple *LONG_PAIR;
    28.7 +  static const TypeTuple *INT_CC_PAIR;
    28.8  #ifndef PRODUCT
    28.9    virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
   28.10  #endif
    29.1 --- a/src/share/vm/prims/jvm.cpp	Thu Sep 26 08:48:15 2013 +0200
    29.2 +++ b/src/share/vm/prims/jvm.cpp	Fri Sep 27 12:43:51 2013 -0700
    29.3 @@ -4226,13 +4226,13 @@
    29.4  
    29.5  JVM_LEAF(jboolean, JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get))
    29.6    JVMWrapper("JVM_AccessBoolVMFlag");
    29.7 -  return is_get ? CommandLineFlags::boolAt((char*) name, (bool*) value) : CommandLineFlags::boolAtPut((char*) name, (bool*) value, INTERNAL);
    29.8 +  return is_get ? CommandLineFlags::boolAt((char*) name, (bool*) value) : CommandLineFlags::boolAtPut((char*) name, (bool*) value, Flag::INTERNAL);
    29.9  JVM_END
   29.10  
   29.11  JVM_LEAF(jboolean, JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get))
   29.12    JVMWrapper("JVM_AccessVMIntFlag");
   29.13    intx v;
   29.14 -  jboolean result = is_get ? CommandLineFlags::intxAt((char*) name, &v) : CommandLineFlags::intxAtPut((char*) name, &v, INTERNAL);
   29.15 +  jboolean result = is_get ? CommandLineFlags::intxAt((char*) name, &v) : CommandLineFlags::intxAtPut((char*) name, &v, Flag::INTERNAL);
   29.16    *value = (jint)v;
   29.17    return result;
   29.18  JVM_END
    30.1 --- a/src/share/vm/runtime/arguments.cpp	Thu Sep 26 08:48:15 2013 +0200
    30.2 +++ b/src/share/vm/runtime/arguments.cpp	Fri Sep 27 12:43:51 2013 -0700
    30.3 @@ -625,11 +625,11 @@
    30.4    }
    30.5  }
    30.6  
    30.7 -static bool set_bool_flag(char* name, bool value, FlagValueOrigin origin) {
    30.8 +static bool set_bool_flag(char* name, bool value, Flag::Flags origin) {
    30.9    return CommandLineFlags::boolAtPut(name, &value, origin);
   30.10  }
   30.11  
   30.12 -static bool set_fp_numeric_flag(char* name, char* value, FlagValueOrigin origin) {
   30.13 +static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) {
   30.14    double v;
   30.15    if (sscanf(value, "%lf", &v) != 1) {
   30.16      return false;
   30.17 @@ -641,7 +641,7 @@
   30.18    return false;
   30.19  }
   30.20  
   30.21 -static bool set_numeric_flag(char* name, char* value, FlagValueOrigin origin) {
   30.22 +static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) {
   30.23    julong v;
   30.24    intx intx_v;
   30.25    bool is_neg = false;
   30.26 @@ -674,14 +674,14 @@
   30.27    return false;
   30.28  }
   30.29  
   30.30 -static bool set_string_flag(char* name, const char* value, FlagValueOrigin origin) {
   30.31 +static bool set_string_flag(char* name, const char* value, Flag::Flags origin) {
   30.32    if (!CommandLineFlags::ccstrAtPut(name, &value, origin))  return false;
   30.33    // Contract:  CommandLineFlags always returns a pointer that needs freeing.
   30.34    FREE_C_HEAP_ARRAY(char, value, mtInternal);
   30.35    return true;
   30.36  }
   30.37  
   30.38 -static bool append_to_string_flag(char* name, const char* new_value, FlagValueOrigin origin) {
   30.39 +static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags origin) {
   30.40    const char* old_value = "";
   30.41    if (!CommandLineFlags::ccstrAt(name, &old_value))  return false;
   30.42    size_t old_len = old_value != NULL ? strlen(old_value) : 0;
   30.43 @@ -709,7 +709,7 @@
   30.44    return true;
   30.45  }
   30.46  
   30.47 -bool Arguments::parse_argument(const char* arg, FlagValueOrigin origin) {
   30.48 +bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
   30.49  
   30.50    // range of acceptable characters spelled out for portability reasons
   30.51  #define NAME_RANGE  "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
   30.52 @@ -850,7 +850,7 @@
   30.53  }
   30.54  
   30.55  bool Arguments::process_argument(const char* arg,
   30.56 -    jboolean ignore_unrecognized, FlagValueOrigin origin) {
   30.57 +    jboolean ignore_unrecognized, Flag::Flags origin) {
   30.58  
   30.59    JDK_Version since = JDK_Version();
   30.60  
   30.61 @@ -904,7 +904,7 @@
   30.62        jio_fprintf(defaultStream::error_stream(),
   30.63                    "Did you mean '%s%s%s'?\n",
   30.64                    (fuzzy_matched->is_bool()) ? "(+/-)" : "",
   30.65 -                  fuzzy_matched->name,
   30.66 +                  fuzzy_matched->_name,
   30.67                    (fuzzy_matched->is_bool()) ? "" : "=<value>");
   30.68      }
   30.69    }
   30.70 @@ -952,7 +952,7 @@
   30.71          // this allows a way to include spaces in string-valued options
   30.72          token[pos] = '\0';
   30.73          logOption(token);
   30.74 -        result &= process_argument(token, ignore_unrecognized, CONFIG_FILE);
   30.75 +        result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE);
   30.76          build_jvm_flags(token);
   30.77          pos = 0;
   30.78          in_white_space = true;
   30.79 @@ -970,7 +970,7 @@
   30.80    }
   30.81    if (pos > 0) {
   30.82      token[pos] = '\0';
   30.83 -    result &= process_argument(token, ignore_unrecognized, CONFIG_FILE);
   30.84 +    result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE);
   30.85      build_jvm_flags(token);
   30.86    }
   30.87    fclose(stream);
   30.88 @@ -2438,7 +2438,7 @@
   30.89    }
   30.90  
   30.91    // Parse JavaVMInitArgs structure passed in
   30.92 -  result = parse_each_vm_init_arg(args, &scp, &scp_assembly_required, COMMAND_LINE);
   30.93 +  result = parse_each_vm_init_arg(args, &scp, &scp_assembly_required, Flag::COMMAND_LINE);
   30.94    if (result != JNI_OK) {
   30.95      return result;
   30.96    }
   30.97 @@ -2510,7 +2510,7 @@
   30.98  jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
   30.99                                         SysClassPath* scp_p,
  30.100                                         bool* scp_assembly_required_p,
  30.101 -                                       FlagValueOrigin origin) {
  30.102 +                                       Flag::Flags origin) {
  30.103    // Remaining part of option string
  30.104    const char* tail;
  30.105  
  30.106 @@ -3333,7 +3333,7 @@
  30.107        }
  30.108      }
  30.109  
  30.110 -    return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, ENVIRON_VAR));
  30.111 +    return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, Flag::ENVIRON_VAR));
  30.112    }
  30.113    return JNI_OK;
  30.114  }
    31.1 --- a/src/share/vm/runtime/arguments.hpp	Thu Sep 26 08:48:15 2013 +0200
    31.2 +++ b/src/share/vm/runtime/arguments.hpp	Fri Sep 27 12:43:51 2013 -0700
    31.3 @@ -360,15 +360,15 @@
    31.4  
    31.5    // Argument parsing
    31.6    static void do_pd_flag_adjustments();
    31.7 -  static bool parse_argument(const char* arg, FlagValueOrigin origin);
    31.8 -  static bool process_argument(const char* arg, jboolean ignore_unrecognized, FlagValueOrigin origin);
    31.9 +  static bool parse_argument(const char* arg, Flag::Flags origin);
   31.10 +  static bool process_argument(const char* arg, jboolean ignore_unrecognized, Flag::Flags origin);
   31.11    static void process_java_launcher_argument(const char*, void*);
   31.12    static void process_java_compiler_argument(char* arg);
   31.13    static jint parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p);
   31.14    static jint parse_java_tool_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p);
   31.15    static jint parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p);
   31.16    static jint parse_vm_init_args(const JavaVMInitArgs* args);
   31.17 -  static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, SysClassPath* scp_p, bool* scp_assembly_required_p, FlagValueOrigin origin);
   31.18 +  static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, SysClassPath* scp_p, bool* scp_assembly_required_p, Flag::Flags origin);
   31.19    static jint finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required);
   31.20    static bool is_bad_option(const JavaVMOption* option, jboolean ignore,
   31.21      const char* option_type);
    32.1 --- a/src/share/vm/runtime/globals.cpp	Thu Sep 26 08:48:15 2013 +0200
    32.2 +++ b/src/share/vm/runtime/globals.cpp	Fri Sep 27 12:43:51 2013 -0700
    32.3 @@ -62,26 +62,174 @@
    32.4  MATERIALIZE_FLAGS_EXT
    32.5  
    32.6  
    32.7 +void Flag::check_writable() {
    32.8 +  if (is_constant_in_binary()) {
    32.9 +    fatal(err_msg("flag is constant: %s", _name));
   32.10 +  }
   32.11 +}
   32.12 +
   32.13 +bool Flag::is_bool() const {
   32.14 +  return strcmp(_type, "bool") == 0;
   32.15 +}
   32.16 +
   32.17 +bool Flag::get_bool() const {
   32.18 +  return *((bool*) _addr);
   32.19 +}
   32.20 +
   32.21 +void Flag::set_bool(bool value) {
   32.22 +  check_writable();
   32.23 +  *((bool*) _addr) = value;
   32.24 +}
   32.25 +
   32.26 +bool Flag::is_intx() const {
   32.27 +  return strcmp(_type, "intx")  == 0;
   32.28 +}
   32.29 +
   32.30 +intx Flag::get_intx() const {
   32.31 +  return *((intx*) _addr);
   32.32 +}
   32.33 +
   32.34 +void Flag::set_intx(intx value) {
   32.35 +  check_writable();
   32.36 +  *((intx*) _addr) = value;
   32.37 +}
   32.38 +
   32.39 +bool Flag::is_uintx() const {
   32.40 +  return strcmp(_type, "uintx") == 0;
   32.41 +}
   32.42 +
   32.43 +uintx Flag::get_uintx() const {
   32.44 +  return *((uintx*) _addr);
   32.45 +}
   32.46 +
   32.47 +void Flag::set_uintx(uintx value) {
   32.48 +  check_writable();
   32.49 +  *((uintx*) _addr) = value;
   32.50 +}
   32.51 +
   32.52 +bool Flag::is_uint64_t() const {
   32.53 +  return strcmp(_type, "uint64_t") == 0;
   32.54 +}
   32.55 +
   32.56 +uint64_t Flag::get_uint64_t() const {
   32.57 +  return *((uint64_t*) _addr);
   32.58 +}
   32.59 +
   32.60 +void Flag::set_uint64_t(uint64_t value) {
   32.61 +  check_writable();
   32.62 +  *((uint64_t*) _addr) = value;
   32.63 +}
   32.64 +
   32.65 +bool Flag::is_double() const {
   32.66 +  return strcmp(_type, "double") == 0;
   32.67 +}
   32.68 +
   32.69 +double Flag::get_double() const {
   32.70 +  return *((double*) _addr);
   32.71 +}
   32.72 +
   32.73 +void Flag::set_double(double value) {
   32.74 +  check_writable();
   32.75 +  *((double*) _addr) = value;
   32.76 +}
   32.77 +
   32.78 +bool Flag::is_ccstr() const {
   32.79 +  return strcmp(_type, "ccstr") == 0 || strcmp(_type, "ccstrlist") == 0;
   32.80 +}
   32.81 +
   32.82 +bool Flag::ccstr_accumulates() const {
   32.83 +  return strcmp(_type, "ccstrlist") == 0;
   32.84 +}
   32.85 +
   32.86 +ccstr Flag::get_ccstr() const {
   32.87 +  return *((ccstr*) _addr);
   32.88 +}
   32.89 +
   32.90 +void Flag::set_ccstr(ccstr value) {
   32.91 +  check_writable();
   32.92 +  *((ccstr*) _addr) = value;
   32.93 +}
   32.94 +
   32.95 +
   32.96 +Flag::Flags Flag::get_origin() {
   32.97 +  return Flags(_flags & VALUE_ORIGIN_MASK);
   32.98 +}
   32.99 +
  32.100 +void Flag::set_origin(Flags origin) {
  32.101 +  assert((origin & VALUE_ORIGIN_MASK) == origin, "sanity");
  32.102 +  _flags = Flags((_flags & ~VALUE_ORIGIN_MASK) | origin);
  32.103 +}
  32.104 +
  32.105 +bool Flag::is_default() {
  32.106 +  return (get_origin() == DEFAULT);
  32.107 +}
  32.108 +
  32.109 +bool Flag::is_ergonomic() {
  32.110 +  return (get_origin() == ERGONOMIC);
  32.111 +}
  32.112 +
  32.113 +bool Flag::is_command_line() {
  32.114 +  return (get_origin() == COMMAND_LINE);
  32.115 +}
  32.116 +
  32.117 +bool Flag::is_product() const {
  32.118 +  return (_flags & KIND_PRODUCT) != 0;
  32.119 +}
  32.120 +
  32.121 +bool Flag::is_manageable() const {
  32.122 +  return (_flags & KIND_MANAGEABLE) != 0;
  32.123 +}
  32.124 +
  32.125 +bool Flag::is_diagnostic() const {
  32.126 +  return (_flags & KIND_DIAGNOSTIC) != 0;
  32.127 +}
  32.128 +
  32.129 +bool Flag::is_experimental() const {
  32.130 +  return (_flags & KIND_EXPERIMENTAL) != 0;
  32.131 +}
  32.132 +
  32.133 +bool Flag::is_notproduct() const {
  32.134 +  return (_flags & KIND_NOT_PRODUCT) != 0;
  32.135 +}
  32.136 +
  32.137 +bool Flag::is_develop() const {
  32.138 +  return (_flags & KIND_DEVELOP) != 0;
  32.139 +}
  32.140 +
  32.141 +bool Flag::is_read_write() const {
  32.142 +  return (_flags & KIND_READ_WRITE) != 0;
  32.143 +}
  32.144 +
  32.145 +bool Flag::is_commercial() const {
  32.146 +  return (_flags & KIND_COMMERCIAL) != 0;
  32.147 +}
  32.148 +
  32.149 +/**
  32.150 + * Returns if this flag is a constant in the binary.  Right now this is
  32.151 + * true for notproduct and develop flags in product builds.
  32.152 + */
  32.153 +bool Flag::is_constant_in_binary() const {
  32.154 +#ifdef PRODUCT
  32.155 +    return is_notproduct() || is_develop();
  32.156 +#else
  32.157 +    return false;
  32.158 +#endif
  32.159 +}
  32.160 +
  32.161  bool Flag::is_unlocker() const {
  32.162 -  return strcmp(name, "UnlockDiagnosticVMOptions") == 0     ||
  32.163 -         strcmp(name, "UnlockExperimentalVMOptions") == 0   ||
  32.164 +  return strcmp(_name, "UnlockDiagnosticVMOptions") == 0     ||
  32.165 +         strcmp(_name, "UnlockExperimentalVMOptions") == 0   ||
  32.166           is_unlocker_ext();
  32.167  }
  32.168  
  32.169  bool Flag::is_unlocked() const {
  32.170 -  if (strcmp(kind, "{diagnostic}") == 0 ||
  32.171 -      strcmp(kind, "{C2 diagnostic}") == 0 ||
  32.172 -      strcmp(kind, "{ARCH diagnostic}") == 0 ||
  32.173 -      strcmp(kind, "{Shark diagnostic}") == 0) {
  32.174 +  if (is_diagnostic()) {
  32.175      return UnlockDiagnosticVMOptions;
  32.176 -  } else if (strcmp(kind, "{experimental}") == 0 ||
  32.177 -             strcmp(kind, "{C2 experimental}") == 0 ||
  32.178 -             strcmp(kind, "{ARCH experimental}") == 0 ||
  32.179 -             strcmp(kind, "{Shark experimental}") == 0) {
  32.180 +  }
  32.181 +  if (is_experimental()) {
  32.182      return UnlockExperimentalVMOptions;
  32.183 -  } else {
  32.184 -    return is_unlocked_ext();
  32.185    }
  32.186 +  return is_unlocked_ext();
  32.187  }
  32.188  
  32.189  // Get custom message for this locked flag, or return NULL if
  32.190 @@ -91,16 +239,14 @@
  32.191  }
  32.192  
  32.193  bool Flag::is_writeable() const {
  32.194 -  return strcmp(kind, "{manageable}") == 0 ||
  32.195 -         strcmp(kind, "{product rw}") == 0 ||
  32.196 -         is_writeable_ext();
  32.197 +  return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext();
  32.198  }
  32.199  
  32.200  // All flags except "manageable" are assumed to be internal flags.
  32.201  // Long term, we need to define a mechanism to specify which flags
  32.202  // are external/stable and change this function accordingly.
  32.203  bool Flag::is_external() const {
  32.204 -  return strcmp(kind, "{manageable}") == 0 || is_external_ext();
  32.205 +  return is_manageable() || is_external_ext();
  32.206  }
  32.207  
  32.208  
  32.209 @@ -108,53 +254,113 @@
  32.210  #define FORMAT_BUFFER_LEN 16
  32.211  
  32.212  void Flag::print_on(outputStream* st, bool withComments) {
  32.213 -  st->print("%9s %-40s %c= ", type, name, (origin != DEFAULT ? ':' : ' '));
  32.214 -  if (is_bool())     st->print("%-16s", get_bool() ? "true" : "false");
  32.215 -  if (is_intx())     st->print("%-16ld", get_intx());
  32.216 -  if (is_uintx())    st->print("%-16lu", get_uintx());
  32.217 -  if (is_uint64_t()) st->print("%-16lu", get_uint64_t());
  32.218 -  if (is_double())   st->print("%-16f", get_double());
  32.219 +  // Don't print notproduct and develop flags in a product build.
  32.220 +  if (is_constant_in_binary()) {
  32.221 +    return;
  32.222 +  }
  32.223  
  32.224 +  st->print("%9s %-40s %c= ", _type, _name, (!is_default() ? ':' : ' '));
  32.225 +
  32.226 +  if (is_bool()) {
  32.227 +    st->print("%-16s", get_bool() ? "true" : "false");
  32.228 +  }
  32.229 +  if (is_intx()) {
  32.230 +    st->print("%-16ld", get_intx());
  32.231 +  }
  32.232 +  if (is_uintx()) {
  32.233 +    st->print("%-16lu", get_uintx());
  32.234 +  }
  32.235 +  if (is_uint64_t()) {
  32.236 +    st->print("%-16lu", get_uint64_t());
  32.237 +  }
  32.238 +  if (is_double()) {
  32.239 +    st->print("%-16f", get_double());
  32.240 +  }
  32.241    if (is_ccstr()) {
  32.242 -     const char* cp = get_ccstr();
  32.243 -     if (cp != NULL) {
  32.244 -       const char* eol;
  32.245 -       while ((eol = strchr(cp, '\n')) != NULL) {
  32.246 -         char format_buffer[FORMAT_BUFFER_LEN];
  32.247 -         size_t llen = pointer_delta(eol, cp, sizeof(char));
  32.248 -         jio_snprintf(format_buffer, FORMAT_BUFFER_LEN,
  32.249 -                     "%%." SIZE_FORMAT "s", llen);
  32.250 -         st->print(format_buffer, cp);
  32.251 -         st->cr();
  32.252 -         cp = eol+1;
  32.253 -         st->print("%5s %-35s += ", "", name);
  32.254 -       }
  32.255 -       st->print("%-16s", cp);
  32.256 -     }
  32.257 -     else st->print("%-16s", "");
  32.258 +    const char* cp = get_ccstr();
  32.259 +    if (cp != NULL) {
  32.260 +      const char* eol;
  32.261 +      while ((eol = strchr(cp, '\n')) != NULL) {
  32.262 +        char format_buffer[FORMAT_BUFFER_LEN];
  32.263 +        size_t llen = pointer_delta(eol, cp, sizeof(char));
  32.264 +        jio_snprintf(format_buffer, FORMAT_BUFFER_LEN,
  32.265 +            "%%." SIZE_FORMAT "s", llen);
  32.266 +        st->print(format_buffer, cp);
  32.267 +        st->cr();
  32.268 +        cp = eol+1;
  32.269 +        st->print("%5s %-35s += ", "", _name);
  32.270 +      }
  32.271 +      st->print("%-16s", cp);
  32.272 +    }
  32.273 +    else st->print("%-16s", "");
  32.274    }
  32.275 -  st->print("%-20s", kind);
  32.276 +
  32.277 +  st->print("%-20");
  32.278 +  print_kind(st);
  32.279 +
  32.280    if (withComments) {
  32.281  #ifndef PRODUCT
  32.282 -    st->print("%s", doc );
  32.283 +    st->print("%s", _doc);
  32.284  #endif
  32.285    }
  32.286    st->cr();
  32.287  }
  32.288  
  32.289 +void Flag::print_kind(outputStream* st) {
  32.290 +  struct Data {
  32.291 +    int flag;
  32.292 +    const char* name;
  32.293 +  };
  32.294 +
  32.295 +  Data data[] = {
  32.296 +      { KIND_C1, "C1" },
  32.297 +      { KIND_C2, "C2" },
  32.298 +      { KIND_ARCH, "ARCH" },
  32.299 +      { KIND_SHARK, "SHARK" },
  32.300 +      { KIND_PLATFORM_DEPENDENT, "pd" },
  32.301 +      { KIND_PRODUCT, "product" },
  32.302 +      { KIND_MANAGEABLE, "manageable" },
  32.303 +      { KIND_DIAGNOSTIC, "diagnostic" },
  32.304 +      { KIND_NOT_PRODUCT, "notproduct" },
  32.305 +      { KIND_DEVELOP, "develop" },
  32.306 +      { KIND_LP64_PRODUCT, "lp64_product" },
  32.307 +      { KIND_READ_WRITE, "rw" },
  32.308 +      { -1, "" }
  32.309 +  };
  32.310 +
  32.311 +  if ((_flags & KIND_MASK) != 0) {
  32.312 +    st->print("{");
  32.313 +    bool is_first = true;
  32.314 +
  32.315 +    for (int i = 0; data[i].flag != -1; i++) {
  32.316 +      Data d = data[i];
  32.317 +      if ((_flags & d.flag) != 0) {
  32.318 +        if (is_first) {
  32.319 +          is_first = false;
  32.320 +        } else {
  32.321 +          st->print(" ");
  32.322 +        }
  32.323 +        st->print(d.name);
  32.324 +      }
  32.325 +    }
  32.326 +
  32.327 +    st->print("}");
  32.328 +  }
  32.329 +}
  32.330 +
  32.331  void Flag::print_as_flag(outputStream* st) {
  32.332    if (is_bool()) {
  32.333 -    st->print("-XX:%s%s", get_bool() ? "+" : "-", name);
  32.334 +    st->print("-XX:%s%s", get_bool() ? "+" : "-", _name);
  32.335    } else if (is_intx()) {
  32.336 -    st->print("-XX:%s=" INTX_FORMAT, name, get_intx());
  32.337 +    st->print("-XX:%s=" INTX_FORMAT, _name, get_intx());
  32.338    } else if (is_uintx()) {
  32.339 -    st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx());
  32.340 +    st->print("-XX:%s=" UINTX_FORMAT, _name, get_uintx());
  32.341    } else if (is_uint64_t()) {
  32.342 -    st->print("-XX:%s=" UINT64_FORMAT, name, get_uint64_t());
  32.343 +    st->print("-XX:%s=" UINT64_FORMAT, _name, get_uint64_t());
  32.344    } else if (is_double()) {
  32.345 -    st->print("-XX:%s=%f", name, get_double());
  32.346 +    st->print("-XX:%s=%f", _name, get_double());
  32.347    } else if (is_ccstr()) {
  32.348 -    st->print("-XX:%s=", name);
  32.349 +    st->print("-XX:%s=", _name);
  32.350      const char* cp = get_ccstr();
  32.351      if (cp != NULL) {
  32.352        // Need to turn embedded '\n's back into separate arguments
  32.353 @@ -167,7 +373,7 @@
  32.354              st->print("%c", *cp);
  32.355              break;
  32.356            case '\n':
  32.357 -            st->print(" -XX:%s=", name);
  32.358 +            st->print(" -XX:%s=", _name);
  32.359              break;
  32.360          }
  32.361        }
  32.362 @@ -180,79 +386,51 @@
  32.363  // 4991491 do not "optimize out" the was_set false values: omitting them
  32.364  // tickles a Microsoft compiler bug causing flagTable to be malformed
  32.365  
  32.366 -#define RUNTIME_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{product}", DEFAULT },
  32.367 -#define RUNTIME_PD_PRODUCT_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{pd product}", DEFAULT },
  32.368 -#define RUNTIME_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{diagnostic}", DEFAULT },
  32.369 -#define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{experimental}", DEFAULT },
  32.370 -#define RUNTIME_MANAGEABLE_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{manageable}", DEFAULT },
  32.371 -#define RUNTIME_PRODUCT_RW_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{product rw}", DEFAULT },
  32.372 +#define NAME(name) NOT_PRODUCT(&name) PRODUCT_ONLY(&CONST_##name)
  32.373  
  32.374 -#ifdef PRODUCT
  32.375 -  #define RUNTIME_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
  32.376 -  #define RUNTIME_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     /* flag is constant */
  32.377 -  #define RUNTIME_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc)
  32.378 -#else
  32.379 -  #define RUNTIME_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "", DEFAULT },
  32.380 -  #define RUNTIME_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, doc, "{pd}", DEFAULT },
  32.381 -  #define RUNTIME_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{notproduct}", DEFAULT },
  32.382 -#endif
  32.383 +#define RUNTIME_PRODUCT_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT) },
  32.384 +#define RUNTIME_PD_PRODUCT_FLAG_STRUCT(  type, name,        doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
  32.385 +#define RUNTIME_DIAGNOSTIC_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DIAGNOSTIC) },
  32.386 +#define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_EXPERIMENTAL) },
  32.387 +#define RUNTIME_MANAGEABLE_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_MANAGEABLE) },
  32.388 +#define RUNTIME_PRODUCT_RW_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT | Flag::KIND_READ_WRITE) },
  32.389 +#define RUNTIME_DEVELOP_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DEVELOP) },
  32.390 +#define RUNTIME_PD_DEVELOP_FLAG_STRUCT(  type, name,        doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
  32.391 +#define RUNTIME_NOTPRODUCT_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_NOT_PRODUCT) },
  32.392  
  32.393  #ifdef _LP64
  32.394 -  #define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{lp64_product}", DEFAULT },
  32.395 +#define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_LP64_PRODUCT) },
  32.396  #else
  32.397 -  #define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
  32.398 +#define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
  32.399  #endif // _LP64
  32.400  
  32.401 -#define C1_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C1 product}", DEFAULT },
  32.402 -#define C1_PD_PRODUCT_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C1 pd product}", DEFAULT },
  32.403 -#define C1_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C1 diagnostic}", DEFAULT },
  32.404 -#ifdef PRODUCT
  32.405 -  #define C1_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
  32.406 -  #define C1_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     /* flag is constant */
  32.407 -  #define C1_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc)
  32.408 -#else
  32.409 -  #define C1_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{C1}", DEFAULT },
  32.410 -  #define C1_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, doc, "{C1 pd}", DEFAULT },
  32.411 -  #define C1_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{C1 notproduct}", DEFAULT },
  32.412 -#endif
  32.413 +#define C1_PRODUCT_FLAG_STRUCT(          type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_PRODUCT) },
  32.414 +#define C1_PD_PRODUCT_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
  32.415 +#define C1_DIAGNOSTIC_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DIAGNOSTIC) },
  32.416 +#define C1_DEVELOP_FLAG_STRUCT(          type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DEVELOP) },
  32.417 +#define C1_PD_DEVELOP_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
  32.418 +#define C1_NOTPRODUCT_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_NOT_PRODUCT) },
  32.419  
  32.420 -#define C2_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C2 product}", DEFAULT },
  32.421 -#define C2_PD_PRODUCT_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C2 pd product}", DEFAULT },
  32.422 -#define C2_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C2 diagnostic}", DEFAULT },
  32.423 -#define C2_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C2 experimental}", DEFAULT },
  32.424 -#ifdef PRODUCT
  32.425 -  #define C2_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
  32.426 -  #define C2_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     /* flag is constant */
  32.427 -  #define C2_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc)
  32.428 -#else
  32.429 -  #define C2_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{C2}", DEFAULT },
  32.430 -  #define C2_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, doc, "{C2 pd}", DEFAULT },
  32.431 -  #define C2_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{C2 notproduct}", DEFAULT },
  32.432 -#endif
  32.433 +#define C2_PRODUCT_FLAG_STRUCT(          type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT) },
  32.434 +#define C2_PD_PRODUCT_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
  32.435 +#define C2_DIAGNOSTIC_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DIAGNOSTIC) },
  32.436 +#define C2_EXPERIMENTAL_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_EXPERIMENTAL) },
  32.437 +#define C2_DEVELOP_FLAG_STRUCT(          type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DEVELOP) },
  32.438 +#define C2_PD_DEVELOP_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
  32.439 +#define C2_NOTPRODUCT_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_NOT_PRODUCT) },
  32.440  
  32.441 -#define ARCH_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{ARCH product}", DEFAULT },
  32.442 -#define ARCH_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{ARCH diagnostic}", DEFAULT },
  32.443 -#define ARCH_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{ARCH experimental}", DEFAULT },
  32.444 -#ifdef PRODUCT
  32.445 -  #define ARCH_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
  32.446 -  #define ARCH_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc)
  32.447 -#else
  32.448 -  #define ARCH_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{ARCH}", DEFAULT },
  32.449 -  #define ARCH_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{ARCH notproduct}", DEFAULT },
  32.450 -#endif
  32.451 +#define ARCH_PRODUCT_FLAG_STRUCT(        type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_PRODUCT) },
  32.452 +#define ARCH_DIAGNOSTIC_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_DIAGNOSTIC) },
  32.453 +#define ARCH_EXPERIMENTAL_FLAG_STRUCT(   type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_EXPERIMENTAL) },
  32.454 +#define ARCH_DEVELOP_FLAG_STRUCT(        type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_DEVELOP) },
  32.455 +#define ARCH_NOTPRODUCT_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_NOT_PRODUCT) },
  32.456  
  32.457 -#define SHARK_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{Shark product}", DEFAULT },
  32.458 -#define SHARK_PD_PRODUCT_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{Shark pd product}", DEFAULT },
  32.459 -#define SHARK_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{Shark diagnostic}", DEFAULT },
  32.460 -#ifdef PRODUCT
  32.461 -  #define SHARK_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
  32.462 -  #define SHARK_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     /* flag is constant */
  32.463 -  #define SHARK_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc)
  32.464 -#else
  32.465 -  #define SHARK_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{Shark}", DEFAULT },
  32.466 -  #define SHARK_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, doc, "{Shark pd}", DEFAULT },
  32.467 -  #define SHARK_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{Shark notproduct}", DEFAULT },
  32.468 -#endif
  32.469 +#define SHARK_PRODUCT_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_PRODUCT) },
  32.470 +#define SHARK_PD_PRODUCT_FLAG_STRUCT(    type, name,        doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
  32.471 +#define SHARK_DIAGNOSTIC_FLAG_STRUCT(    type, name, value, doc) { #type, XSTR(name), &name,      NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DIAGNOSTIC) },
  32.472 +#define SHARK_DEVELOP_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DEVELOP) },
  32.473 +#define SHARK_PD_DEVELOP_FLAG_STRUCT(    type, name,        doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
  32.474 +#define SHARK_NOTPRODUCT_FLAG_STRUCT(    type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_NOT_PRODUCT) },
  32.475  
  32.476  static Flag flagTable[] = {
  32.477   RUNTIME_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_DIAGNOSTIC_FLAG_STRUCT, RUNTIME_EXPERIMENTAL_FLAG_STRUCT, RUNTIME_NOTPRODUCT_FLAG_STRUCT, RUNTIME_MANAGEABLE_FLAG_STRUCT, RUNTIME_PRODUCT_RW_FLAG_STRUCT, RUNTIME_LP64_PRODUCT_FLAG_STRUCT)
  32.478 @@ -285,9 +463,14 @@
  32.479  
  32.480  // Search the flag table for a named flag
  32.481  Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked) {
  32.482 -  for (Flag* current = &flagTable[0]; current->name != NULL; current++) {
  32.483 -    if (str_equal(current->name, name, length)) {
  32.484 -      // Found a matching entry.  Report locked flags only if allowed.
  32.485 +  for (Flag* current = &flagTable[0]; current->_name != NULL; current++) {
  32.486 +    if (str_equal(current->_name, name, length)) {
  32.487 +      // Found a matching entry.
  32.488 +      // Don't report notproduct and develop flags in product builds.
  32.489 +      if (current->is_constant_in_binary()) {
  32.490 +        return NULL;
  32.491 +      }
  32.492 +      // Report locked flags only if allowed.
  32.493        if (!(current->is_unlocked() || current->is_unlocker())) {
  32.494          if (!allow_locked) {
  32.495            // disable use of locked flags, e.g. diagnostic, experimental,
  32.496 @@ -327,8 +510,8 @@
  32.497    float score;
  32.498    float max_score = -1;
  32.499  
  32.500 -  for (Flag* current = &flagTable[0]; current->name != NULL; current++) {
  32.501 -    score = str_similar(current->name, name, length);
  32.502 +  for (Flag* current = &flagTable[0]; current->_name != NULL; current++) {
  32.503 +    score = str_similar(current->_name, name, length);
  32.504      if (score > max_score) {
  32.505        max_score = score;
  32.506        match = current;
  32.507 @@ -357,25 +540,25 @@
  32.508  bool CommandLineFlagsEx::is_default(CommandLineFlag flag) {
  32.509    assert((size_t)flag < Flag::numFlags, "bad command line flag index");
  32.510    Flag* f = &Flag::flags[flag];
  32.511 -  return (f->origin == DEFAULT);
  32.512 +  return f->is_default();
  32.513  }
  32.514  
  32.515  bool CommandLineFlagsEx::is_ergo(CommandLineFlag flag) {
  32.516    assert((size_t)flag < Flag::numFlags, "bad command line flag index");
  32.517    Flag* f = &Flag::flags[flag];
  32.518 -  return (f->origin == ERGONOMIC);
  32.519 +  return f->is_ergonomic();
  32.520  }
  32.521  
  32.522  bool CommandLineFlagsEx::is_cmdline(CommandLineFlag flag) {
  32.523    assert((size_t)flag < Flag::numFlags, "bad command line flag index");
  32.524    Flag* f = &Flag::flags[flag];
  32.525 -  return (f->origin == COMMAND_LINE);
  32.526 +  return f->is_command_line();
  32.527  }
  32.528  
  32.529  bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) {
  32.530    Flag* result = Flag::find_flag((char*)name, strlen(name));
  32.531    if (result == NULL) return false;
  32.532 -  *value = (result->origin == COMMAND_LINE);
  32.533 +  *value = result->is_command_line();
  32.534    return true;
  32.535  }
  32.536  
  32.537 @@ -387,22 +570,22 @@
  32.538    return true;
  32.539  }
  32.540  
  32.541 -bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, FlagValueOrigin origin) {
  32.542 +bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flags origin) {
  32.543    Flag* result = Flag::find_flag(name, len);
  32.544    if (result == NULL) return false;
  32.545    if (!result->is_bool()) return false;
  32.546    bool old_value = result->get_bool();
  32.547    result->set_bool(*value);
  32.548    *value = old_value;
  32.549 -  result->origin = origin;
  32.550 +  result->set_origin(origin);
  32.551    return true;
  32.552  }
  32.553  
  32.554 -void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, FlagValueOrigin origin) {
  32.555 +void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) {
  32.556    Flag* faddr = address_of_flag(flag);
  32.557    guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
  32.558    faddr->set_bool(value);
  32.559 -  faddr->origin = origin;
  32.560 +  faddr->set_origin(origin);
  32.561  }
  32.562  
  32.563  bool CommandLineFlags::intxAt(char* name, size_t len, intx* value) {
  32.564 @@ -413,22 +596,22 @@
  32.565    return true;
  32.566  }
  32.567  
  32.568 -bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, FlagValueOrigin origin) {
  32.569 +bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flags origin) {
  32.570    Flag* result = Flag::find_flag(name, len);
  32.571    if (result == NULL) return false;
  32.572    if (!result->is_intx()) return false;
  32.573    intx old_value = result->get_intx();
  32.574    result->set_intx(*value);
  32.575    *value = old_value;
  32.576 -  result->origin = origin;
  32.577 +  result->set_origin(origin);
  32.578    return true;
  32.579  }
  32.580  
  32.581 -void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, FlagValueOrigin origin) {
  32.582 +void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) {
  32.583    Flag* faddr = address_of_flag(flag);
  32.584    guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
  32.585    faddr->set_intx(value);
  32.586 -  faddr->origin = origin;
  32.587 +  faddr->set_origin(origin);
  32.588  }
  32.589  
  32.590  bool CommandLineFlags::uintxAt(char* name, size_t len, uintx* value) {
  32.591 @@ -439,22 +622,22 @@
  32.592    return true;
  32.593  }
  32.594  
  32.595 -bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, FlagValueOrigin origin) {
  32.596 +bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Flags origin) {
  32.597    Flag* result = Flag::find_flag(name, len);
  32.598    if (result == NULL) return false;
  32.599    if (!result->is_uintx()) return false;
  32.600    uintx old_value = result->get_uintx();
  32.601    result->set_uintx(*value);
  32.602    *value = old_value;
  32.603 -  result->origin = origin;
  32.604 +  result->set_origin(origin);
  32.605    return true;
  32.606  }
  32.607  
  32.608 -void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, FlagValueOrigin origin) {
  32.609 +void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) {
  32.610    Flag* faddr = address_of_flag(flag);
  32.611    guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
  32.612    faddr->set_uintx(value);
  32.613 -  faddr->origin = origin;
  32.614 +  faddr->set_origin(origin);
  32.615  }
  32.616  
  32.617  bool CommandLineFlags::uint64_tAt(char* name, size_t len, uint64_t* value) {
  32.618 @@ -465,22 +648,22 @@
  32.619    return true;
  32.620  }
  32.621  
  32.622 -bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, FlagValueOrigin origin) {
  32.623 +bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Flag::Flags origin) {
  32.624    Flag* result = Flag::find_flag(name, len);
  32.625    if (result == NULL) return false;
  32.626    if (!result->is_uint64_t()) return false;
  32.627    uint64_t old_value = result->get_uint64_t();
  32.628    result->set_uint64_t(*value);
  32.629    *value = old_value;
  32.630 -  result->origin = origin;
  32.631 +  result->set_origin(origin);
  32.632    return true;
  32.633  }
  32.634  
  32.635 -void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, FlagValueOrigin origin) {
  32.636 +void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) {
  32.637    Flag* faddr = address_of_flag(flag);
  32.638    guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
  32.639    faddr->set_uint64_t(value);
  32.640 -  faddr->origin = origin;
  32.641 +  faddr->set_origin(origin);
  32.642  }
  32.643  
  32.644  bool CommandLineFlags::doubleAt(char* name, size_t len, double* value) {
  32.645 @@ -491,22 +674,22 @@
  32.646    return true;
  32.647  }
  32.648  
  32.649 -bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, FlagValueOrigin origin) {
  32.650 +bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::Flags origin) {
  32.651    Flag* result = Flag::find_flag(name, len);
  32.652    if (result == NULL) return false;
  32.653    if (!result->is_double()) return false;
  32.654    double old_value = result->get_double();
  32.655    result->set_double(*value);
  32.656    *value = old_value;
  32.657 -  result->origin = origin;
  32.658 +  result->set_origin(origin);
  32.659    return true;
  32.660  }
  32.661  
  32.662 -void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, FlagValueOrigin origin) {
  32.663 +void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
  32.664    Flag* faddr = address_of_flag(flag);
  32.665    guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
  32.666    faddr->set_double(value);
  32.667 -  faddr->origin = origin;
  32.668 +  faddr->set_origin(origin);
  32.669  }
  32.670  
  32.671  bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) {
  32.672 @@ -519,7 +702,7 @@
  32.673  
  32.674  // Contract:  Flag will make private copy of the incoming value.
  32.675  // Outgoing value is always malloc-ed, and caller MUST call free.
  32.676 -bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, FlagValueOrigin origin) {
  32.677 +bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin) {
  32.678    Flag* result = Flag::find_flag(name, len);
  32.679    if (result == NULL) return false;
  32.680    if (!result->is_ccstr()) return false;
  32.681 @@ -530,35 +713,35 @@
  32.682      strcpy(new_value, *value);
  32.683    }
  32.684    result->set_ccstr(new_value);
  32.685 -  if (result->origin == DEFAULT && old_value != NULL) {
  32.686 +  if (result->is_default() && old_value != NULL) {
  32.687      // Prior value is NOT heap allocated, but was a literal constant.
  32.688      char* old_value_to_free = NEW_C_HEAP_ARRAY(char, strlen(old_value)+1, mtInternal);
  32.689      strcpy(old_value_to_free, old_value);
  32.690      old_value = old_value_to_free;
  32.691    }
  32.692    *value = old_value;
  32.693 -  result->origin = origin;
  32.694 +  result->set_origin(origin);
  32.695    return true;
  32.696  }
  32.697  
  32.698  // Contract:  Flag will make private copy of the incoming value.
  32.699 -void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, FlagValueOrigin origin) {
  32.700 +void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) {
  32.701    Flag* faddr = address_of_flag(flag);
  32.702    guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
  32.703    ccstr old_value = faddr->get_ccstr();
  32.704    char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1, mtInternal);
  32.705    strcpy(new_value, value);
  32.706    faddr->set_ccstr(new_value);
  32.707 -  if (faddr->origin != DEFAULT && old_value != NULL) {
  32.708 +  if (!faddr->is_default() && old_value != NULL) {
  32.709      // Prior value is heap allocated so free it.
  32.710      FREE_C_HEAP_ARRAY(char, old_value, mtInternal);
  32.711    }
  32.712 -  faddr->origin = origin;
  32.713 +  faddr->set_origin(origin);
  32.714  }
  32.715  
  32.716  extern "C" {
  32.717    static int compare_flags(const void* void_a, const void* void_b) {
  32.718 -    return strcmp((*((Flag**) void_a))->name, (*((Flag**) void_b))->name);
  32.719 +    return strcmp((*((Flag**) void_a))->_name, (*((Flag**) void_b))->_name);
  32.720    }
  32.721  }
  32.722  
  32.723 @@ -567,20 +750,19 @@
  32.724    // note: this method is called before the thread structure is in place
  32.725    //       which means resource allocation cannot be used.
  32.726  
  32.727 -  // Compute size
  32.728 -  int length= 0;
  32.729 -  while (flagTable[length].name != NULL) length++;
  32.730 +  // The last entry is the null entry.
  32.731 +  const size_t length = Flag::numFlags - 1;
  32.732  
  32.733    // Sort
  32.734    Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal);
  32.735 -  for (int index = 0; index < length; index++) {
  32.736 -    array[index] = &flagTable[index];
  32.737 +  for (size_t i = 0; i < length; i++) {
  32.738 +    array[i] = &flagTable[i];
  32.739    }
  32.740    qsort(array, length, sizeof(Flag*), compare_flags);
  32.741  
  32.742    // Print
  32.743 -  for (int i = 0; i < length; i++) {
  32.744 -    if (array[i]->origin /* naked field! */) {
  32.745 +  for (size_t i = 0; i < length; i++) {
  32.746 +    if (array[i]->get_origin() /* naked field! */) {
  32.747        array[i]->print_as_flag(out);
  32.748        out->print(" ");
  32.749      }
  32.750 @@ -603,20 +785,19 @@
  32.751    // note: this method is called before the thread structure is in place
  32.752    //       which means resource allocation cannot be used.
  32.753  
  32.754 -  // Compute size
  32.755 -  int length= 0;
  32.756 -  while (flagTable[length].name != NULL) length++;
  32.757 +  // The last entry is the null entry.
  32.758 +  const size_t length = Flag::numFlags - 1;
  32.759  
  32.760    // Sort
  32.761    Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal);
  32.762 -  for (int index = 0; index < length; index++) {
  32.763 -    array[index] = &flagTable[index];
  32.764 +  for (size_t i = 0; i < length; i++) {
  32.765 +    array[i] = &flagTable[i];
  32.766    }
  32.767    qsort(array, length, sizeof(Flag*), compare_flags);
  32.768  
  32.769    // Print
  32.770    out->print_cr("[Global flags]");
  32.771 -  for (int i = 0; i < length; i++) {
  32.772 +  for (size_t i = 0; i < length; i++) {
  32.773      if (array[i]->is_unlocked()) {
  32.774        array[i]->print_on(out, withComments);
  32.775      }
    33.1 --- a/src/share/vm/runtime/globals.hpp	Thu Sep 26 08:48:15 2013 +0200
    33.2 +++ b/src/share/vm/runtime/globals.hpp	Fri Sep 27 12:43:51 2013 -0700
    33.3 @@ -194,29 +194,49 @@
    33.4  typedef const char* ccstr;
    33.5  typedef const char* ccstrlist;   // represents string arguments which accumulate
    33.6  
    33.7 -enum FlagValueOrigin {
    33.8 -  DEFAULT          = 0,
    33.9 -  COMMAND_LINE     = 1,
   33.10 -  ENVIRON_VAR      = 2,
   33.11 -  CONFIG_FILE      = 3,
   33.12 -  MANAGEMENT       = 4,
   33.13 -  ERGONOMIC        = 5,
   33.14 -  ATTACH_ON_DEMAND = 6,
   33.15 -  INTERNAL         = 99
   33.16 -};
   33.17 +struct Flag {
   33.18 +  enum Flags {
   33.19 +    // value origin
   33.20 +    DEFAULT          = 0,
   33.21 +    COMMAND_LINE     = 1,
   33.22 +    ENVIRON_VAR      = 2,
   33.23 +    CONFIG_FILE      = 3,
   33.24 +    MANAGEMENT       = 4,
   33.25 +    ERGONOMIC        = 5,
   33.26 +    ATTACH_ON_DEMAND = 6,
   33.27 +    INTERNAL         = 7,
   33.28  
   33.29 -struct Flag {
   33.30 -  const char *type;
   33.31 -  const char *name;
   33.32 -  void*       addr;
   33.33 +    LAST_VALUE_ORIGIN = INTERNAL,
   33.34 +    VALUE_ORIGIN_BITS = 4,
   33.35 +    VALUE_ORIGIN_MASK = right_n_bits(VALUE_ORIGIN_BITS),
   33.36  
   33.37 -  NOT_PRODUCT(const char *doc;)
   33.38 +    // flag kind
   33.39 +    KIND_PRODUCT            = 1 << 4,
   33.40 +    KIND_MANAGEABLE         = 1 << 5,
   33.41 +    KIND_DIAGNOSTIC         = 1 << 6,
   33.42 +    KIND_EXPERIMENTAL       = 1 << 7,
   33.43 +    KIND_NOT_PRODUCT        = 1 << 8,
   33.44 +    KIND_DEVELOP            = 1 << 9,
   33.45 +    KIND_PLATFORM_DEPENDENT = 1 << 10,
   33.46 +    KIND_READ_WRITE         = 1 << 11,
   33.47 +    KIND_C1                 = 1 << 12,
   33.48 +    KIND_C2                 = 1 << 13,
   33.49 +    KIND_ARCH               = 1 << 14,
   33.50 +    KIND_SHARK              = 1 << 15,
   33.51 +    KIND_LP64_PRODUCT       = 1 << 16,
   33.52 +    KIND_COMMERCIAL         = 1 << 17,
   33.53  
   33.54 -  const char *kind;
   33.55 -  FlagValueOrigin origin;
   33.56 +    KIND_MASK = ~VALUE_ORIGIN_MASK
   33.57 +  };
   33.58 +
   33.59 +  const char* _type;
   33.60 +  const char* _name;
   33.61 +  void* _addr;
   33.62 +  NOT_PRODUCT(const char* _doc;)
   33.63 +  Flags _flags;
   33.64  
   33.65    // points to all Flags static array
   33.66 -  static Flag *flags;
   33.67 +  static Flag* flags;
   33.68  
   33.69    // number of flags
   33.70    static size_t numFlags;
   33.71 @@ -224,30 +244,50 @@
   33.72    static Flag* find_flag(const char* name, size_t length, bool allow_locked = false);
   33.73    static Flag* fuzzy_match(const char* name, size_t length, bool allow_locked = false);
   33.74  
   33.75 -  bool is_bool() const        { return strcmp(type, "bool") == 0; }
   33.76 -  bool get_bool() const       { return *((bool*) addr); }
   33.77 -  void set_bool(bool value)   { *((bool*) addr) = value; }
   33.78 +  void check_writable();
   33.79  
   33.80 -  bool is_intx()  const       { return strcmp(type, "intx")  == 0; }
   33.81 -  intx get_intx() const       { return *((intx*) addr); }
   33.82 -  void set_intx(intx value)   { *((intx*) addr) = value; }
   33.83 +  bool is_bool() const;
   33.84 +  bool get_bool() const;
   33.85 +  void set_bool(bool value);
   33.86  
   33.87 -  bool is_uintx() const       { return strcmp(type, "uintx") == 0; }
   33.88 -  uintx get_uintx() const     { return *((uintx*) addr); }
   33.89 -  void set_uintx(uintx value) { *((uintx*) addr) = value; }
   33.90 +  bool is_intx() const;
   33.91 +  intx get_intx() const;
   33.92 +  void set_intx(intx value);
   33.93  
   33.94 -  bool is_uint64_t() const          { return strcmp(type, "uint64_t") == 0; }
   33.95 -  uint64_t get_uint64_t() const     { return *((uint64_t*) addr); }
   33.96 -  void set_uint64_t(uint64_t value) { *((uint64_t*) addr) = value; }
   33.97 +  bool is_uintx() const;
   33.98 +  uintx get_uintx() const;
   33.99 +  void set_uintx(uintx value);
  33.100  
  33.101 -  bool is_double() const        { return strcmp(type, "double") == 0; }
  33.102 -  double get_double() const     { return *((double*) addr); }
  33.103 -  void set_double(double value) { *((double*) addr) = value; }
  33.104 +  bool is_uint64_t() const;
  33.105 +  uint64_t get_uint64_t() const;
  33.106 +  void set_uint64_t(uint64_t value);
  33.107  
  33.108 -  bool is_ccstr() const          { return strcmp(type, "ccstr") == 0 || strcmp(type, "ccstrlist") == 0; }
  33.109 -  bool ccstr_accumulates() const { return strcmp(type, "ccstrlist") == 0; }
  33.110 -  ccstr get_ccstr() const     { return *((ccstr*) addr); }
  33.111 -  void set_ccstr(ccstr value) { *((ccstr*) addr) = value; }
  33.112 +  bool is_double() const;
  33.113 +  double get_double() const;
  33.114 +  void set_double(double value);
  33.115 +
  33.116 +  bool is_ccstr() const;
  33.117 +  bool ccstr_accumulates() const;
  33.118 +  ccstr get_ccstr() const;
  33.119 +  void set_ccstr(ccstr value);
  33.120 +
  33.121 +  Flags get_origin();
  33.122 +  void set_origin(Flags origin);
  33.123 +
  33.124 +  bool is_default();
  33.125 +  bool is_ergonomic();
  33.126 +  bool is_command_line();
  33.127 +
  33.128 +  bool is_product() const;
  33.129 +  bool is_manageable() const;
  33.130 +  bool is_diagnostic() const;
  33.131 +  bool is_experimental() const;
  33.132 +  bool is_notproduct() const;
  33.133 +  bool is_develop() const;
  33.134 +  bool is_read_write() const;
  33.135 +  bool is_commercial() const;
  33.136 +
  33.137 +  bool is_constant_in_binary() const;
  33.138  
  33.139    bool is_unlocker() const;
  33.140    bool is_unlocked() const;
  33.141 @@ -263,6 +303,7 @@
  33.142    void get_locked_message_ext(char*, int) const;
  33.143  
  33.144    void print_on(outputStream* st, bool withComments = false );
  33.145 +  void print_kind(outputStream* st);
  33.146    void print_as_flag(outputStream* st);
  33.147  };
  33.148  
  33.149 @@ -310,33 +351,33 @@
  33.150   public:
  33.151    static bool boolAt(char* name, size_t len, bool* value);
  33.152    static bool boolAt(char* name, bool* value)      { return boolAt(name, strlen(name), value); }
  33.153 -  static bool boolAtPut(char* name, size_t len, bool* value, FlagValueOrigin origin);
  33.154 -  static bool boolAtPut(char* name, bool* value, FlagValueOrigin origin)   { return boolAtPut(name, strlen(name), value, origin); }
  33.155 +  static bool boolAtPut(char* name, size_t len, bool* value, Flag::Flags origin);
  33.156 +  static bool boolAtPut(char* name, bool* value, Flag::Flags origin)   { return boolAtPut(name, strlen(name), value, origin); }
  33.157  
  33.158    static bool intxAt(char* name, size_t len, intx* value);
  33.159    static bool intxAt(char* name, intx* value)      { return intxAt(name, strlen(name), value); }
  33.160 -  static bool intxAtPut(char* name, size_t len, intx* value, FlagValueOrigin origin);
  33.161 -  static bool intxAtPut(char* name, intx* value, FlagValueOrigin origin)   { return intxAtPut(name, strlen(name), value, origin); }
  33.162 +  static bool intxAtPut(char* name, size_t len, intx* value, Flag::Flags origin);
  33.163 +  static bool intxAtPut(char* name, intx* value, Flag::Flags origin)   { return intxAtPut(name, strlen(name), value, origin); }
  33.164  
  33.165    static bool uintxAt(char* name, size_t len, uintx* value);
  33.166    static bool uintxAt(char* name, uintx* value)    { return uintxAt(name, strlen(name), value); }
  33.167 -  static bool uintxAtPut(char* name, size_t len, uintx* value, FlagValueOrigin origin);
  33.168 -  static bool uintxAtPut(char* name, uintx* value, FlagValueOrigin origin) { return uintxAtPut(name, strlen(name), value, origin); }
  33.169 +  static bool uintxAtPut(char* name, size_t len, uintx* value, Flag::Flags origin);
  33.170 +  static bool uintxAtPut(char* name, uintx* value, Flag::Flags origin) { return uintxAtPut(name, strlen(name), value, origin); }
  33.171  
  33.172    static bool uint64_tAt(char* name, size_t len, uint64_t* value);
  33.173    static bool uint64_tAt(char* name, uint64_t* value) { return uint64_tAt(name, strlen(name), value); }
  33.174 -  static bool uint64_tAtPut(char* name, size_t len, uint64_t* value, FlagValueOrigin origin);
  33.175 -  static bool uint64_tAtPut(char* name, uint64_t* value, FlagValueOrigin origin) { return uint64_tAtPut(name, strlen(name), value, origin); }
  33.176 +  static bool uint64_tAtPut(char* name, size_t len, uint64_t* value, Flag::Flags origin);
  33.177 +  static bool uint64_tAtPut(char* name, uint64_t* value, Flag::Flags origin) { return uint64_tAtPut(name, strlen(name), value, origin); }
  33.178  
  33.179    static bool doubleAt(char* name, size_t len, double* value);
  33.180    static bool doubleAt(char* name, double* value)    { return doubleAt(name, strlen(name), value); }
  33.181 -  static bool doubleAtPut(char* name, size_t len, double* value, FlagValueOrigin origin);
  33.182 -  static bool doubleAtPut(char* name, double* value, FlagValueOrigin origin) { return doubleAtPut(name, strlen(name), value, origin); }
  33.183 +  static bool doubleAtPut(char* name, size_t len, double* value, Flag::Flags origin);
  33.184 +  static bool doubleAtPut(char* name, double* value, Flag::Flags origin) { return doubleAtPut(name, strlen(name), value, origin); }
  33.185  
  33.186    static bool ccstrAt(char* name, size_t len, ccstr* value);
  33.187    static bool ccstrAt(char* name, ccstr* value)    { return ccstrAt(name, strlen(name), value); }
  33.188 -  static bool ccstrAtPut(char* name, size_t len, ccstr* value, FlagValueOrigin origin);
  33.189 -  static bool ccstrAtPut(char* name, ccstr* value, FlagValueOrigin origin) { return ccstrAtPut(name, strlen(name), value, origin); }
  33.190 +  static bool ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin);
  33.191 +  static bool ccstrAtPut(char* name, ccstr* value, Flag::Flags origin) { return ccstrAtPut(name, strlen(name), value, origin); }
  33.192  
  33.193    // Returns false if name is not a command line flag.
  33.194    static bool wasSetOnCmdline(const char* name, bool* value);
  33.195 @@ -3730,20 +3771,20 @@
  33.196   */
  33.197  
  33.198  // Interface macros
  33.199 -#define DECLARE_PRODUCT_FLAG(type, name, value, doc)    extern "C" type name;
  33.200 -#define DECLARE_PD_PRODUCT_FLAG(type, name, doc)        extern "C" type name;
  33.201 -#define DECLARE_DIAGNOSTIC_FLAG(type, name, value, doc) extern "C" type name;
  33.202 +#define DECLARE_PRODUCT_FLAG(type, name, value, doc)      extern "C" type name;
  33.203 +#define DECLARE_PD_PRODUCT_FLAG(type, name, doc)          extern "C" type name;
  33.204 +#define DECLARE_DIAGNOSTIC_FLAG(type, name, value, doc)   extern "C" type name;
  33.205  #define DECLARE_EXPERIMENTAL_FLAG(type, name, value, doc) extern "C" type name;
  33.206 -#define DECLARE_MANAGEABLE_FLAG(type, name, value, doc) extern "C" type name;
  33.207 -#define DECLARE_PRODUCT_RW_FLAG(type, name, value, doc) extern "C" type name;
  33.208 +#define DECLARE_MANAGEABLE_FLAG(type, name, value, doc)   extern "C" type name;
  33.209 +#define DECLARE_PRODUCT_RW_FLAG(type, name, value, doc)   extern "C" type name;
  33.210  #ifdef PRODUCT
  33.211 -#define DECLARE_DEVELOPER_FLAG(type, name, value, doc)  const type name = value;
  33.212 -#define DECLARE_PD_DEVELOPER_FLAG(type, name, doc)      const type name = pd_##name;
  33.213 -#define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc)
  33.214 +#define DECLARE_DEVELOPER_FLAG(type, name, value, doc)    extern "C" type CONST_##name; const type name = value;
  33.215 +#define DECLARE_PD_DEVELOPER_FLAG(type, name, doc)        extern "C" type CONST_##name; const type name = pd_##name;
  33.216 +#define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc)   extern "C" type CONST_##name;
  33.217  #else
  33.218 -#define DECLARE_DEVELOPER_FLAG(type, name, value, doc)  extern "C" type name;
  33.219 -#define DECLARE_PD_DEVELOPER_FLAG(type, name, doc)      extern "C" type name;
  33.220 -#define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc)  extern "C" type name;
  33.221 +#define DECLARE_DEVELOPER_FLAG(type, name, value, doc)    extern "C" type name;
  33.222 +#define DECLARE_PD_DEVELOPER_FLAG(type, name, doc)        extern "C" type name;
  33.223 +#define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc)   extern "C" type name;
  33.224  #endif
  33.225  // Special LP64 flags, product only needed for now.
  33.226  #ifdef _LP64
  33.227 @@ -3753,23 +3794,23 @@
  33.228  #endif // _LP64
  33.229  
  33.230  // Implementation macros
  33.231 -#define MATERIALIZE_PRODUCT_FLAG(type, name, value, doc)   type name = value;
  33.232 -#define MATERIALIZE_PD_PRODUCT_FLAG(type, name, doc)       type name = pd_##name;
  33.233 -#define MATERIALIZE_DIAGNOSTIC_FLAG(type, name, value, doc) type name = value;
  33.234 +#define MATERIALIZE_PRODUCT_FLAG(type, name, value, doc)      type name = value;
  33.235 +#define MATERIALIZE_PD_PRODUCT_FLAG(type, name, doc)          type name = pd_##name;
  33.236 +#define MATERIALIZE_DIAGNOSTIC_FLAG(type, name, value, doc)   type name = value;
  33.237  #define MATERIALIZE_EXPERIMENTAL_FLAG(type, name, value, doc) type name = value;
  33.238 -#define MATERIALIZE_MANAGEABLE_FLAG(type, name, value, doc) type name = value;
  33.239 -#define MATERIALIZE_PRODUCT_RW_FLAG(type, name, value, doc) type name = value;
  33.240 +#define MATERIALIZE_MANAGEABLE_FLAG(type, name, value, doc)   type name = value;
  33.241 +#define MATERIALIZE_PRODUCT_RW_FLAG(type, name, value, doc)   type name = value;
  33.242  #ifdef PRODUCT
  33.243 -#define MATERIALIZE_DEVELOPER_FLAG(type, name, value, doc) /* flag name is constant */
  33.244 -#define MATERIALIZE_PD_DEVELOPER_FLAG(type, name, doc)     /* flag name is constant */
  33.245 -#define MATERIALIZE_NOTPRODUCT_FLAG(type, name, value, doc)
  33.246 +#define MATERIALIZE_DEVELOPER_FLAG(type, name, value, doc)    type CONST_##name = value;
  33.247 +#define MATERIALIZE_PD_DEVELOPER_FLAG(type, name, doc)        type CONST_##name = pd_##name;
  33.248 +#define MATERIALIZE_NOTPRODUCT_FLAG(type, name, value, doc)   type CONST_##name = value;
  33.249  #else
  33.250 -#define MATERIALIZE_DEVELOPER_FLAG(type, name, value, doc) type name = value;
  33.251 -#define MATERIALIZE_PD_DEVELOPER_FLAG(type, name, doc)     type name = pd_##name;
  33.252 -#define MATERIALIZE_NOTPRODUCT_FLAG(type, name, value, doc) type name = value;
  33.253 +#define MATERIALIZE_DEVELOPER_FLAG(type, name, value, doc)    type name = value;
  33.254 +#define MATERIALIZE_PD_DEVELOPER_FLAG(type, name, doc)        type name = pd_##name;
  33.255 +#define MATERIALIZE_NOTPRODUCT_FLAG(type, name, value, doc)   type name = value;
  33.256  #endif
  33.257  #ifdef _LP64
  33.258 -#define MATERIALIZE_LP64_PRODUCT_FLAG(type, name, value, doc)   type name = value;
  33.259 +#define MATERIALIZE_LP64_PRODUCT_FLAG(type, name, value, doc) type name = value;
  33.260  #else
  33.261  #define MATERIALIZE_LP64_PRODUCT_FLAG(type, name, value, doc) /* flag is constant */
  33.262  #endif // _LP64
    34.1 --- a/src/share/vm/runtime/globals_extension.hpp	Thu Sep 26 08:48:15 2013 +0200
    34.2 +++ b/src/share/vm/runtime/globals_extension.hpp	Fri Sep 27 12:43:51 2013 -0700
    34.3 @@ -34,64 +34,42 @@
    34.4  // Parens left off in the following for the enum decl below.
    34.5  #define FLAG_MEMBER(flag) Flag_##flag
    34.6  
    34.7 -#define RUNTIME_PRODUCT_FLAG_MEMBER(type, name, value, doc)    FLAG_MEMBER(name),
    34.8 -#define RUNTIME_PD_PRODUCT_FLAG_MEMBER(type, name, doc)        FLAG_MEMBER(name),
    34.9 -#define RUNTIME_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name),
   34.10 +#define RUNTIME_PRODUCT_FLAG_MEMBER(type, name, value, doc)      FLAG_MEMBER(name),
   34.11 +#define RUNTIME_PD_PRODUCT_FLAG_MEMBER(type, name, doc)          FLAG_MEMBER(name),
   34.12 +#define RUNTIME_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc)   FLAG_MEMBER(name),
   34.13  #define RUNTIME_EXPERIMENTAL_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name),
   34.14 -#define RUNTIME_MANAGEABLE_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name),
   34.15 -#define RUNTIME_PRODUCT_RW_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name),
   34.16 -#ifdef PRODUCT
   34.17 -  #define RUNTIME_DEVELOP_FLAG_MEMBER(type, name, value, doc)  /* flag is constant */
   34.18 -  #define RUNTIME_PD_DEVELOP_FLAG_MEMBER(type, name, doc)      /* flag is constant */
   34.19 -  #define RUNTIME_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc)
   34.20 +#define RUNTIME_MANAGEABLE_FLAG_MEMBER(type, name, value, doc)   FLAG_MEMBER(name),
   34.21 +#define RUNTIME_PRODUCT_RW_FLAG_MEMBER(type, name, value, doc)   FLAG_MEMBER(name),
   34.22 +#define RUNTIME_DEVELOP_FLAG_MEMBER(type, name, value, doc)      FLAG_MEMBER(name),
   34.23 +#define RUNTIME_PD_DEVELOP_FLAG_MEMBER(type, name, doc)          FLAG_MEMBER(name),
   34.24 +#define RUNTIME_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc)   FLAG_MEMBER(name),
   34.25 +
   34.26 +#ifdef _LP64
   34.27 +#define RUNTIME_LP64_PRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name),
   34.28  #else
   34.29 -  #define RUNTIME_DEVELOP_FLAG_MEMBER(type, name, value, doc)  FLAG_MEMBER(name),
   34.30 -  #define RUNTIME_PD_DEVELOP_FLAG_MEMBER(type, name, doc)      FLAG_MEMBER(name),
   34.31 -  #define RUNTIME_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name),
   34.32 -#endif
   34.33 -#ifdef _LP64
   34.34 -#define RUNTIME_LP64_PRODUCT_FLAG_MEMBER(type, name, value, doc)    FLAG_MEMBER(name),
   34.35 -#else
   34.36 -#define RUNTIME_LP64_PRODUCT_FLAG_MEMBER(type, name, value, doc)    /* flag is constant */
   34.37 +#define RUNTIME_LP64_PRODUCT_FLAG_MEMBER(type, name, value, doc) /* flag is constant */
   34.38  #endif // _LP64
   34.39  
   34.40 -#define C1_PRODUCT_FLAG_MEMBER(type, name, value, doc)         FLAG_MEMBER(name),
   34.41 -#define C1_PD_PRODUCT_FLAG_MEMBER(type, name, doc)             FLAG_MEMBER(name),
   34.42 -#define C1_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc)      FLAG_MEMBER(name),
   34.43 -#ifdef PRODUCT
   34.44 -  #define C1_DEVELOP_FLAG_MEMBER(type, name, value, doc)       /* flag is constant */
   34.45 -  #define C1_PD_DEVELOP_FLAG_MEMBER(type, name, doc)           /* flag is constant */
   34.46 -  #define C1_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc)
   34.47 -#else
   34.48 -  #define C1_DEVELOP_FLAG_MEMBER(type, name, value, doc)       FLAG_MEMBER(name),
   34.49 -  #define C1_PD_DEVELOP_FLAG_MEMBER(type, name, doc)           FLAG_MEMBER(name),
   34.50 -  #define C1_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc)    FLAG_MEMBER(name),
   34.51 -#endif
   34.52 +#define C1_PRODUCT_FLAG_MEMBER(type, name, value, doc)           FLAG_MEMBER(name),
   34.53 +#define C1_PD_PRODUCT_FLAG_MEMBER(type, name, doc)               FLAG_MEMBER(name),
   34.54 +#define C1_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc)        FLAG_MEMBER(name),
   34.55 +#define C1_DEVELOP_FLAG_MEMBER(type, name, value, doc)           FLAG_MEMBER(name),
   34.56 +#define C1_PD_DEVELOP_FLAG_MEMBER(type, name, doc)               FLAG_MEMBER(name),
   34.57 +#define C1_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc)        FLAG_MEMBER(name),
   34.58  
   34.59 -#define C2_PRODUCT_FLAG_MEMBER(type, name, value, doc)         FLAG_MEMBER(name),
   34.60 -#define C2_PD_PRODUCT_FLAG_MEMBER(type, name, doc)             FLAG_MEMBER(name),
   34.61 -#define C2_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc)      FLAG_MEMBER(name),
   34.62 -#define C2_EXPERIMENTAL_FLAG_MEMBER(type, name, value, doc)    FLAG_MEMBER(name),
   34.63 -#ifdef PRODUCT
   34.64 -  #define C2_DEVELOP_FLAG_MEMBER(type, name, value, doc)       /* flag is constant */
   34.65 -  #define C2_PD_DEVELOP_FLAG_MEMBER(type, name, doc)           /* flag is constant */
   34.66 -  #define C2_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc)
   34.67 -#else
   34.68 -  #define C2_DEVELOP_FLAG_MEMBER(type, name, value, doc)       FLAG_MEMBER(name),
   34.69 -  #define C2_PD_DEVELOP_FLAG_MEMBER(type, name, doc)           FLAG_MEMBER(name),
   34.70 -  #define C2_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc)    FLAG_MEMBER(name),
   34.71 -#endif
   34.72 +#define C2_PRODUCT_FLAG_MEMBER(type, name, value, doc)           FLAG_MEMBER(name),
   34.73 +#define C2_PD_PRODUCT_FLAG_MEMBER(type, name, doc)               FLAG_MEMBER(name),
   34.74 +#define C2_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc)        FLAG_MEMBER(name),
   34.75 +#define C2_EXPERIMENTAL_FLAG_MEMBER(type, name, value, doc)      FLAG_MEMBER(name),
   34.76 +#define C2_DEVELOP_FLAG_MEMBER(type, name, value, doc)           FLAG_MEMBER(name),
   34.77 +#define C2_PD_DEVELOP_FLAG_MEMBER(type, name, doc)               FLAG_MEMBER(name),
   34.78 +#define C2_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc)        FLAG_MEMBER(name),
   34.79  
   34.80  #define ARCH_PRODUCT_FLAG_MEMBER(type, name, value, doc)         FLAG_MEMBER(name),
   34.81  #define ARCH_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc)      FLAG_MEMBER(name),
   34.82  #define ARCH_EXPERIMENTAL_FLAG_MEMBER(type, name, value, doc)    FLAG_MEMBER(name),
   34.83 -#ifdef PRODUCT
   34.84 -  #define ARCH_DEVELOP_FLAG_MEMBER(type, name, value, doc)       /* flag is constant */
   34.85 -  #define ARCH_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc)
   34.86 -#else
   34.87 -  #define ARCH_DEVELOP_FLAG_MEMBER(type, name, value, doc)       FLAG_MEMBER(name),
   34.88 -  #define ARCH_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc)    FLAG_MEMBER(name),
   34.89 -#endif
   34.90 +#define ARCH_DEVELOP_FLAG_MEMBER(type, name, value, doc)         FLAG_MEMBER(name),
   34.91 +#define ARCH_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc)      FLAG_MEMBER(name),
   34.92  
   34.93  typedef enum {
   34.94   RUNTIME_FLAGS(RUNTIME_DEVELOP_FLAG_MEMBER, RUNTIME_PD_DEVELOP_FLAG_MEMBER, RUNTIME_PRODUCT_FLAG_MEMBER, RUNTIME_PD_PRODUCT_FLAG_MEMBER, RUNTIME_DIAGNOSTIC_FLAG_MEMBER, RUNTIME_EXPERIMENTAL_FLAG_MEMBER, RUNTIME_NOTPRODUCT_FLAG_MEMBER, RUNTIME_MANAGEABLE_FLAG_MEMBER, RUNTIME_PRODUCT_RW_FLAG_MEMBER, RUNTIME_LP64_PRODUCT_FLAG_MEMBER)
   34.95 @@ -114,64 +92,42 @@
   34.96  
   34.97  #define FLAG_MEMBER_WITH_TYPE(flag,type) Flag_##flag##_##type
   34.98  
   34.99 -#define RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)    FLAG_MEMBER_WITH_TYPE(name,type),
  34.100 -#define RUNTIME_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc)        FLAG_MEMBER_WITH_TYPE(name,type),
  34.101 -#define RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type),
  34.102 +#define RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)      FLAG_MEMBER_WITH_TYPE(name,type),
  34.103 +#define RUNTIME_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc)          FLAG_MEMBER_WITH_TYPE(name,type),
  34.104 +#define RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)   FLAG_MEMBER_WITH_TYPE(name,type),
  34.105  #define RUNTIME_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type),
  34.106 -#define RUNTIME_MANAGEABLE_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type),
  34.107 -#define RUNTIME_PRODUCT_RW_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type),
  34.108 -#ifdef PRODUCT
  34.109 -  #define RUNTIME_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)     /* flag is constant */
  34.110 -  #define RUNTIME_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc)         /* flag is constant */
  34.111 -  #define RUNTIME_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)
  34.112 +#define RUNTIME_MANAGEABLE_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)   FLAG_MEMBER_WITH_TYPE(name,type),
  34.113 +#define RUNTIME_PRODUCT_RW_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)   FLAG_MEMBER_WITH_TYPE(name,type),
  34.114 +#define RUNTIME_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)      FLAG_MEMBER_WITH_TYPE(name,type),
  34.115 +#define RUNTIME_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc)          FLAG_MEMBER_WITH_TYPE(name,type),
  34.116 +#define RUNTIME_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)   FLAG_MEMBER_WITH_TYPE(name,type),
  34.117 +
  34.118 +#define C1_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)           FLAG_MEMBER_WITH_TYPE(name,type),
  34.119 +#define C1_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc)               FLAG_MEMBER_WITH_TYPE(name,type),
  34.120 +#define C1_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)        FLAG_MEMBER_WITH_TYPE(name,type),
  34.121 +#define C1_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)           FLAG_MEMBER_WITH_TYPE(name,type),
  34.122 +#define C1_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc)               FLAG_MEMBER_WITH_TYPE(name,type),
  34.123 +#define C1_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)        FLAG_MEMBER_WITH_TYPE(name,type),
  34.124 +
  34.125 +#ifdef _LP64
  34.126 +#define RUNTIME_LP64_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type),
  34.127  #else
  34.128 -  #define RUNTIME_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)     FLAG_MEMBER_WITH_TYPE(name,type),
  34.129 -  #define RUNTIME_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc)         FLAG_MEMBER_WITH_TYPE(name,type),
  34.130 -  #define RUNTIME_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)  FLAG_MEMBER_WITH_TYPE(name,type),
  34.131 -#endif
  34.132 -
  34.133 -#define C1_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)         FLAG_MEMBER_WITH_TYPE(name,type),
  34.134 -#define C1_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc)             FLAG_MEMBER_WITH_TYPE(name,type),
  34.135 -#define C1_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)      FLAG_MEMBER_WITH_TYPE(name,type),
  34.136 -#ifdef PRODUCT
  34.137 -  #define C1_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)       /* flag is constant */
  34.138 -  #define C1_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc)           /* flag is constant */
  34.139 -  #define C1_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)
  34.140 -#else
  34.141 -  #define C1_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)       FLAG_MEMBER_WITH_TYPE(name,type),
  34.142 -  #define C1_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc)           FLAG_MEMBER_WITH_TYPE(name,type),
  34.143 -  #define C1_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)    FLAG_MEMBER_WITH_TYPE(name,type),
  34.144 -#endif
  34.145 -#ifdef _LP64
  34.146 -#define RUNTIME_LP64_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)    FLAG_MEMBER_WITH_TYPE(name,type),
  34.147 -#else
  34.148 -#define RUNTIME_LP64_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)    /* flag is constant */
  34.149 +#define RUNTIME_LP64_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) /* flag is constant */
  34.150  #endif // _LP64
  34.151  
  34.152 -#define C2_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)         FLAG_MEMBER_WITH_TYPE(name,type),
  34.153 -#define C2_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc)             FLAG_MEMBER_WITH_TYPE(name,type),
  34.154 -#define C2_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)      FLAG_MEMBER_WITH_TYPE(name,type),
  34.155 +#define C2_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)           FLAG_MEMBER_WITH_TYPE(name,type),
  34.156 +#define C2_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc)               FLAG_MEMBER_WITH_TYPE(name,type),
  34.157 +#define C2_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)        FLAG_MEMBER_WITH_TYPE(name,type),
  34.158  #define C2_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)      FLAG_MEMBER_WITH_TYPE(name,type),
  34.159 -#ifdef PRODUCT
  34.160 -  #define C2_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)       /* flag is constant */
  34.161 -  #define C2_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc)           /* flag is constant */
  34.162 -  #define C2_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)
  34.163 -#else
  34.164 -  #define C2_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)       FLAG_MEMBER_WITH_TYPE(name,type),
  34.165 -  #define C2_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc)           FLAG_MEMBER_WITH_TYPE(name,type),
  34.166 -  #define C2_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)    FLAG_MEMBER_WITH_TYPE(name,type),
  34.167 -#endif
  34.168 +#define C2_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)           FLAG_MEMBER_WITH_TYPE(name,type),
  34.169 +#define C2_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc)               FLAG_MEMBER_WITH_TYPE(name,type),
  34.170 +#define C2_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)        FLAG_MEMBER_WITH_TYPE(name,type),
  34.171  
  34.172  #define ARCH_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)         FLAG_MEMBER_WITH_TYPE(name,type),
  34.173  #define ARCH_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)      FLAG_MEMBER_WITH_TYPE(name,type),
  34.174 -#define ARCH_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)      FLAG_MEMBER_WITH_TYPE(name,type),
  34.175 -#ifdef PRODUCT
  34.176 -  #define ARCH_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)       /* flag is constant */
  34.177 -  #define ARCH_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)
  34.178 -#else
  34.179 -  #define ARCH_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)       FLAG_MEMBER_WITH_TYPE(name,type),
  34.180 -  #define ARCH_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)    FLAG_MEMBER_WITH_TYPE(name,type),
  34.181 -#endif
  34.182 +#define ARCH_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)    FLAG_MEMBER_WITH_TYPE(name,type),
  34.183 +#define ARCH_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)         FLAG_MEMBER_WITH_TYPE(name,type),
  34.184 +#define ARCH_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc)      FLAG_MEMBER_WITH_TYPE(name,type),
  34.185  
  34.186  typedef enum {
  34.187   RUNTIME_FLAGS(RUNTIME_DEVELOP_FLAG_MEMBER_WITH_TYPE,
  34.188 @@ -233,19 +189,19 @@
  34.189  
  34.190  #define FLAG_SET_DEFAULT(name, value) ((name) = (value))
  34.191  
  34.192 -#define FLAG_SET_CMDLINE(type, name, value) (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name,type), (type)(value), COMMAND_LINE))
  34.193 -#define FLAG_SET_ERGO(type, name, value)    (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name,type), (type)(value), ERGONOMIC))
  34.194 +#define FLAG_SET_CMDLINE(type, name, value) (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name,type), (type)(value), Flag::COMMAND_LINE))
  34.195 +#define FLAG_SET_ERGO(type, name, value)    (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name,type), (type)(value), Flag::ERGONOMIC))
  34.196  
  34.197  // Can't put the following in CommandLineFlags because
  34.198  // of a circular dependency on the enum definition.
  34.199  class CommandLineFlagsEx : CommandLineFlags {
  34.200   public:
  34.201 -  static void boolAtPut(CommandLineFlagWithType flag, bool value, FlagValueOrigin origin);
  34.202 -  static void intxAtPut(CommandLineFlagWithType flag, intx value, FlagValueOrigin origin);
  34.203 -  static void uintxAtPut(CommandLineFlagWithType flag, uintx value, FlagValueOrigin origin);
  34.204 -  static void uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, FlagValueOrigin origin);
  34.205 -  static void doubleAtPut(CommandLineFlagWithType flag, double value, FlagValueOrigin origin);
  34.206 -  static void ccstrAtPut(CommandLineFlagWithType flag, ccstr value, FlagValueOrigin origin);
  34.207 +  static void boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin);
  34.208 +  static void intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin);
  34.209 +  static void uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin);
  34.210 +  static void uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin);
  34.211 +  static void doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin);
  34.212 +  static void ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin);
  34.213  
  34.214    static bool is_default(CommandLineFlag flag);
  34.215    static bool is_ergo(CommandLineFlag flag);
    35.1 --- a/src/share/vm/runtime/vmStructs.cpp	Thu Sep 26 08:48:15 2013 +0200
    35.2 +++ b/src/share/vm/runtime/vmStructs.cpp	Fri Sep 27 12:43:51 2013 -0700
    35.3 @@ -176,6 +176,7 @@
    35.4  #include "opto/loopnode.hpp"
    35.5  #include "opto/machnode.hpp"
    35.6  #include "opto/matcher.hpp"
    35.7 +#include "opto/mathexactnode.hpp"
    35.8  #include "opto/mulnode.hpp"
    35.9  #include "opto/phaseX.hpp"
   35.10  #include "opto/parse.hpp"
   35.11 @@ -1185,11 +1186,10 @@
   35.12    /* -XX flags         */                                                                                                            \
   35.13    /*********************/                                                                                                            \
   35.14                                                                                                                                       \
   35.15 -  nonstatic_field(Flag,                        type,                                          const char*)                           \
   35.16 -  nonstatic_field(Flag,                        name,                                          const char*)                           \
   35.17 -  unchecked_nonstatic_field(Flag,              addr,                                          sizeof(void*)) /* NOTE: no type */     \
   35.18 -  nonstatic_field(Flag,                        kind,                                          const char*)                           \
   35.19 -  nonstatic_field(Flag,                        origin,                                        FlagValueOrigin)                       \
   35.20 +  nonstatic_field(Flag,                        _type,                                         const char*)                           \
   35.21 +  nonstatic_field(Flag,                        _name,                                         const char*)                           \
   35.22 +  unchecked_nonstatic_field(Flag,              _addr,                                         sizeof(void*)) /* NOTE: no type */     \
   35.23 +  nonstatic_field(Flag,                        _flags,                                        Flag::Flags)                           \
   35.24    static_field(Flag,                           flags,                                         Flag*)                                 \
   35.25    static_field(Flag,                           numFlags,                                      size_t)                                \
   35.26                                                                                                                                       \
   35.27 @@ -1928,6 +1928,9 @@
   35.28    declare_c2_type(CmpF3Node, CmpFNode)                                    \
   35.29    declare_c2_type(CmpDNode, CmpNode)                                      \
   35.30    declare_c2_type(CmpD3Node, CmpDNode)                                    \
   35.31 +  declare_c2_type(MathExactNode, MultiNode)                               \
   35.32 +  declare_c2_type(AddExactINode, MathExactNode)                           \
   35.33 +  declare_c2_type(FlagsProjNode, ProjNode)                                \
   35.34    declare_c2_type(BoolNode, Node)                                         \
   35.35    declare_c2_type(AbsNode, Node)                                          \
   35.36    declare_c2_type(AbsINode, AbsNode)                                      \
   35.37 @@ -2074,7 +2077,7 @@
   35.38     declare_integer_type(JavaThreadState)                                  \
   35.39     declare_integer_type(Location::Type)                                   \
   35.40     declare_integer_type(Location::Where)                                  \
   35.41 -   declare_integer_type(FlagValueOrigin)                                  \
   35.42 +   declare_integer_type(Flag::Flags)                                      \
   35.43     COMPILER2_PRESENT(declare_integer_type(OptoReg::Name))                 \
   35.44                                                                            \
   35.45     declare_toplevel_type(CHeapObj<mtInternal>)                            \
   35.46 @@ -2082,7 +2085,7 @@
   35.47              declare_type(Array<u1>, MetaspaceObj)                         \
   35.48              declare_type(Array<u2>, MetaspaceObj)                         \
   35.49              declare_type(Array<Klass*>, MetaspaceObj)                     \
   35.50 -            declare_type(Array<Method*>, MetaspaceObj)             \
   35.51 +            declare_type(Array<Method*>, MetaspaceObj)                    \
   35.52                                                                            \
   35.53     declare_integer_type(AccessFlags)  /* FIXME: wrong type (not integer) */\
   35.54    declare_toplevel_type(address)      /* FIXME: should this be an integer type? */\
    36.1 --- a/src/share/vm/services/attachListener.cpp	Thu Sep 26 08:48:15 2013 +0200
    36.2 +++ b/src/share/vm/services/attachListener.cpp	Fri Sep 27 12:43:51 2013 -0700
    36.3 @@ -245,7 +245,7 @@
    36.4      }
    36.5      value = (tmp != 0);
    36.6    }
    36.7 -  bool res = CommandLineFlags::boolAtPut((char*)name, &value, ATTACH_ON_DEMAND);
    36.8 +  bool res = CommandLineFlags::boolAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND);
    36.9    if (! res) {
   36.10      out->print_cr("setting flag %s failed", name);
   36.11    }
   36.12 @@ -263,7 +263,7 @@
   36.13        return JNI_ERR;
   36.14      }
   36.15    }
   36.16 -  bool res = CommandLineFlags::intxAtPut((char*)name, &value, ATTACH_ON_DEMAND);
   36.17 +  bool res = CommandLineFlags::intxAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND);
   36.18    if (! res) {
   36.19      out->print_cr("setting flag %s failed", name);
   36.20    }
   36.21 @@ -282,7 +282,7 @@
   36.22        return JNI_ERR;
   36.23      }
   36.24    }
   36.25 -  bool res = CommandLineFlags::uintxAtPut((char*)name, &value, ATTACH_ON_DEMAND);
   36.26 +  bool res = CommandLineFlags::uintxAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND);
   36.27    if (! res) {
   36.28      out->print_cr("setting flag %s failed", name);
   36.29    }
   36.30 @@ -301,7 +301,7 @@
   36.31        return JNI_ERR;
   36.32      }
   36.33    }
   36.34 -  bool res = CommandLineFlags::uint64_tAtPut((char*)name, &value, ATTACH_ON_DEMAND);
   36.35 +  bool res = CommandLineFlags::uint64_tAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND);
   36.36    if (! res) {
   36.37      out->print_cr("setting flag %s failed", name);
   36.38    }
   36.39 @@ -316,7 +316,7 @@
   36.40      out->print_cr("flag value must be a string");
   36.41      return JNI_ERR;
   36.42    }
   36.43 -  bool res = CommandLineFlags::ccstrAtPut((char*)name, &value, ATTACH_ON_DEMAND);
   36.44 +  bool res = CommandLineFlags::ccstrAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND);
   36.45    if (res) {
   36.46      FREE_C_HEAP_ARRAY(char, value, mtInternal);
   36.47    } else {
    37.1 --- a/src/share/vm/services/classLoadingService.cpp	Thu Sep 26 08:48:15 2013 +0200
    37.2 +++ b/src/share/vm/services/classLoadingService.cpp	Fri Sep 27 12:43:51 2013 -0700
    37.3 @@ -202,7 +202,7 @@
    37.4    MutexLocker m(Management_lock);
    37.5  
    37.6    // verbose will be set to the previous value
    37.7 -  bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassLoading", &verbose, MANAGEMENT);
    37.8 +  bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassLoading", &verbose, Flag::MANAGEMENT);
    37.9    assert(succeed, "Setting TraceClassLoading flag fails");
   37.10    reset_trace_class_unloading();
   37.11  
   37.12 @@ -213,7 +213,7 @@
   37.13  void ClassLoadingService::reset_trace_class_unloading() {
   37.14    assert(Management_lock->owned_by_self(), "Must own the Management_lock");
   37.15    bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose();
   37.16 -  bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassUnloading", &value, MANAGEMENT);
   37.17 +  bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassUnloading", &value, Flag::MANAGEMENT);
   37.18    assert(succeed, "Setting TraceClassUnLoading flag fails");
   37.19  }
   37.20  
    38.1 --- a/src/share/vm/services/dtraceAttacher.cpp	Thu Sep 26 08:48:15 2013 +0200
    38.2 +++ b/src/share/vm/services/dtraceAttacher.cpp	Fri Sep 27 12:43:51 2013 -0700
    38.3 @@ -51,7 +51,7 @@
    38.4  
    38.5  static void set_bool_flag(const char* flag, bool value) {
    38.6    CommandLineFlags::boolAtPut((char*)flag, strlen(flag), &value,
    38.7 -                              ATTACH_ON_DEMAND);
    38.8 +                              Flag::ATTACH_ON_DEMAND);
    38.9  }
   38.10  
   38.11  // Enable only the "fine grained" flags. Do *not* touch
    39.1 --- a/src/share/vm/services/management.cpp	Thu Sep 26 08:48:15 2013 +0200
    39.2 +++ b/src/share/vm/services/management.cpp	Fri Sep 27 12:43:51 2013 -0700
    39.3 @@ -1643,9 +1643,13 @@
    39.4    int num_entries = 0;
    39.5    for (int i = 0; i < nFlags; i++) {
    39.6      Flag* flag = &Flag::flags[i];
    39.7 +    // Exclude notproduct and develop flags in product builds.
    39.8 +    if (flag->is_constant_in_binary()) {
    39.9 +      continue;
   39.10 +    }
   39.11      // Exclude the locked (experimental, diagnostic) flags
   39.12      if (flag->is_unlocked() || flag->is_unlocker()) {
   39.13 -      Handle s = java_lang_String::create_from_str(flag->name, CHECK_0);
   39.14 +      Handle s = java_lang_String::create_from_str(flag->_name, CHECK_0);
   39.15        flags_ah->obj_at_put(num_entries, s());
   39.16        num_entries++;
   39.17      }
   39.18 @@ -1669,7 +1673,7 @@
   39.19  bool add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag, TRAPS) {
   39.20    Handle flag_name;
   39.21    if (name() == NULL) {
   39.22 -    flag_name = java_lang_String::create_from_str(flag->name, CHECK_false);
   39.23 +    flag_name = java_lang_String::create_from_str(flag->_name, CHECK_false);
   39.24    } else {
   39.25      flag_name = name;
   39.26    }
   39.27 @@ -1698,23 +1702,23 @@
   39.28  
   39.29    global->writeable = flag->is_writeable();
   39.30    global->external = flag->is_external();
   39.31 -  switch (flag->origin) {
   39.32 -    case DEFAULT:
   39.33 +  switch (flag->get_origin()) {
   39.34 +    case Flag::DEFAULT:
   39.35        global->origin = JMM_VMGLOBAL_ORIGIN_DEFAULT;
   39.36        break;
   39.37 -    case COMMAND_LINE:
   39.38 +    case Flag::COMMAND_LINE:
   39.39        global->origin = JMM_VMGLOBAL_ORIGIN_COMMAND_LINE;
   39.40        break;
   39.41 -    case ENVIRON_VAR:
   39.42 +    case Flag::ENVIRON_VAR:
   39.43        global->origin = JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR;
   39.44        break;
   39.45 -    case CONFIG_FILE:
   39.46 +    case Flag::CONFIG_FILE:
   39.47        global->origin = JMM_VMGLOBAL_ORIGIN_CONFIG_FILE;
   39.48        break;
   39.49 -    case MANAGEMENT:
   39.50 +    case Flag::MANAGEMENT:
   39.51        global->origin = JMM_VMGLOBAL_ORIGIN_MANAGEMENT;
   39.52        break;
   39.53 -    case ERGONOMIC:
   39.54 +    case Flag::ERGONOMIC:
   39.55        global->origin = JMM_VMGLOBAL_ORIGIN_ERGONOMIC;
   39.56        break;
   39.57      default:
   39.58 @@ -1781,6 +1785,10 @@
   39.59      int num_entries = 0;
   39.60      for (int i = 0; i < nFlags && num_entries < count;  i++) {
   39.61        Flag* flag = &Flag::flags[i];
   39.62 +      // Exclude notproduct and develop flags in product builds.
   39.63 +      if (flag->is_constant_in_binary()) {
   39.64 +        continue;
   39.65 +      }
   39.66        // Exclude the locked (diagnostic, experimental) flags
   39.67        if ((flag->is_unlocked() || flag->is_unlocker()) &&
   39.68            add_global_entry(env, null_h, &globals[num_entries], flag, THREAD)) {
   39.69 @@ -1813,23 +1821,23 @@
   39.70    bool succeed;
   39.71    if (flag->is_bool()) {
   39.72      bool bvalue = (new_value.z == JNI_TRUE ? true : false);
   39.73 -    succeed = CommandLineFlags::boolAtPut(name, &bvalue, MANAGEMENT);
   39.74 +    succeed = CommandLineFlags::boolAtPut(name, &bvalue, Flag::MANAGEMENT);
   39.75    } else if (flag->is_intx()) {
   39.76      intx ivalue = (intx)new_value.j;
   39.77 -    succeed = CommandLineFlags::intxAtPut(name, &ivalue, MANAGEMENT);
   39.78 +    succeed = CommandLineFlags::intxAtPut(name, &ivalue, Flag::MANAGEMENT);
   39.79    } else if (flag->is_uintx()) {
   39.80      uintx uvalue = (uintx)new_value.j;
   39.81 -    succeed = CommandLineFlags::uintxAtPut(name, &uvalue, MANAGEMENT);
   39.82 +    succeed = CommandLineFlags::uintxAtPut(name, &uvalue, Flag::MANAGEMENT);
   39.83    } else if (flag->is_uint64_t()) {
   39.84      uint64_t uvalue = (uint64_t)new_value.j;
   39.85 -    succeed = CommandLineFlags::uint64_tAtPut(name, &uvalue, MANAGEMENT);
   39.86 +    succeed = CommandLineFlags::uint64_tAtPut(name, &uvalue, Flag::MANAGEMENT);
   39.87    } else if (flag->is_ccstr()) {
   39.88      oop str = JNIHandles::resolve_external_guard(new_value.l);
   39.89      if (str == NULL) {
   39.90        THROW(vmSymbols::java_lang_NullPointerException());
   39.91      }
   39.92      ccstr svalue = java_lang_String::as_utf8_string(str);
   39.93 -    succeed = CommandLineFlags::ccstrAtPut(name, &svalue, MANAGEMENT);
   39.94 +    succeed = CommandLineFlags::ccstrAtPut(name, &svalue, Flag::MANAGEMENT);
   39.95    }
   39.96    assert(succeed, "Setting flag should succeed");
   39.97  JVM_END
    40.1 --- a/src/share/vm/services/memoryService.cpp	Thu Sep 26 08:48:15 2013 +0200
    40.2 +++ b/src/share/vm/services/memoryService.cpp	Fri Sep 27 12:43:51 2013 -0700
    40.3 @@ -515,7 +515,7 @@
    40.4  bool MemoryService::set_verbose(bool verbose) {
    40.5    MutexLocker m(Management_lock);
    40.6    // verbose will be set to the previous value
    40.7 -  bool succeed = CommandLineFlags::boolAtPut((char*)"PrintGC", &verbose, MANAGEMENT);
    40.8 +  bool succeed = CommandLineFlags::boolAtPut((char*)"PrintGC", &verbose, Flag::MANAGEMENT);
    40.9    assert(succeed, "Setting PrintGC flag fails");
   40.10    ClassLoadingService::reset_trace_class_unloading();
   40.11  
   40.12 @@ -618,4 +618,3 @@
   40.13    MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime,
   40.14                          _recordGCEndTime, _countCollection, _cause);
   40.15  }
   40.16 -
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/test/compiler/intrinsics/mathexact/CondTest.java	Fri Sep 27 12:43:51 2013 -0700
    41.3 @@ -0,0 +1,59 @@
    41.4 +/*
    41.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    41.7 + *
    41.8 + * This code is free software; you can redistribute it and/or modify it
    41.9 + * under the terms of the GNU General Public License version 2 only, as
   41.10 + * published by the Free Software Foundation.
   41.11 + *
   41.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   41.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   41.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   41.15 + * version 2 for more details (a copy is included in the LICENSE file that
   41.16 + * accompanied this code).
   41.17 + *
   41.18 + * You should have received a copy of the GNU General Public License version
   41.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   41.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   41.21 + *
   41.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   41.23 + * or visit www.oracle.com if you need additional information or have any
   41.24 + * questions.
   41.25 + */
   41.26 +
   41.27 +/*
   41.28 + * @test
   41.29 + * @bug 8024924
   41.30 + * @summary Test non constant addExact
   41.31 + * @compile CondTest.java Verify.java
   41.32 + * @run main CondTest
   41.33 + *
   41.34 + */
   41.35 +
   41.36 +import java.lang.ArithmeticException;
   41.37 +
   41.38 +public class CondTest {
   41.39 +  public static int result = 0;
   41.40 +
   41.41 +  public static void main(String[] args) {
   41.42 +    for (int i = 0; i < 50000; ++i) {
   41.43 +      runTest();
   41.44 +    }
   41.45 +  }
   41.46 +
   41.47 +  public static void runTest() {
   41.48 +    int i = 7;
   41.49 +    while (java.lang.Math.addExact(i, result) < 89361) {
   41.50 +        if ((java.lang.Math.addExact(i, i) & 1) == 1) {
   41.51 +            i += 3;
   41.52 +        } else if ((i & 5) == 4) {
   41.53 +            i += 7;
   41.54 +        } else if ((i & 0xf) == 6) {
   41.55 +            i += 2;
   41.56 +        } else {
   41.57 +            i += 1;
   41.58 +        }
   41.59 +        result += 2;
   41.60 +    }
   41.61 +  }
   41.62 +}
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/test/compiler/intrinsics/mathexact/ConstantTest.java	Fri Sep 27 12:43:51 2013 -0700
    42.3 @@ -0,0 +1,47 @@
    42.4 +/*
    42.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    42.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    42.7 + *
    42.8 + * This code is free software; you can redistribute it and/or modify it
    42.9 + * under the terms of the GNU General Public License version 2 only, as
   42.10 + * published by the Free Software Foundation.
   42.11 + *
   42.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   42.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   42.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   42.15 + * version 2 for more details (a copy is included in the LICENSE file that
   42.16 + * accompanied this code).
   42.17 + *
   42.18 + * You should have received a copy of the GNU General Public License version
   42.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   42.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   42.21 + *
   42.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   42.23 + * or visit www.oracle.com if you need additional information or have any
   42.24 + * questions.
   42.25 + */
   42.26 +
   42.27 +/*
   42.28 + * @test
   42.29 + * @bug 8024924
   42.30 + * @summary Test constant addExact
   42.31 + * @compile ConstantTest.java Verify.java
   42.32 + * @run main ConstantTest
   42.33 + *
   42.34 + */
   42.35 +
   42.36 +import java.lang.ArithmeticException;
   42.37 +
   42.38 +public class ConstantTest {
   42.39 +  public static void main(String[] args) {
   42.40 +    for (int i = 0; i < 50000; ++i) {
   42.41 +      Verify.verify(5, 7);
   42.42 +      Verify.verify(Integer.MAX_VALUE, 1);
   42.43 +      Verify.verify(Integer.MIN_VALUE, -1);
   42.44 +      Verify.verify(Integer.MAX_VALUE, -1);
   42.45 +      Verify.verify(Integer.MIN_VALUE, 1);
   42.46 +      Verify.verify(Integer.MAX_VALUE / 2, Integer.MAX_VALUE / 2);
   42.47 +      Verify.verify(Integer.MAX_VALUE / 2, (Integer.MAX_VALUE / 2) + 3);
   42.48 +    }
   42.49 +  }
   42.50 +}
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/test/compiler/intrinsics/mathexact/LoadTest.java	Fri Sep 27 12:43:51 2013 -0700
    43.3 @@ -0,0 +1,55 @@
    43.4 +/*
    43.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    43.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    43.7 + *
    43.8 + * This code is free software; you can redistribute it and/or modify it
    43.9 + * under the terms of the GNU General Public License version 2 only, as
   43.10 + * published by the Free Software Foundation.
   43.11 + *
   43.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   43.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   43.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   43.15 + * version 2 for more details (a copy is included in the LICENSE file that
   43.16 + * accompanied this code).
   43.17 + *
   43.18 + * You should have received a copy of the GNU General Public License version
   43.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   43.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   43.21 + *
   43.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   43.23 + * or visit www.oracle.com if you need additional information or have any
   43.24 + * questions.
   43.25 + */
   43.26 +
   43.27 +/*
   43.28 + * @test
   43.29 + * @bug 8024924
   43.30 + * @summary Test non constant addExact
   43.31 + * @compile LoadTest.java Verify.java
   43.32 + * @run main LoadTest
   43.33 + *
   43.34 + */
   43.35 +
   43.36 +import java.lang.ArithmeticException;
   43.37 +
   43.38 +public class LoadTest {
   43.39 +  public static java.util.Random rnd = new java.util.Random();
   43.40 +  public static int[] values = new int[256];
   43.41 +
   43.42 +  public static void main(String[] args) {
   43.43 +    for (int i = 0; i < values.length; ++i) {
   43.44 +        values[i] = rnd.nextInt();
   43.45 +    }
   43.46 +
   43.47 +    for (int i = 0; i < 50000; ++i) {
   43.48 +      Verify.verify(values[i & 255], values[i & 255] - i);
   43.49 +      Verify.verify(values[i & 255] + i, values[i & 255] - i);
   43.50 +      Verify.verify(values[i & 255], values[i & 255]);
   43.51 +      if ((i & 1) == 1 && i > 5) {
   43.52 +          Verify.verify(values[i & 255] + i, values[i & 255] - i);
   43.53 +      } else {
   43.54 +          Verify.verify(values[i & 255] - i, values[i & 255] + i);
   43.55 +      }
   43.56 +    }
   43.57 +  }
   43.58 +}
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/test/compiler/intrinsics/mathexact/LoopDependentTest.java	Fri Sep 27 12:43:51 2013 -0700
    44.3 @@ -0,0 +1,48 @@
    44.4 +/*
    44.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    44.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44.7 + *
    44.8 + * This code is free software; you can redistribute it and/or modify it
    44.9 + * under the terms of the GNU General Public License version 2 only, as
   44.10 + * published by the Free Software Foundation.
   44.11 + *
   44.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   44.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   44.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   44.15 + * version 2 for more details (a copy is included in the LICENSE file that
   44.16 + * accompanied this code).
   44.17 + *
   44.18 + * You should have received a copy of the GNU General Public License version
   44.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   44.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   44.21 + *
   44.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   44.23 + * or visit www.oracle.com if you need additional information or have any
   44.24 + * questions.
   44.25 + */
   44.26 +
   44.27 +/*
   44.28 + * @test
   44.29 + * @bug 8024924
   44.30 + * @summary Test non constant addExact
   44.31 + * @compile LoopDependentTest.java Verify.java
   44.32 + * @run main LoopDependentTest
   44.33 + *
   44.34 + */
   44.35 +
   44.36 +import java.lang.ArithmeticException;
   44.37 +
   44.38 +public class LoopDependentTest {
   44.39 +  public static java.util.Random rnd = new java.util.Random();
   44.40 +
   44.41 +  public static void main(String[] args) {
   44.42 +    int rnd1 = rnd.nextInt(), rnd2 = rnd.nextInt();
   44.43 +    for (int i = 0; i < 50000; ++i) {
   44.44 +      Verify.verify(rnd1 + i, rnd2 + i);
   44.45 +      Verify.verify(rnd1 + i, rnd2 + (i & 0xff));
   44.46 +      Verify.verify(rnd1 - i, rnd2 - (i & 0xff));
   44.47 +      Verify.verify(rnd1 + i + 1, rnd2 + i + 2);
   44.48 +      Verify.verify(rnd1 + i * 2, rnd2 + i);
   44.49 +    }
   44.50 +  }
   44.51 +}
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/test/compiler/intrinsics/mathexact/NonConstantTest.java	Fri Sep 27 12:43:51 2013 -0700
    45.3 @@ -0,0 +1,48 @@
    45.4 +/*
    45.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    45.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    45.7 + *
    45.8 + * This code is free software; you can redistribute it and/or modify it
    45.9 + * under the terms of the GNU General Public License version 2 only, as
   45.10 + * published by the Free Software Foundation.
   45.11 + *
   45.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   45.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   45.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   45.15 + * version 2 for more details (a copy is included in the LICENSE file that
   45.16 + * accompanied this code).
   45.17 + *
   45.18 + * You should have received a copy of the GNU General Public License version
   45.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   45.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   45.21 + *
   45.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   45.23 + * or visit www.oracle.com if you need additional information or have any
   45.24 + * questions.
   45.25 + */
   45.26 +
   45.27 +/*
   45.28 + * @test
   45.29 + * @bug 8024924
   45.30 + * @summary Test non constant addExact
   45.31 + * @compile NonConstantTest.java Verify.java
   45.32 + * @run main NonConstantTest
   45.33 + *
   45.34 + */
   45.35 +
   45.36 +import java.lang.ArithmeticException;
   45.37 +
   45.38 +public class NonConstantTest {
   45.39 +  public static java.util.Random rnd = new java.util.Random();
   45.40 +
   45.41 +  public static void main(String[] args) {
   45.42 +    for (int i = 0; i < 50000; ++i) {
   45.43 +      int rnd1 = rnd.nextInt(), rnd2 = rnd.nextInt();
   45.44 +      Verify.verify(rnd1, rnd2);
   45.45 +      Verify.verify(rnd1, rnd2 + 1);
   45.46 +      Verify.verify(rnd1 + 1, rnd2);
   45.47 +      Verify.verify(rnd1 - 1, rnd2);
   45.48 +      Verify.verify(rnd1, rnd2 - 1);
   45.49 +    }
   45.50 +  }
   45.51 +}
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/test/compiler/intrinsics/mathexact/Verify.java	Fri Sep 27 12:43:51 2013 -0700
    46.3 @@ -0,0 +1,68 @@
    46.4 +/*
    46.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    46.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    46.7 + *
    46.8 + * This code is free software; you can redistribute it and/or modify it
    46.9 + * under the terms of the GNU General Public License version 2 only, as
   46.10 + * published by the Free Software Foundation.
   46.11 + *
   46.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   46.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   46.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   46.15 + * version 2 for more details (a copy is included in the LICENSE file that
   46.16 + * accompanied this code).
   46.17 + *
   46.18 + * You should have received a copy of the GNU General Public License version
   46.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   46.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   46.21 + *
   46.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   46.23 + * or visit www.oracle.com if you need additional information or have any
   46.24 + * questions.
   46.25 + */
   46.26 +
   46.27 +public class Verify {
   46.28 +  public static String throwWord(boolean threw) {
   46.29 +    return (threw ? "threw" : "didn't throw");
   46.30 +  }
   46.31 +
   46.32 +  public static void verify(int a, int b) {
   46.33 +    boolean exception1 = false, exception2 = false;
   46.34 +    int result1 = 0, result2 = 0;
   46.35 +    try {
   46.36 +      result1 = testIntrinsic(a, b);
   46.37 +    } catch (ArithmeticException e) {
   46.38 +      exception1 = true;
   46.39 +    }
   46.40 +    try {
   46.41 +      result2 = testNonIntrinsic(a, b);
   46.42 +    } catch (ArithmeticException e) {
   46.43 +      exception2 = true;
   46.44 +    }
   46.45 +
   46.46 +    if (exception1 != exception2) {
   46.47 +      throw new RuntimeException("Intrinsic version " + throwWord(exception1) + " exception, NonIntrinsic version " + throwWord(exception2) + " for: " + a + " + " + b);
   46.48 +    }
   46.49 +    if (result1 != result2) {
   46.50 +      throw new RuntimeException("Intrinsic version returned: " + a + " while NonIntrinsic version returned: " + b);
   46.51 +    }
   46.52 +  }
   46.53 +
   46.54 +  public static int testIntrinsic(int a, int b) {
   46.55 +    return java.lang.Math.addExact(a, b);
   46.56 +  }
   46.57 +
   46.58 +  public static int testNonIntrinsic(int a, int b) {
   46.59 +    return safeAddExact(a, b);
   46.60 +  }
   46.61 +
   46.62 +  // Copied java.lang.Math.addExact to avoid intrinsification
   46.63 +  public static int safeAddExact(int x, int y) {
   46.64 +    int r = x + y;
   46.65 +    // HD 2-12 Overflow iff both arguments have the opposite sign of the result
   46.66 +    if (((x ^ r) & (y ^ r)) < 0) {
   46.67 +      throw new ArithmeticException("integer overflow");
   46.68 +    }
   46.69 +    return r;
   46.70 +  }
   46.71 +}

mercurial