hotspot/src/share/vm/c1/c1_Compiler.cpp
author xdono
Mon, 15 Dec 2008 16:55:11 -0800
changeset 1623 a0dd9009e992
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6785258: Update copyright year Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008 Reviewed-by: katleman, ohair, tbell
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-2007 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_Compiler.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
volatile int Compiler::_runtimes = uninitialized;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
volatile bool Compiler::_compiling = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
Compiler::Compiler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
Compiler::~Compiler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
void Compiler::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  if (_runtimes != initialized) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    initialize_runtimes( Runtime1::initialize, &_runtimes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  mark_initialized();
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
void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  if (!is_initialized()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // invoke compilation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
#ifdef TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // We are thread in native here...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  CompilerThread* thread = CompilerThread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    ThreadInVMfromNative tv(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    MutexLocker only_one (C1_lock, thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    while ( _compiling) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
      C1_lock->wait();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    _compiling = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
#endif // TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    // We are nested here because we need for the destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    // of Compilation to occur before we release the any
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    // competing compiler thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    Compilation c(this, env, method, entry_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
#ifdef TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    ThreadInVMfromNative tv(thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    MutexLocker only_one (C1_lock, thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    _compiling = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    C1_lock->notify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
#endif // TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
void Compiler::print_timers() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  Compilation::print_timers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
}