hotspot/src/share/vm/c1/c1_Compiler.cpp
author anoll
Thu, 23 May 2013 14:11:09 +0200
changeset 17623 6295813086d0
parent 13963 e5b53c306fb5
child 20707 b3b658c6d1f8
permissions -rw-r--r--
8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87) Summary: Disable client compiler and switch to interpreter if there is not enough free space in the code cache. Reviewed-by: kvn, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13963
e5b53c306fb5 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 13195
diff changeset
     2
 * Copyright (c) 1999, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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: 5707
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    26
#include "c1/c1_Compilation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    27
#include "c1/c1_Compiler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    28
#include "c1/c1_FrameMap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    29
#include "c1/c1_GraphBuilder.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    30
#include "c1/c1_LinearScan.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    31
#include "c1/c1_MacroAssembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    32
#include "c1/c1_Runtime1.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    33
#include "c1/c1_ValueType.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    34
#include "compiler/compileBroker.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    35
#include "compiler/compilerOracle.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    36
#include "interpreter/linkResolver.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    37
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    38
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    39
#include "memory/resourceArea.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    40
#include "prims/nativeLookup.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    41
#include "runtime/arguments.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    42
#include "runtime/interfaceSupport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5707
diff changeset
    43
#include "runtime/sharedRuntime.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
volatile int Compiler::_runtimes = uninitialized;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
Compiler::Compiler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
Compiler::~Compiler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    56
void Compiler::initialize_all() {
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    57
  BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7397
diff changeset
    58
  Arena* arena = new (mtCompiler) Arena();
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    59
  Runtime1::initialize(buffer_blob);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    60
  FrameMap::initialize();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    61
  // initialize data structures
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    62
  ValueType::initialize(arena);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    63
  // Instruction::initialize();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    64
  // BlockBegin::initialize();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    65
  GraphBuilder::initialize();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    66
  // note: to use more than one instance of LinearScan at a time this function call has to
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    67
  //       be moved somewhere outside of this constructor:
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    68
  Interval::initialize(arena);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    69
}
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    70
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    71
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
void Compiler::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  if (_runtimes != initialized) {
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    74
    initialize_runtimes( initialize_all, &_runtimes);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  mark_initialized();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
17623
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    80
BufferBlob* Compiler::get_buffer_blob(ciEnv* env) {
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    81
  // Allocate buffer blob once at startup since allocation for each
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    82
  // compilation seems to be too expensive (at least on Intel win32).
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    83
  BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    84
  if (buffer_blob != NULL) {
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    85
    return buffer_blob;
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    86
  }
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    87
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    88
  // setup CodeBuffer.  Preallocate a BufferBlob of size
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    89
  // NMethodSizeLimit plus some extra space for constants.
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    90
  int code_buffer_size = Compilation::desired_max_code_buffer_size() +
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
    91
    Compilation::desired_max_constant_size();
17623
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    92
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    93
  buffer_blob = BufferBlob::create("Compiler1 temporary CodeBuffer",
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    94
                                   code_buffer_size);
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    95
  if (buffer_blob == NULL) {
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    96
    CompileBroker::handle_full_code_cache();
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    97
    env->record_failure("CodeCache is full");
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    98
  } else {
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
    99
    CompilerThread::current()->set_buffer_blob(buffer_blob);
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
   100
  }
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
   101
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
   102
  return buffer_blob;
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   103
}
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   104
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   105
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) {
17623
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
   107
  BufferBlob* buffer_blob = Compiler::get_buffer_blob(env);
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   108
  if (buffer_blob == NULL) {
17623
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
   109
    return;
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   110
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  if (!is_initialized()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  }
17623
6295813086d0 8014430: JRE crashes instead of stop compilation on full Code Cache. Internal Error (c1_Compiler.cpp:87)
anoll
parents: 13963
diff changeset
   115
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // invoke compilation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    // We are nested here because we need for the destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    // of Compilation to occur before we release the any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    // competing compiler thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    ResourceMark rm;
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   122
    Compilation c(this, env, method, entry_bci, buffer_blob);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
void Compiler::print_timers() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  Compilation::print_timers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
}