hotspot/src/share/vm/c1/c1_ValueStack.cpp
author jrose
Tue, 21 Apr 2009 23:21:04 -0700
changeset 2570 ecc7862946d4
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6655646: dynamic languages need dynamically linked call sites Summary: invokedynamic instruction (JSR 292 RI) Reviewed-by: twisti, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
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
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_c1_ValueStack.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// Implementation of ValueStack
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
ValueStack::ValueStack(IRScope* scope, int locals_size, int max_stack_size)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
: _scope(scope)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
, _locals(locals_size, NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
, _stack(max_stack_size)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
, _lock_stack(false)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
, _locks(1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  assert(scope != NULL, "scope must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
ValueStack* ValueStack::copy() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  ValueStack* s = new ValueStack(scope(), locals_size(), max_stack_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  s->_stack.appendAll(&_stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  s->_locks.appendAll(&_locks);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  s->replace_locals(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  return s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
ValueStack* ValueStack::copy_locks() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  int sz = scope()->lock_stack_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  if (stack_size() == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    sz = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  ValueStack* s = new ValueStack(scope(), locals_size(), sz);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  s->_lock_stack = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  s->_locks.appendAll(&_locks);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  s->replace_locals(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  if (sz > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    assert(sz <= stack_size(), "lock stack underflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    for (int i = 0; i < sz; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
      s->_stack.append(_stack[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  return s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
bool ValueStack::is_same(ValueStack* s) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  assert(s != NULL, "state must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  assert(scope      () == s->scope      (), "scopes       must correspond");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  assert(locals_size() == s->locals_size(), "locals sizes must correspond");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  return is_same_across_scopes(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
bool ValueStack::is_same_across_scopes(ValueStack* s) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  assert(s != NULL, "state must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  assert(stack_size () == s->stack_size (), "stack  sizes must correspond");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  assert(locks_size () == s->locks_size (), "locks  sizes must correspond");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // compare each stack element with the corresponding stack element of s
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  int index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  Value value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  for_each_stack_value(this, index, value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    if (value->type()->tag() != s->stack_at(index)->type()->tag()) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  for_each_lock_value(this, index, value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    if (value != s->lock_at(index)) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
ValueStack* ValueStack::caller_state() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  return scope()->caller_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
void ValueStack::clear_locals() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  for (int i = _locals.length() - 1; i >= 0; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    _locals.at_put(i, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
void ValueStack::replace_locals(ValueStack* with) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  assert(locals_size() == with->locals_size(), "number of locals must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  for (int i = locals_size() - 1; i >= 0; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    _locals.at_put(i, with->_locals.at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
void ValueStack::pin_stack_for_linear_scan() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  for_each_state_value(this, v,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    if (v->as_Constant() == NULL && v->as_Local() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
      v->pin(Instruction::PinStackForStateSplit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
// apply function to all values of a list; factored out from values_do(f)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
void ValueStack::apply(Values list, void f(Value*)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  for (int i = 0; i < list.length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    Value* va = list.adr_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    Value v0 = *va;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    if (v0 != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
      if (!v0->type()->is_illegal()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
        assert(v0->as_HiWord() == NULL, "should never see HiWord during traversal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
        f(va);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
        Value v1 = *va;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
        if (v0 != v1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
          assert(v1->type()->is_illegal() || v0->type()->tag() == v1->type()->tag(), "types must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
          if (v0->type()->is_double_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
            list.at_put(i + 1, v0->hi_word());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
        if (v0->type()->is_double_word()) i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
void ValueStack::values_do(void f(Value*)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  apply(_stack, f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  apply(_locks, f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  ValueStack* state = this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  for_each_state(state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    apply(state->_locals, f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
Values* ValueStack::pop_arguments(int argument_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  assert(stack_size() >= argument_size, "stack too small or too many arguments");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  int base = stack_size() - argument_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  Values* args = new Values(argument_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  for (int i = base; i < stack_size();) args->push(stack_at_inc(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  truncate_stack(base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  return args;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
int ValueStack::lock(IRScope* scope, Value obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  _locks.push(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  scope->set_min_number_of_locks(locks_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  return locks_size() - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
int ValueStack::unlock() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  _locks.pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  return locks_size();
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
ValueStack* ValueStack::push_scope(IRScope* scope) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  assert(scope->caller() == _scope, "scopes must have caller/callee relationship");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  ValueStack* res = new ValueStack(scope,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
                                   scope->method()->max_locals(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
                                   max_stack_size() + scope->method()->max_stack());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  // Preserves stack and monitors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  res->_stack.appendAll(&_stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  res->_locks.appendAll(&_locks);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  assert(res->_stack.size() <= res->max_stack_size(), "stack overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  return res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
ValueStack* ValueStack::pop_scope() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  assert(_scope->caller() != NULL, "scope must have caller");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  IRScope* scope = _scope->caller();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  int max_stack = max_stack_size() - _scope->method()->max_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  assert(max_stack >= 0, "stack underflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  ValueStack* res = new ValueStack(scope,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
                                   scope->method()->max_locals(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
                                   max_stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  // Preserves stack and monitors. Restores local and store state from caller scope.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  res->_stack.appendAll(&_stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  res->_locks.appendAll(&_locks);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  ValueStack* caller = caller_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  if (caller != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    for (int i = 0; i < caller->_locals.length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
      res->_locals.at_put(i, caller->_locals.at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    assert(res->_locals.length() == res->scope()->method()->max_locals(), "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  assert(res->_stack.size() <= res->max_stack_size(), "stack overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  return res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
void ValueStack::setup_phi_for_stack(BlockBegin* b, int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  assert(stack_at(index)->as_Phi() == NULL || stack_at(index)->as_Phi()->block() != b, "phi function already created");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  ValueType* t = stack_at(index)->type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  Value phi = new Phi(t, b, -index - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  _stack[index] = phi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  if (t->is_double_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    _stack[index + 1] = phi->hi_word();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
void ValueStack::setup_phi_for_local(BlockBegin* b, int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  assert(local_at(index)->as_Phi() == NULL || local_at(index)->as_Phi()->block() != b, "phi function already created");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  ValueType* t = local_at(index)->type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  Value phi = new Phi(t, b, index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  store_local(index, phi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
void ValueStack::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  if (stack_is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    tty->print_cr("empty stack");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    InstructionPrinter ip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    for (int i = 0; i < stack_size();) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
      Value t = stack_at_inc(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
      tty->print("%2d  ", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
      ip.print_instr(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
      tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  if (!no_active_locks()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    InstructionPrinter ip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    for (int i = 0; i < locks_size(); i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
      Value t = lock_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      tty->print("lock %2d  ", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
      if (t == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
        tty->print("this");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
        ip.print_instr(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
      tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  if (locals_size() > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    InstructionPrinter ip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    for (int i = 0; i < locals_size();) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
      Value l = _locals[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
      tty->print("local %d ", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
      if (l == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
        tty->print("null");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
        i ++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
        ip.print_instr(l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
        if (l->type()->is_illegal() || l->type()->is_single_word()) i ++; else i += 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
      tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
void ValueStack::verify() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
#endif // PRODUCT