src/hotspot/cpu/zero/stack_zero.cpp
author stefank
Thu, 09 May 2019 14:28:30 +0200
changeset 54786 ebf733a324d4
parent 52818 cfbe4d8ffd1d
permissions -rw-r--r--
8223624: Cleanup includes of universe.hpp Reviewed-by: coleenp, lkorinth
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     1
/*
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 47687
diff changeset
     2
 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     3
 * Copyright 2010 Red Hat, Inc.
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     5
 *
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     8
 * published by the Free Software Foundation.
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
     9
 *
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    14
 * accompanied this code).
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    15
 *
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    19
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5424
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5424
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5424
diff changeset
    22
 * questions.
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    23
 *
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    24
 */
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    25
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "precompiled.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 47687
diff changeset
    27
#include "interpreter/bytecodeInterpreter.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "interpreter/interpreterRuntime.hpp"
52818
cfbe4d8ffd1d 8214787: Zero builds fail with "undefined JavaThread::thread_state()"
shade
parents: 49480
diff changeset
    29
#include "runtime/thread.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "stack_zero.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "stack_zero.inline.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 47687
diff changeset
    32
#include "runtime/frame.inline.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    33
#include "utilities/align.hpp"
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    34
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 27669
diff changeset
    35
// Inlined causes circular inclusion with thread.hpp
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 27669
diff changeset
    36
ZeroStack::ZeroStack()
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 27669
diff changeset
    37
    : _base(NULL), _top(NULL), _sp(NULL) {
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 27669
diff changeset
    38
    _shadow_pages_size = JavaThread::stack_shadow_zone_size();
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 27669
diff changeset
    39
  }
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 27669
diff changeset
    40
5424
fc1c380199b0 6950178: Zero stack improvements
twisti
parents: 5418
diff changeset
    41
int ZeroStack::suggest_size(Thread *thread) const {
fc1c380199b0 6950178: Zero stack improvements
twisti
parents: 5418
diff changeset
    42
  assert(needs_setup(), "already set up");
27669
c2c526bc1a18 8064815: Zero+PPC64: Stack overflow when running Maven
simonis
parents: 10256
diff changeset
    43
  int abi_available = abi_stack_available(thread);
c2c526bc1a18 8064815: Zero+PPC64: Stack overflow when running Maven
simonis
parents: 10256
diff changeset
    44
  assert(abi_available >= 0, "available abi stack must be >= 0");
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 35479
diff changeset
    45
  return align_down(abi_available / 2, wordSize);
5424
fc1c380199b0 6950178: Zero stack improvements
twisti
parents: 5418
diff changeset
    46
}
fc1c380199b0 6950178: Zero stack improvements
twisti
parents: 5418
diff changeset
    47
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    48
void ZeroStack::handle_overflow(TRAPS) {
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    49
  JavaThread *thread = (JavaThread *) THREAD;
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    50
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    51
  // Set up the frame anchor if it isn't already
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    52
  bool has_last_Java_frame = thread->has_last_Java_frame();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    53
  if (!has_last_Java_frame) {
5418
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    54
    intptr_t *sp = thread->zero_stack()->sp();
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    55
    ZeroFrame *frame = thread->top_zero_frame();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    56
    while (frame) {
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    57
      if (frame->is_interpreter_frame()) {
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    58
        interpreterState istate =
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    59
          frame->as_interpreter_frame()->interpreter_state();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    60
        if (istate->self_link() == istate)
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    61
          break;
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    62
      }
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    63
5418
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    64
      sp = ((intptr_t *) frame) + 1;
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    65
      frame = frame->next();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    66
    }
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    67
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    68
    if (frame == NULL)
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    69
      fatal("unrecoverable stack overflow");
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    70
5418
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    71
    thread->set_last_Java_frame(frame, sp);
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    72
  }
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    73
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    74
  // Throw the exception
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    75
  switch (thread->thread_state()) {
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    76
  case _thread_in_Java:
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    77
    InterpreterRuntime::throw_StackOverflowError(thread);
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    78
    break;
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    79
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    80
  case _thread_in_vm:
10256
8a0a9bbb6fa5 7066143: JSR 292: Zero support after regressions from 7009923 and 7009309
twisti
parents: 7397
diff changeset
    81
    Exceptions::throw_stack_overflow_exception(thread, __FILE__, __LINE__,
8a0a9bbb6fa5 7066143: JSR 292: Zero support after regressions from 7009923 and 7009309
twisti
parents: 7397
diff changeset
    82
                                               methodHandle());
5339
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    83
    break;
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    84
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    85
  default:
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    86
    ShouldNotReachHere();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    87
  }
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    88
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    89
  // Reset the frame anchor if necessary
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    90
  if (!has_last_Java_frame)
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    91
    thread->reset_last_Java_frame();
ee4d549502b1 6944473: 6941224 misses new files
twisti
parents:
diff changeset
    92
}
5418
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    93
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    94
#ifndef PRODUCT
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    95
void ZeroStack::zap(int c) {
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    96
  memset(_base, c, available_words() * wordSize);
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    97
}
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5339
diff changeset
    98
#endif // PRODUCT