hotspot/src/share/vm/shark/sharkCompiler.cpp
author coleenp
Mon, 14 Jan 2013 11:01:39 -0500
changeset 15194 a35093d73168
parent 14622 8e94e4186d35
child 15206 b86a40ac02ff
permissions -rw-r--r--
8006005: Fix constant pool index validation and alignment trap for method parameter reflection Summary: This patch addresses an alignment trap due to the storage format of method parameters data in constMethod. It also adds code to validate constant pool indexes for method parameters data. Reviewed-by: jrose, dholmes Contributed-by: eric.mccorkle@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
9103
535a93f494f6 7032458: Zero and Shark fixes
twisti
parents: 7397
diff changeset
     3
 * Copyright 2008, 2009, 2010, 2011 Red Hat, Inc.
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     5
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     8
 * published by the Free Software Foundation.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     9
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    14
 * accompanied this code).
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    15
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    19
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    22
 * questions.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    23
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    24
 */
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    25
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    26
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    27
#include "ci/ciEnv.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    28
#include "ci/ciMethod.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    29
#include "code/debugInfoRec.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    30
#include "code/dependencies.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    31
#include "code/exceptionHandlerTable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    32
#include "code/oopRecorder.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    33
#include "compiler/abstractCompiler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    34
#include "compiler/oopMap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    35
#include "shark/llvmHeaders.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    36
#include "shark/sharkBuilder.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    37
#include "shark/sharkCodeBuffer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    38
#include "shark/sharkCompiler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    39
#include "shark/sharkContext.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    40
#include "shark/sharkEntry.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    41
#include "shark/sharkFunction.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    42
#include "shark/sharkMemoryManager.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    43
#include "shark/sharkNativeWrapper.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    44
#include "shark/shark_globals.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    45
#include "utilities/debug.hpp"
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    46
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    47
#include <fnmatch.h>
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    48
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    49
using namespace llvm;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    50
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    51
namespace {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    52
  cl::opt<std::string>
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    53
  MCPU("mcpu");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    54
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    55
  cl::list<std::string>
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    56
  MAttrs("mattr",
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    57
         cl::CommaSeparated);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    58
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    59
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    60
SharkCompiler::SharkCompiler()
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    61
  : AbstractCompiler() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    62
  // Create the lock to protect the memory manager and execution engine
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    63
  _execution_engine_lock = new Monitor(Mutex::leaf, "SharkExecutionEngineLock");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    64
  MutexLocker locker(execution_engine_lock());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    65
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    66
  // Make LLVM safe for multithreading
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    67
  if (!llvm_start_multithreaded())
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    68
    fatal("llvm_start_multithreaded() failed");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    69
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    70
  // Initialize the native target
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    71
  InitializeNativeTarget();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    72
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
    73
  // MCJIT require a native AsmPrinter
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
    74
  InitializeNativeTargetAsmPrinter();
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
    75
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    76
  // Create the two contexts which we'll use
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    77
  _normal_context = new SharkContext("normal");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    78
  _native_context = new SharkContext("native");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    79
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    80
  // Create the memory manager
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    81
  _memory_manager = new SharkMemoryManager();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    82
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    83
  // Finetune LLVM for the current host CPU.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    84
  StringMap<bool> Features;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    85
  bool gotCpuFeatures = llvm::sys::getHostCPUFeatures(Features);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    86
  std::string cpu("-mcpu=" + llvm::sys::getHostCPUName());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    87
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    88
  std::vector<const char*> args;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    89
  args.push_back(""); // program name
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    90
  args.push_back(cpu.c_str());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    91
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    92
  std::string mattr("-mattr=");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    93
  if(gotCpuFeatures){
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    94
    for(StringMap<bool>::iterator I = Features.begin(),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    95
      E = Features.end(); I != E; ++I){
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    96
      if(I->second){
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    97
        std::string attr(I->first());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    98
        mattr+="+"+attr+",";
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    99
      }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   100
    }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   101
    args.push_back(mattr.c_str());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   102
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   103
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   104
  args.push_back(0);  // terminator
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   105
  cl::ParseCommandLineOptions(args.size() - 1, (char **) &args[0]);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   106
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   107
  // Create the JIT
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   108
  std::string ErrorMsg;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   109
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   110
  EngineBuilder builder(_normal_context->module());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   111
  builder.setMCPU(MCPU);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   112
  builder.setMAttrs(MAttrs);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   113
  builder.setJITMemoryManager(memory_manager());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   114
  builder.setEngineKind(EngineKind::JIT);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   115
  builder.setErrorStr(&ErrorMsg);
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   116
  if (! fnmatch(SharkOptimizationLevel, "None", 0)) {
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   117
    tty->print_cr("Shark optimization level set to: None");
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   118
    builder.setOptLevel(llvm::CodeGenOpt::None);
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   119
  } else if (! fnmatch(SharkOptimizationLevel, "Less", 0)) {
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   120
    tty->print_cr("Shark optimization level set to: Less");
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   121
    builder.setOptLevel(llvm::CodeGenOpt::Less);
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   122
  } else if (! fnmatch(SharkOptimizationLevel, "Aggressive", 0)) {
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   123
    tty->print_cr("Shark optimization level set to: Aggressive");
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   124
    builder.setOptLevel(llvm::CodeGenOpt::Aggressive);
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   125
  } // else Default is selected by, well, default :-)
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   126
  _execution_engine = builder.create();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   127
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   128
  if (!execution_engine()) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   129
    if (!ErrorMsg.empty())
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   130
      printf("Error while creating Shark JIT: %s\n",ErrorMsg.c_str());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   131
    else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   132
      printf("Unknown error while creating Shark JIT\n");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   133
    exit(1);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   134
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   135
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   136
  execution_engine()->addModule(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   137
    _native_context->module());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   138
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   139
  // All done
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   140
  mark_initialized();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   141
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   142
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   143
void SharkCompiler::initialize() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   144
  ShouldNotCallThis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   145
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   146
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   147
void SharkCompiler::compile_method(ciEnv*    env,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   148
                                   ciMethod* target,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   149
                                   int       entry_bci) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   150
  assert(is_initialized(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   151
  ResourceMark rm;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   152
  const char *name = methodname(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   153
    target->holder()->name()->as_utf8(), target->name()->as_utf8());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   154
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   155
  // Do the typeflow analysis
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   156
  ciTypeFlow *flow;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   157
  if (entry_bci == InvocationEntryBci)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   158
    flow = target->get_flow_analysis();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   159
  else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   160
    flow = target->get_osr_flow_analysis(entry_bci);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   161
  if (flow->failing())
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   162
    return;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   163
  if (SharkPrintTypeflowOf != NULL) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   164
    if (!fnmatch(SharkPrintTypeflowOf, name, 0))
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   165
      flow->print_on(tty);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   166
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   167
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   168
  // Create the recorders
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   169
  Arena arena;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   170
  env->set_oop_recorder(new OopRecorder(&arena));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   171
  OopMapSet oopmaps;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   172
  env->set_debug_info(new DebugInformationRecorder(env->oop_recorder()));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   173
  env->debug_info()->set_oopmaps(&oopmaps);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   174
  env->set_dependencies(new Dependencies(env));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   175
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   176
  // Create the code buffer and builder
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   177
  CodeBuffer hscb("Shark", 256 * K, 64 * K);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   178
  hscb.initialize_oop_recorder(env->oop_recorder());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   179
  MacroAssembler *masm = new MacroAssembler(&hscb);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   180
  SharkCodeBuffer cb(masm);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   181
  SharkBuilder builder(&cb);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   182
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   183
  // Emit the entry point
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   184
  SharkEntry *entry = (SharkEntry *) cb.malloc(sizeof(SharkEntry));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   185
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   186
  // Build the LLVM IR for the method
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   187
  Function *function = SharkFunction::build(env, &builder, flow, name);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   188
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   189
  // Generate native code.  It's unpleasant that we have to drop into
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   190
  // the VM to do this -- it blocks safepoints -- but I can't see any
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   191
  // other way to handle the locking.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   192
  {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   193
    ThreadInVMfromNative tiv(JavaThread::current());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   194
    generate_native_code(entry, function, name);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   195
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   196
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   197
  // Install the method into the VM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   198
  CodeOffsets offsets;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   199
  offsets.set_value(CodeOffsets::Deopt, 0);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   200
  offsets.set_value(CodeOffsets::Exceptions, 0);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   201
  offsets.set_value(CodeOffsets::Verified_Entry,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   202
                    target->is_static() ? 0 : wordSize);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   203
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   204
  ExceptionHandlerTable handler_table;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   205
  ImplicitExceptionTable inc_table;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   206
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   207
  env->register_method(target,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   208
                       entry_bci,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   209
                       &offsets,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   210
                       0,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   211
                       &hscb,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   212
                       0,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   213
                       &oopmaps,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   214
                       &handler_table,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   215
                       &inc_table,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   216
                       this,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   217
                       env->comp_level(),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   218
                       false,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   219
                       false);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   220
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   221
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   222
nmethod* SharkCompiler::generate_native_wrapper(MacroAssembler* masm,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   223
                                                methodHandle    target,
9103
535a93f494f6 7032458: Zero and Shark fixes
twisti
parents: 7397
diff changeset
   224
                                                int             compile_id,
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   225
                                                BasicType*      arg_types,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   226
                                                BasicType       return_type) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   227
  assert(is_initialized(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   228
  ResourceMark rm;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   229
  const char *name = methodname(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   230
    target->klass_name()->as_utf8(), target->name()->as_utf8());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   231
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   232
  // Create the code buffer and builder
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   233
  SharkCodeBuffer cb(masm);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   234
  SharkBuilder builder(&cb);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   235
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   236
  // Emit the entry point
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   237
  SharkEntry *entry = (SharkEntry *) cb.malloc(sizeof(SharkEntry));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   238
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   239
  // Build the LLVM IR for the method
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   240
  SharkNativeWrapper *wrapper = SharkNativeWrapper::build(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   241
    &builder, target, name, arg_types, return_type);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   242
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   243
  // Generate native code
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   244
  generate_native_code(entry, wrapper->function(), name);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   245
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   246
  // Return the nmethod for installation in the VM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   247
  return nmethod::new_native_nmethod(target,
9103
535a93f494f6 7032458: Zero and Shark fixes
twisti
parents: 7397
diff changeset
   248
                                     compile_id,
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   249
                                     masm->code(),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   250
                                     0,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   251
                                     0,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   252
                                     wrapper->frame_size(),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   253
                                     wrapper->receiver_offset(),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   254
                                     wrapper->lock_offset(),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   255
                                     wrapper->oop_maps());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   256
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   257
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   258
void SharkCompiler::generate_native_code(SharkEntry* entry,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   259
                                         Function*   function,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   260
                                         const char* name) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   261
  // Print the LLVM bitcode, if requested
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   262
  if (SharkPrintBitcodeOf != NULL) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   263
    if (!fnmatch(SharkPrintBitcodeOf, name, 0))
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   264
      function->dump();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   265
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   266
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   267
  if (SharkVerifyFunction != NULL) {
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   268
    if (!fnmatch(SharkVerifyFunction, name, 0)) {
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   269
      verifyFunction(*function);
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   270
    }
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   271
  }
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   272
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   273
  // Compile to native code
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   274
  address code = NULL;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   275
  context()->add_function(function);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   276
  {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   277
    MutexLocker locker(execution_engine_lock());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   278
    free_queued_methods();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   279
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   280
#ifndef NDEBUG
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   281
#if SHARK_LLVM_VERSION <= 31
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   282
#define setCurrentDebugType SetCurrentDebugType
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   283
#endif
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   284
    if (SharkPrintAsmOf != NULL) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   285
      if (!fnmatch(SharkPrintAsmOf, name, 0)) {
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   286
        llvm::setCurrentDebugType(X86_ONLY("x86-emitter") NOT_X86("jit"));
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   287
        llvm::DebugFlag = true;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   288
      }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   289
      else {
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   290
        llvm::setCurrentDebugType("");
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   291
        llvm::DebugFlag = false;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   292
      }
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   293
    }
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   294
#ifdef setCurrentDebugType
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   295
#undef setCurrentDebugType
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   296
#endif
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   297
#endif // !NDEBUG
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   298
    memory_manager()->set_entry_for_function(function, entry);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   299
    code = (address) execution_engine()->getPointerToFunction(function);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   300
  }
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   301
  assert(code != NULL, "code must be != NULL");
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   302
  entry->set_entry_point(code);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   303
  entry->set_function(function);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   304
  entry->set_context(context());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   305
  address code_start = entry->code_start();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   306
  address code_limit = entry->code_limit();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   307
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   308
  // Register generated code for profiling, etc
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   309
  if (JvmtiExport::should_post_dynamic_code_generated())
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   310
    JvmtiExport::post_dynamic_code_generated(name, code_start, code_limit);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   311
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   312
  // Print debug information, if requested
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   313
  if (SharkTraceInstalls) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   314
    tty->print_cr(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   315
      " [%p-%p): %s (%d bytes code)",
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   316
      code_start, code_limit, name, code_limit - code_start);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   317
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   318
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   319
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   320
void SharkCompiler::free_compiled_method(address code) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   321
  // This method may only be called when the VM is at a safepoint.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   322
  // All _thread_in_vm threads will be waiting for the safepoint to
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   323
  // finish with the exception of the VM thread, so we can consider
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   324
  // ourself the owner of the execution engine lock even though we
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   325
  // can't actually acquire it at this time.
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   326
  assert(Thread::current()->is_Compiler_thread(), "must be called by compiler thread");
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 9103
diff changeset
   327
  assert_locked_or_safepoint(CodeCache_lock);
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   328
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   329
  SharkEntry *entry = (SharkEntry *) code;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   330
  entry->context()->push_to_free_queue(entry->function());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   331
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   332
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   333
void SharkCompiler::free_queued_methods() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   334
  // The free queue is protected by the execution engine lock
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   335
  assert(execution_engine_lock()->owned_by_self(), "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   336
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   337
  while (true) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   338
    Function *function = context()->pop_from_free_queue();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   339
    if (function == NULL)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   340
      break;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   341
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   342
    execution_engine()->freeMachineCodeForFunction(function);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   343
    function->eraseFromParent();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   344
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   345
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   346
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   347
const char* SharkCompiler::methodname(const char* klass, const char* method) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   348
  char *buf = NEW_RESOURCE_ARRAY(char, strlen(klass) + 2 + strlen(method) + 1);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   349
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   350
  char *dst = buf;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   351
  for (const char *c = klass; *c; c++) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   352
    if (*c == '/')
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   353
      *(dst++) = '.';
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   354
    else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   355
      *(dst++) = *c;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   356
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   357
  *(dst++) = ':';
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   358
  *(dst++) = ':';
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   359
  for (const char *c = method; *c; c++) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   360
    *(dst++) = *c;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   361
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   362
  *(dst++) = '\0';
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   363
  return buf;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   364
}