src/hotspot/share/adlc/forms.cpp
author pliden
Wed, 20 Nov 2019 10:37:46 +0100
changeset 59152 59272e9e0635
parent 53416 9db898820f63
permissions -rw-r--r--
8234383: Test TestBiasedLockRevocationEvents.java assumes -XX:UseBiasedLocking is enabled Reviewed-by: mgronlun, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 12957
diff changeset
     2
 * Copyright (c) 1997, 2012, 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: 2154
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2154
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: 2154
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// FORMS.CPP - Definitions for ADL Parser Generic & Utility Forms Classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "adlc.hpp"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
//------------------------------Static Initializers----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// allocate arena used by forms
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
Arena  *Form::arena = Form::generate_arena(); //  = Form::generate_arena();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
Arena *Form::generate_arena() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  return (new Arena);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//------------------------------NameList---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// reserved user-defined string
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
const char  *NameList::_signal   = "$$SIGNAL$$";
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 670
diff changeset
    38
const char  *NameList::_signal2  = "$$SIGNAL2$$";
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 670
diff changeset
    39
const char  *NameList::_signal3  = "$$SIGNAL3$$";
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// Constructor and Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
NameList::NameList() : _cur(0), _max(4), _iter(0), _justReset(true) {
52583
a3aa8d5380d9 8212779: ADL Parser does not check allocation return values in all cases
jcm
parents: 47216
diff changeset
    43
  _names = (const char**) AllocateHeap(_max*sizeof(char*));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
NameList::~NameList() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // The following free is a double-free, and crashes the program:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  //free(_names);                   // not owner of strings
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
void   NameList::addName(const char *name) {
53416
9db898820f63 8217291: Failure of ::realloc() should be handled correctly in adlc/forms.cpp
thartmann
parents: 52583
diff changeset
    51
  if (_cur == _max) {
9db898820f63 8217291: Failure of ::realloc() should be handled correctly in adlc/forms.cpp
thartmann
parents: 52583
diff changeset
    52
    _names = (const char**) ReAllocateHeap(_names, (_max *=2)*sizeof(char*));
9db898820f63 8217291: Failure of ::realloc() should be handled correctly in adlc/forms.cpp
thartmann
parents: 52583
diff changeset
    53
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  _names[_cur++] = name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
void   NameList::add_signal() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  addName( _signal );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
void   NameList::clear() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  _cur   = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  _iter  = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  _justReset = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // _max   = 4; Already allocated
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
int    NameList::count()  const { return _cur; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
void   NameList::reset()   { _iter = 0; _justReset = true;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
const char  *NameList::iter()    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  if (_justReset) {_justReset=false; return (_iter < _cur ? _names[_iter] : NULL);}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  else return (_iter <_cur-1 ? _names[++_iter] : NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
const char  *NameList::current() { return (_iter < _cur ? _names[_iter] : NULL); }
2150
0d91d17158cc 6797305: Add LoadUB and LoadUI opcode class
twisti
parents: 2129
diff changeset
    75
const char  *NameList::peek(int skip) { return (_iter + skip < _cur ? _names[_iter + skip] : NULL); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
// Return 'true' if current entry is signal
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
bool  NameList::current_is_signal() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  const char *entry = current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  return is_signal(entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
// Return true if entry is a signal
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
bool  NameList::is_signal(const char *entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  return ( (strcmp(entry,NameList::_signal) == 0) ? true : false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
// Search for a name in the list
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
bool   NameList::search(const char *name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  const char *entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  for(reset(); (entry = iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    if(!strcmp(entry,name)) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
// Return index of name in list
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
int    NameList::index(const char *name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  int         cnt = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  const char *entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  for(reset(); (entry = iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    if(!strcmp(entry,name)) return cnt;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    cnt++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  return Not_in_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
// Return name at index in list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
const char  *NameList::name(intptr_t  index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  return ( index < _cur ? _names[index] : NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
void   NameList::dump() { output(stderr); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
void   NameList::output(FILE *fp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  fprintf(fp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // Run iteration over all entries, independent of position of iterator.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  const char *name       = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  int         iter       = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  bool        justReset  = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  while( ( name  = (justReset ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
                    (justReset=false, (iter < _cur ? _names[iter] : NULL)) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
                    (iter < _cur-1 ? _names[++iter] : NULL)) )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
         != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    fprintf( fp, "  %s,\n", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  fprintf(fp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
//------------------------------NameAndList------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
// Storage for a name and an associated list of names
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
NameAndList::NameAndList(char *name) : _name(name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
NameAndList::~NameAndList() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
// Add to entries in list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
void NameAndList::add_entry(const char *entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  _list.addName(entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
// Access the name and its associated list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
const char *NameAndList::name()  const {  return _name;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
void        NameAndList::reset()       { _list.reset();  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
const char *NameAndList::iter()        { return _list.iter(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
// Return the "index" entry in the list, zero-based
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
const char *NameAndList::operator[](int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  assert( index >= 0, "Internal Error(): index less than 0.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  _list.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  const char *entry = _list.iter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // Iterate further if it isn't at index 0.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  for ( int position = 0; position != index; ++position ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    entry = _list.iter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
void   NameAndList::dump() { output(stderr); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
void   NameAndList::output(FILE *fp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  fprintf(fp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  // Output the Name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  fprintf(fp, "Name == %s", (_name ? _name : "") );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // Output the associated list of names
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  const char *name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  fprintf(fp, " (");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  for (reset(); (name = iter()) != NULL;) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    fprintf(fp, "  %s,\n", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  fprintf(fp, ")");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  fprintf(fp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
//------------------------------Form-------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
OpClassForm   *Form::is_opclass()     const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
OperandForm   *Form::is_operand()     const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
InstructForm  *Form::is_instruction() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
MachNodeForm  *Form::is_machnode() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
AttributeForm *Form::is_attribute() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
Effect        *Form::is_effect() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
ResourceForm  *Form::is_resource() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
PipeClassForm *Form::is_pipeclass() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
Form::DataType Form::ideal_to_const_type(const char *name) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  if( name == NULL ) { return Form::none; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  if (strcmp(name,"ConI")==0) return Form::idealI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  if (strcmp(name,"ConP")==0) return Form::idealP;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   219
  if (strcmp(name,"ConN")==0) return Form::idealN;
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13104
diff changeset
   220
  if (strcmp(name,"ConNKlass")==0) return Form::idealNKlass;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  if (strcmp(name,"ConL")==0) return Form::idealL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  if (strcmp(name,"ConF")==0) return Form::idealF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  if (strcmp(name,"ConD")==0) return Form::idealD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  if (strcmp(name,"Bool")==0) return Form::idealI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  return Form::none;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
Form::DataType Form::ideal_to_sReg_type(const char *name) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  if( name == NULL ) { return Form::none; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  if (strcmp(name,"sRegI")==0) return Form::idealI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  if (strcmp(name,"sRegP")==0) return Form::idealP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  if (strcmp(name,"sRegF")==0) return Form::idealF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  if (strcmp(name,"sRegD")==0) return Form::idealD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  if (strcmp(name,"sRegL")==0) return Form::idealL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  return Form::none;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
Form::DataType Form::ideal_to_Reg_type(const char *name) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  if( name == NULL ) { return Form::none; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  if (strcmp(name,"RegI")==0) return Form::idealI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  if (strcmp(name,"RegP")==0) return Form::idealP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  if (strcmp(name,"RegF")==0) return Form::idealF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  if (strcmp(name,"RegD")==0) return Form::idealD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  if (strcmp(name,"RegL")==0) return Form::idealL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  return Form::none;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
// True if 'opType', an ideal name, loads or stores.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
Form::DataType Form::is_load_from_memory(const char *opType) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  if( strcmp(opType,"LoadB")==0 )  return Form::idealB;
2150
0d91d17158cc 6797305: Add LoadUB and LoadUI opcode class
twisti
parents: 2129
diff changeset
   255
  if( strcmp(opType,"LoadUB")==0 )  return Form::idealB;
2022
28ce8115a91d 6796746: rename LoadC (char) opcode class to LoadUS (unsigned short)
twisti
parents: 1495
diff changeset
   256
  if( strcmp(opType,"LoadUS")==0 )  return Form::idealC;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  if( strcmp(opType,"LoadD")==0 )  return Form::idealD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  if( strcmp(opType,"LoadD_unaligned")==0 )  return Form::idealD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  if( strcmp(opType,"LoadF")==0 )  return Form::idealF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  if( strcmp(opType,"LoadI")==0 )  return Form::idealI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  if( strcmp(opType,"LoadKlass")==0 )  return Form::idealP;
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13104
diff changeset
   262
  if( strcmp(opType,"LoadNKlass")==0 ) return Form::idealNKlass;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  if( strcmp(opType,"LoadL")==0 )  return Form::idealL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  if( strcmp(opType,"LoadL_unaligned")==0 )  return Form::idealL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  if( strcmp(opType,"LoadPLocked")==0 )  return Form::idealP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  if( strcmp(opType,"LoadP")==0 )  return Form::idealP;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   267
  if( strcmp(opType,"LoadN")==0 )  return Form::idealN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  if( strcmp(opType,"LoadRange")==0 )  return Form::idealI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  if( strcmp(opType,"LoadS")==0 )  return Form::idealS;
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 12957
diff changeset
   270
  if( strcmp(opType,"LoadVector")==0 )  return Form::idealV;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  assert( strcmp(opType,"Load") != 0, "Must type Loads" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  return Form::none;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
Form::DataType Form::is_store_to_memory(const char *opType) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  if( strcmp(opType,"StoreB")==0)  return Form::idealB;
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 12957
diff changeset
   277
  if( strcmp(opType,"StoreCM")==0) return Form::idealB;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  if( strcmp(opType,"StoreC")==0)  return Form::idealC;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  if( strcmp(opType,"StoreD")==0)  return Form::idealD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  if( strcmp(opType,"StoreF")==0)  return Form::idealF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  if( strcmp(opType,"StoreI")==0)  return Form::idealI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  if( strcmp(opType,"StoreL")==0)  return Form::idealL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  if( strcmp(opType,"StoreP")==0)  return Form::idealP;
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 12957
diff changeset
   284
  if( strcmp(opType,"StoreN")==0)  return Form::idealN;
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13104
diff changeset
   285
  if( strcmp(opType,"StoreNKlass")==0)  return Form::idealNKlass;
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 12957
diff changeset
   286
  if( strcmp(opType,"StoreVector")==0 )  return Form::idealV;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  assert( strcmp(opType,"Store") != 0, "Must type Stores" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  return Form::none;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
Form::InterfaceType Form::interface_type(FormDict &globals) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  return Form::no_interface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
//------------------------------FormList---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
// Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
FormList::~FormList()  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  // // This list may not own its elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  // Form *cur  = _root;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  // Form *next = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  // for( ; (cur = next) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  //   next = (Form *)cur->_next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  //   delete cur;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  // }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
//------------------------------FormDict---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
// Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
FormDict::FormDict( CmpKey cmp, Hash hash, Arena *arena )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  : _form(cmp, hash, arena) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
FormDict::~FormDict() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
// Return # of name-Form pairs in dict
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
int FormDict::Size(void) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  return _form.Size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
// Insert inserts the given key-value pair into the dictionary.  The prior
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
// value of the key is returned; NULL if the key was not previously defined.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
const Form  *FormDict::Insert(const char *name, Form *form) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  return (Form*)_form.Insert((void*)name, (void*)form);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
// Finds the value of a given key; or NULL if not found.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
// The dictionary is NOT changed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
const Form  *FormDict::operator [](const char *name) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  return (Form*)_form[name];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
//------------------------------FormDict::private------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
// Disable public use of constructor, copy-ctor, operator =, operator ==
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
FormDict::FormDict( ) : _form(cmpkey,hashkey) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  assert( false, "NotImplemented");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
FormDict::FormDict( const FormDict & fd) : _form(fd._form) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
FormDict &FormDict::operator =( const FormDict &rhs) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  assert( false, "NotImplemented");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  _form = rhs._form;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  return *this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
// == compares two dictionaries; they must have the same keys (their keys
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
// must match using CmpKey) and they must have the same values (pointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
// comparison).  If so 1 is returned, if not 0 is returned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
bool FormDict::operator ==(const FormDict &d) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  assert( false, "NotImplemented");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
// Print out the dictionary contents as key-value pairs
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 2022
diff changeset
   353
static void dumpkey (const void* key)  { fprintf(stdout, "%s", (char*) key); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
static void dumpform(const void* form) { fflush(stdout); ((Form*)form)->dump(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
void FormDict::dump() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  _form.print(dumpkey, dumpform);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
//------------------------------SourceForm-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
SourceForm::SourceForm(char* code) : _code(code) { }; // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
SourceForm::~SourceForm() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
void SourceForm::dump() {                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  output(stderr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
void SourceForm::output(FILE *fp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  fprintf(fp,"\n//%s\n%s\n",classname(),(_code?_code:""));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
}