src/share/vm/c1/c1_Compiler.cpp

Tue, 18 Jun 2013 12:31:07 -0700

author
johnc
date
Tue, 18 Jun 2013 12:31:07 -0700
changeset 5277
01522ca68fc7
parent 5157
01e51113b4f5
child 5919
469216acdb28
permissions
-rw-r--r--

8015237: Parallelize string table scanning during strong root processing
Summary: Parallelize the scanning of the intern string table by having each GC worker claim a given number of buckets. Changes were also reviewed by Per Liden <per.liden@oracle.com>.
Reviewed-by: tschatzl, stefank, twisti

duke@435 1 /*
mikael@4153 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "c1/c1_Compilation.hpp"
stefank@2314 27 #include "c1/c1_Compiler.hpp"
stefank@2314 28 #include "c1/c1_FrameMap.hpp"
stefank@2314 29 #include "c1/c1_GraphBuilder.hpp"
stefank@2314 30 #include "c1/c1_LinearScan.hpp"
stefank@2314 31 #include "c1/c1_MacroAssembler.hpp"
stefank@2314 32 #include "c1/c1_Runtime1.hpp"
stefank@2314 33 #include "c1/c1_ValueType.hpp"
stefank@2314 34 #include "compiler/compileBroker.hpp"
stefank@2314 35 #include "compiler/compilerOracle.hpp"
stefank@2314 36 #include "interpreter/linkResolver.hpp"
stefank@2314 37 #include "memory/allocation.hpp"
stefank@2314 38 #include "memory/allocation.inline.hpp"
stefank@2314 39 #include "memory/resourceArea.hpp"
stefank@2314 40 #include "prims/nativeLookup.hpp"
stefank@2314 41 #include "runtime/arguments.hpp"
stefank@2314 42 #include "runtime/interfaceSupport.hpp"
stefank@2314 43 #include "runtime/sharedRuntime.hpp"
duke@435 44
duke@435 45 volatile int Compiler::_runtimes = uninitialized;
duke@435 46
duke@435 47 Compiler::Compiler() {
duke@435 48 }
duke@435 49
duke@435 50
duke@435 51 Compiler::~Compiler() {
duke@435 52 Unimplemented();
duke@435 53 }
duke@435 54
duke@435 55
iveresov@1939 56 void Compiler::initialize_all() {
iveresov@1939 57 BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
zgu@3900 58 Arena* arena = new (mtCompiler) Arena();
iveresov@1939 59 Runtime1::initialize(buffer_blob);
iveresov@1939 60 FrameMap::initialize();
iveresov@1939 61 // initialize data structures
iveresov@1939 62 ValueType::initialize(arena);
iveresov@1939 63 // Instruction::initialize();
iveresov@1939 64 // BlockBegin::initialize();
iveresov@1939 65 GraphBuilder::initialize();
iveresov@1939 66 // note: to use more than one instance of LinearScan at a time this function call has to
iveresov@1939 67 // be moved somewhere outside of this constructor:
iveresov@1939 68 Interval::initialize(arena);
iveresov@1939 69 }
iveresov@1939 70
iveresov@1939 71
duke@435 72 void Compiler::initialize() {
duke@435 73 if (_runtimes != initialized) {
iveresov@1939 74 initialize_runtimes( initialize_all, &_runtimes);
duke@435 75 }
duke@435 76 mark_initialized();
duke@435 77 }
duke@435 78
duke@435 79
anoll@5157 80 BufferBlob* Compiler::get_buffer_blob(ciEnv* env) {
anoll@5157 81 // Allocate buffer blob once at startup since allocation for each
anoll@5157 82 // compilation seems to be too expensive (at least on Intel win32).
anoll@5157 83 BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
anoll@5157 84 if (buffer_blob != NULL) {
anoll@5157 85 return buffer_blob;
anoll@5157 86 }
anoll@5157 87
iveresov@1939 88 // setup CodeBuffer. Preallocate a BufferBlob of size
iveresov@1939 89 // NMethodSizeLimit plus some extra space for constants.
iveresov@1939 90 int code_buffer_size = Compilation::desired_max_code_buffer_size() +
iveresov@1939 91 Compilation::desired_max_constant_size();
anoll@5157 92
anoll@5157 93 buffer_blob = BufferBlob::create("Compiler1 temporary CodeBuffer",
anoll@5157 94 code_buffer_size);
anoll@5157 95 if (buffer_blob == NULL) {
anoll@5157 96 CompileBroker::handle_full_code_cache();
anoll@5157 97 env->record_failure("CodeCache is full");
anoll@5157 98 } else {
anoll@5157 99 CompilerThread::current()->set_buffer_blob(buffer_blob);
anoll@5157 100 }
anoll@5157 101
anoll@5157 102 return buffer_blob;
iveresov@1939 103 }
iveresov@1939 104
iveresov@1939 105
duke@435 106 void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) {
anoll@5157 107 BufferBlob* buffer_blob = Compiler::get_buffer_blob(env);
iveresov@1939 108 if (buffer_blob == NULL) {
anoll@5157 109 return;
iveresov@1939 110 }
duke@435 111
duke@435 112 if (!is_initialized()) {
duke@435 113 initialize();
duke@435 114 }
anoll@5157 115
duke@435 116 // invoke compilation
duke@435 117 {
duke@435 118 // We are nested here because we need for the destructor
duke@435 119 // of Compilation to occur before we release the any
duke@435 120 // competing compiler thread
duke@435 121 ResourceMark rm;
iveresov@1939 122 Compilation c(this, env, method, entry_bci, buffer_blob);
duke@435 123 }
duke@435 124 }
duke@435 125
duke@435 126
duke@435 127 void Compiler::print_timers() {
duke@435 128 Compilation::print_timers();
duke@435 129 }

mercurial