src/hotspot/share/utilities/globalDefinitions.cpp
author lfoltan
Mon, 21 Oct 2019 13:13:16 -0400
changeset 58722 cba8afa5cfed
parent 57875 427b38332f20
permissions -rw-r--r--
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently Summary: Increase the use of type signature constants instead of hard coded characters within the JVM. Reviewed-by: coleenp, dholmes, fparain Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 57875
diff changeset
     2
 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    25
#include "precompiled.hpp"
57875
427b38332f20 8229836: Remove include of globals.hpp from allocation.hpp
stefank
parents: 49011
diff changeset
    26
#include "runtime/globals.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    27
#include "runtime/os.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    28
#include "utilities/globalDefinitions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    29
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
    30
// Basic error support
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
    32
// Info for oops within a java object.  Defaults are zero so
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
    33
// things will break badly if incorrectly initialized.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
    34
int heapOopSize        = 0;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
    35
int LogBytesPerHeapOop = 0;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
    36
int LogBitsPerHeapOop  = 0;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
    37
int BytesPerHeapOop    = 0;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
    38
int BitsPerHeapOop     = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
5694
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    40
// Object alignment, in units of HeapWords.
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    41
// Defaults are -1 so things will break badly if incorrectly initialized.
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    42
int MinObjAlignment            = -1;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    43
int MinObjAlignmentInBytes     = -1;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    44
int MinObjAlignmentInBytesMask = 0;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    45
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    46
int LogMinObjAlignment         = -1;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    47
int LogMinObjAlignmentInBytes  = -1;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    48
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    49
// Oop encoding heap max
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    50
uint64_t OopEncodingHeapMax = 0;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 670
diff changeset
    51
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// Something to help porters sleep at night
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
    54
void basic_types_init() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  assert(min_intx ==  (intx)CONST64(0x8000000000000000), "correct constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  assert(max_intx ==  CONST64(0x7FFFFFFFFFFFFFFF), "correct constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  assert(max_uintx == CONST64(0xFFFFFFFFFFFFFFFF), "correct constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  assert( 8 == sizeof( intx),      "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  assert( 8 == sizeof( jobject),   "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  assert(min_intx ==  (intx)0x80000000,  "correct constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  assert(max_intx ==  0x7FFFFFFF,  "correct constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  assert(max_uintx == 0xFFFFFFFF,  "correct constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  assert( 4 == sizeof( intx),      "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  assert( 4 == sizeof( jobject),   "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  assert( (~max_juint) == 0,  "max_juint has all its bits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  assert( (~max_uintx) == 0,  "max_uintx has all its bits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  assert( (~max_julong) == 0, "max_julong has all its bits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  assert( 1 == sizeof( jbyte),     "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  assert( 2 == sizeof( jchar),     "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  assert( 2 == sizeof( jshort),    "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  assert( 4 == sizeof( juint),     "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  assert( 4 == sizeof( jint),      "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  assert( 1 == sizeof( jboolean),  "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  assert( 8 == sizeof( jlong),     "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  assert( 4 == sizeof( jfloat),    "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  assert( 8 == sizeof( jdouble),   "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  assert( 1 == sizeof( u1),        "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  assert( 2 == sizeof( u2),        "wrong size for basic type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  assert( 4 == sizeof( u4),        "wrong size for basic type");
35898
ddc274f0052f 8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents: 35529
diff changeset
    84
  assert(wordSize == BytesPerWord, "should be the same since they're used interchangeably");
ddc274f0052f 8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents: 35529
diff changeset
    85
  assert(wordSize == HeapWordSize, "should be the same since they're also used interchangeably");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  int num_type_chars = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  for (int i = 0; i < 99; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    if (type2char((BasicType)i) != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      assert(char2type(type2char((BasicType)i)) == i, "proper inverses");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      num_type_chars++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  assert(num_type_chars == 11, "must have tested the right number of mappings");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  assert(char2type(0) == T_ILLEGAL, "correct illegality");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
      BasicType vt = (BasicType)i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
      BasicType ft = type2field[vt];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      switch (vt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
      // the following types might plausibly show up in memory layouts:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
      case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      case T_BYTE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
      case T_CHAR:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
      case T_SHORT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
      case T_INT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
      case T_FLOAT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
      case T_DOUBLE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
      case T_LONG:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
      case T_OBJECT:
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   112
      case T_ADDRESS:     // random raw pointer
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   113
      case T_METADATA:    // metadata pointer
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   114
      case T_NARROWOOP:   // compressed pointer
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   115
      case T_NARROWKLASS: // compressed klass pointer
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   116
      case T_CONFLICT:    // might as well support a bottom type
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   117
      case T_VOID:        // padding or other unaddressed word
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
        // layout type must map to itself
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
        assert(vt == ft, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
        // non-layout type must map to a (different) layout type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
        assert(vt != ft, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
        assert(ft == type2field[ft], "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
      // every type must map to same-sized layout type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
      assert(type2size[vt] == type2size[ft], "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // These are assumed, e.g., when filling HeapWords with juints.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  assert(is_power_of_2(sizeof(juint)), "juint must be power of 2");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  assert(is_power_of_2(HeapWordSize), "HeapWordSize must be power of 2");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  assert((size_t)HeapWordSize >= sizeof(juint),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
         "HeapWord should be at least as large as juint");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  assert(sizeof(NULL) == sizeof(char*), "NULL must be same size as pointer");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  if( JavaPriority1_To_OSPriority != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    os::java_to_os_priority[1] = JavaPriority1_To_OSPriority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  if( JavaPriority2_To_OSPriority != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    os::java_to_os_priority[2] = JavaPriority2_To_OSPriority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  if( JavaPriority3_To_OSPriority != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    os::java_to_os_priority[3] = JavaPriority3_To_OSPriority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  if( JavaPriority4_To_OSPriority != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    os::java_to_os_priority[4] = JavaPriority4_To_OSPriority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  if( JavaPriority5_To_OSPriority != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    os::java_to_os_priority[5] = JavaPriority5_To_OSPriority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  if( JavaPriority6_To_OSPriority != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    os::java_to_os_priority[6] = JavaPriority6_To_OSPriority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  if( JavaPriority7_To_OSPriority != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    os::java_to_os_priority[7] = JavaPriority7_To_OSPriority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  if( JavaPriority8_To_OSPriority != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    os::java_to_os_priority[8] = JavaPriority8_To_OSPriority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  if( JavaPriority9_To_OSPriority != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    os::java_to_os_priority[9] = JavaPriority9_To_OSPriority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  if(JavaPriority10_To_OSPriority != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    os::java_to_os_priority[10] = JavaPriority10_To_OSPriority;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   158
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   159
  // Set the size of basic types here (after argument parsing but before
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   160
  // stub generation).
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   161
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   162
    // Size info for oops within java objects is fixed
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   163
    heapOopSize        = jintSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   164
    LogBytesPerHeapOop = LogBytesPerInt;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   165
    LogBitsPerHeapOop  = LogBitsPerInt;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   166
    BytesPerHeapOop    = BytesPerInt;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   167
    BitsPerHeapOop     = BitsPerInt;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   168
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   169
    heapOopSize        = oopSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   170
    LogBytesPerHeapOop = LogBytesPerWord;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   171
    LogBitsPerHeapOop  = LogBitsPerWord;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   172
    BytesPerHeapOop    = BytesPerWord;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   173
    BitsPerHeapOop     = BitsPerWord;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   174
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   175
  _type2aelembytes[T_OBJECT] = heapOopSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   176
  _type2aelembytes[T_ARRAY]  = heapOopSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
// Map BasicType to signature character
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 57875
diff changeset
   181
char type2char_tab[T_CONFLICT+1] = {
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 57875
diff changeset
   182
  0, 0, 0, 0,
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 57875
diff changeset
   183
  JVM_SIGNATURE_BOOLEAN, JVM_SIGNATURE_CHAR,
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 57875
diff changeset
   184
  JVM_SIGNATURE_FLOAT,   JVM_SIGNATURE_DOUBLE,
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 57875
diff changeset
   185
  JVM_SIGNATURE_BYTE,    JVM_SIGNATURE_SHORT,
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 57875
diff changeset
   186
  JVM_SIGNATURE_INT,     JVM_SIGNATURE_LONG,
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 57875
diff changeset
   187
  JVM_SIGNATURE_CLASS,   JVM_SIGNATURE_ARRAY,
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 57875
diff changeset
   188
  JVM_SIGNATURE_VOID,    0,
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 57875
diff changeset
   189
  0, 0, 0, 0
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 57875
diff changeset
   190
};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
// Map BasicType to Java type name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
const char* type2name_tab[T_CONFLICT+1] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  NULL, NULL, NULL, NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  "boolean",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  "char",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  "float",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  "double",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  "byte",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  "short",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  "int",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  "long",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  "object",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  "array",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  "void",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  "*address*",
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   207
  "*narrowoop*",
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   208
  "*metadata*",
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   209
  "*narrowklass*",
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  "*conflict*"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
BasicType name2type(const char* name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  for (int i = T_BOOLEAN; i <= T_VOID; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    BasicType t = (BasicType)i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
    if (type2name_tab[t] != NULL && 0 == strcmp(type2name_tab[t], name))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
      return t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  return T_ILLEGAL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
// Map BasicType to size in words
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   224
int type2size[T_CONFLICT+1]={ -1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 1, -1};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
BasicType type2field[T_CONFLICT+1] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  (BasicType)0,            // 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  (BasicType)0,            // 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  (BasicType)0,            // 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  (BasicType)0,            // 3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  T_BOOLEAN,               // T_BOOLEAN  =  4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  T_CHAR,                  // T_CHAR     =  5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  T_FLOAT,                 // T_FLOAT    =  6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  T_DOUBLE,                // T_DOUBLE   =  7,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  T_BYTE,                  // T_BYTE     =  8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  T_SHORT,                 // T_SHORT    =  9,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  T_INT,                   // T_INT      = 10,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  T_LONG,                  // T_LONG     = 11,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  T_OBJECT,                // T_OBJECT   = 12,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  T_OBJECT,                // T_ARRAY    = 13,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  T_VOID,                  // T_VOID     = 14,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  T_ADDRESS,               // T_ADDRESS  = 15,
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   243
  T_NARROWOOP,             // T_NARROWOOP= 16,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   244
  T_METADATA,              // T_METADATA = 17,
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   245
  T_NARROWKLASS,           // T_NARROWKLASS = 18,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   246
  T_CONFLICT               // T_CONFLICT = 19,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
BasicType type2wfield[T_CONFLICT+1] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  (BasicType)0,            // 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  (BasicType)0,            // 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  (BasicType)0,            // 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  (BasicType)0,            // 3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  T_INT,     // T_BOOLEAN  =  4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  T_INT,     // T_CHAR     =  5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  T_FLOAT,   // T_FLOAT    =  6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  T_DOUBLE,  // T_DOUBLE   =  7,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  T_INT,     // T_BYTE     =  8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  T_INT,     // T_SHORT    =  9,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  T_INT,     // T_INT      = 10,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  T_LONG,    // T_LONG     = 11,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  T_OBJECT,  // T_OBJECT   = 12,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  T_OBJECT,  // T_ARRAY    = 13,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  T_VOID,    // T_VOID     = 14,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  T_ADDRESS, // T_ADDRESS  = 15,
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   267
  T_NARROWOOP, // T_NARROWOOP  = 16,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   268
  T_METADATA,  // T_METADATA   = 17,
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   269
  T_NARROWKLASS, // T_NARROWKLASS  = 18,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   270
  T_CONFLICT // T_CONFLICT = 19,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
202
dc13bf0e5d5d 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 1
diff changeset
   274
int _type2aelembytes[T_CONFLICT+1] = {
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   275
  0,                         // 0
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   276
  0,                         // 1
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   277
  0,                         // 2
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   278
  0,                         // 3
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   279
  T_BOOLEAN_aelem_bytes,     // T_BOOLEAN  =  4,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   280
  T_CHAR_aelem_bytes,        // T_CHAR     =  5,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   281
  T_FLOAT_aelem_bytes,       // T_FLOAT    =  6,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   282
  T_DOUBLE_aelem_bytes,      // T_DOUBLE   =  7,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   283
  T_BYTE_aelem_bytes,        // T_BYTE     =  8,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   284
  T_SHORT_aelem_bytes,       // T_SHORT    =  9,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   285
  T_INT_aelem_bytes,         // T_INT      = 10,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   286
  T_LONG_aelem_bytes,        // T_LONG     = 11,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   287
  T_OBJECT_aelem_bytes,      // T_OBJECT   = 12,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   288
  T_ARRAY_aelem_bytes,       // T_ARRAY    = 13,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   289
  0,                         // T_VOID     = 14,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   290
  T_OBJECT_aelem_bytes,      // T_ADDRESS  = 15,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   291
  T_NARROWOOP_aelem_bytes,   // T_NARROWOOP= 16,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   292
  T_OBJECT_aelem_bytes,      // T_METADATA = 17,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   293
  T_NARROWKLASS_aelem_bytes, // T_NARROWKLASS= 18,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13742
diff changeset
   294
  0                          // T_CONFLICT = 19,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
202
dc13bf0e5d5d 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 1
diff changeset
   297
#ifdef ASSERT
dc13bf0e5d5d 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 1
diff changeset
   298
int type2aelembytes(BasicType t, bool allow_address) {
dc13bf0e5d5d 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 1
diff changeset
   299
  assert(allow_address || t != T_ADDRESS, " ");
dc13bf0e5d5d 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 1
diff changeset
   300
  return _type2aelembytes[t];
dc13bf0e5d5d 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 1
diff changeset
   301
}
dc13bf0e5d5d 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 1
diff changeset
   302
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
// Support for 64-bit integer arithmetic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
// The following code is mostly taken from JVM typedefs_md.h and system_md.c
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 202
diff changeset
   308
static const jlong high_bit   = (jlong)1 << (jlong)63;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
static const jlong other_bits = ~high_bit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
jlong float2long(jfloat f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  jlong tmp = (jlong) f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  if (tmp != high_bit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    return tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    if (g_isnan((jdouble)f)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
      return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    if (f < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
      return high_bit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
      return other_bits;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
jlong double2long(jdouble f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  jlong tmp = (jlong) f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  if (tmp != high_bit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    return tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    if (g_isnan(f)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
      return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    if (f < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
      return high_bit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
      return other_bits;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
// least common multiple
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
size_t lcm(size_t a, size_t b) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    size_t cur, div, next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    cur = MAX2(a, b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    div = MIN2(a, b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    assert(div != 0, "lcm requires positive arguments");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
    while ((next = cur % div) != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
        cur = div; div = next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    julong result = julong(a) * b / div;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    assert(result <= (size_t)max_uintx, "Integer overflow in lcm");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    return size_t(result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
}
16670
4af09aff4237 8003310: Enable -Wunused-function when compiling with gcc
mikael
parents: 13969
diff changeset
   364
37056
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   365
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   366
// Test that nth_bit macro and friends behave as
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   367
// expected, even with low-precedence operators.
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   368
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   369
STATIC_ASSERT(nth_bit(3)   == 0x8);
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   370
STATIC_ASSERT(nth_bit(1|2) == 0x8);
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   371
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   372
STATIC_ASSERT(right_n_bits(3)   == 0x7);
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   373
STATIC_ASSERT(right_n_bits(1|2) == 0x7);
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   374
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   375
STATIC_ASSERT(left_n_bits(3)   == (intptr_t) LP64_ONLY(0xE000000000000000) NOT_LP64(0xE0000000));
109f610020fa 8150617: nth_bit and friends are broken
stefank
parents: 35898
diff changeset
   376
STATIC_ASSERT(left_n_bits(1|2) == (intptr_t) LP64_ONLY(0xE000000000000000) NOT_LP64(0xE0000000));