hotspot/src/share/vm/shark/sharkBuilder.cpp
author twisti
Wed, 11 Aug 2010 05:51:21 -0700
changeset 6187 4fa7845f7c14
child 7397 5b173b4ca846
permissions -rw-r--r--
6976186: integrate Shark HotSpot changes Summary: Shark is a JIT compiler for Zero that uses the LLVM compiler infrastructure. Reviewed-by: kvn, twisti Contributed-by: Gary Benson <gbenson@redhat.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     1
/*
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     2
 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     3
 * Copyright 2008, 2009, 2010 Red Hat, Inc.
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
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    26
#include "incls/_precompiled.incl"
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    27
#include "incls/_sharkBuilder.cpp.incl"
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    28
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    29
using namespace llvm;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    30
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    31
SharkBuilder::SharkBuilder(SharkCodeBuffer* code_buffer)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    32
  : IRBuilder<>(SharkContext::current()),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    33
    _code_buffer(code_buffer) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    34
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    35
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    36
// Helpers for accessing structures
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    37
Value* SharkBuilder::CreateAddressOfStructEntry(Value*      base,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    38
                                                ByteSize    offset,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    39
                                                const Type* type,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    40
                                                const char* name) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    41
  return CreateBitCast(CreateStructGEP(base, in_bytes(offset)), type, name);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    42
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    43
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    44
LoadInst* SharkBuilder::CreateValueOfStructEntry(Value*      base,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    45
                                                 ByteSize    offset,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    46
                                                 const Type* type,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    47
                                                 const char* name) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    48
  return CreateLoad(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    49
    CreateAddressOfStructEntry(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    50
      base, offset, PointerType::getUnqual(type)),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    51
    name);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    52
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    53
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    54
// Helpers for accessing arrays
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    55
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    56
LoadInst* SharkBuilder::CreateArrayLength(Value* arrayoop) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    57
  return CreateValueOfStructEntry(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    58
    arrayoop, in_ByteSize(arrayOopDesc::length_offset_in_bytes()),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    59
    SharkType::jint_type(), "length");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    60
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    61
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    62
Value* SharkBuilder::CreateArrayAddress(Value*      arrayoop,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    63
                                        const Type* element_type,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    64
                                        int         element_bytes,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    65
                                        ByteSize    base_offset,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    66
                                        Value*      index,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    67
                                        const char* name) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    68
  Value* offset = CreateIntCast(index, SharkType::intptr_type(), false);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    69
  if (element_bytes != 1)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    70
    offset = CreateShl(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    71
      offset,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    72
      LLVMValue::intptr_constant(exact_log2(element_bytes)));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    73
  offset = CreateAdd(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    74
    LLVMValue::intptr_constant(in_bytes(base_offset)), offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    75
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    76
  return CreateIntToPtr(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    77
    CreateAdd(CreatePtrToInt(arrayoop, SharkType::intptr_type()), offset),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    78
    PointerType::getUnqual(element_type),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    79
    name);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    80
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    81
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    82
Value* SharkBuilder::CreateArrayAddress(Value*      arrayoop,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    83
                                        BasicType   basic_type,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    84
                                        ByteSize    base_offset,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    85
                                        Value*      index,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    86
                                        const char* name) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    87
  return CreateArrayAddress(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    88
    arrayoop,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    89
    SharkType::to_arrayType(basic_type),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    90
    type2aelembytes(basic_type),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    91
    base_offset, index, name);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    92
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    93
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    94
Value* SharkBuilder::CreateArrayAddress(Value*      arrayoop,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    95
                                        BasicType   basic_type,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    96
                                        Value*      index,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    97
                                        const char* name) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    98
  return CreateArrayAddress(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    99
    arrayoop, basic_type,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   100
    in_ByteSize(arrayOopDesc::base_offset_in_bytes(basic_type)),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   101
    index, name);
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
// Helpers for creating intrinsics and external functions.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   105
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   106
const Type* SharkBuilder::make_type(char type, bool void_ok) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   107
  switch (type) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   108
    // Primitive types
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   109
  case 'c':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   110
    return SharkType::jbyte_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   111
  case 'i':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   112
    return SharkType::jint_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   113
  case 'l':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   114
    return SharkType::jlong_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   115
  case 'x':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   116
    return SharkType::intptr_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   117
  case 'f':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   118
    return SharkType::jfloat_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   119
  case 'd':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   120
    return SharkType::jdouble_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   121
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   122
    // Pointers to primitive types
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   123
  case 'C':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   124
  case 'I':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   125
  case 'L':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   126
  case 'X':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   127
  case 'F':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   128
  case 'D':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   129
    return PointerType::getUnqual(make_type(tolower(type), false));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   130
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   131
    // VM objects
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   132
  case 'T':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   133
    return SharkType::thread_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   134
  case 'M':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   135
    return PointerType::getUnqual(SharkType::monitor_type());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   136
  case 'O':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   137
    return SharkType::oop_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   138
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   139
    // Miscellaneous
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   140
  case 'v':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   141
    assert(void_ok, "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   142
    return SharkType::void_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   143
  case '1':
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   144
    return SharkType::bit_type();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   145
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   146
  default:
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   147
    ShouldNotReachHere();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   148
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   149
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   150
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   151
const FunctionType* SharkBuilder::make_ftype(const char* params,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   152
                                             const char* ret) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   153
  std::vector<const Type*> param_types;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   154
  for (const char* c = params; *c; c++)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   155
    param_types.push_back(make_type(*c, false));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   156
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   157
  assert(strlen(ret) == 1, "should be");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   158
  const Type *return_type = make_type(*ret, true);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   159
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   160
  return FunctionType::get(return_type, param_types, false);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   161
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   162
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   163
// Create an object representing an intrinsic or external function by
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   164
// referencing the symbol by name.  This is the LLVM-style approach,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   165
// but it cannot be used on functions within libjvm.so its symbols
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   166
// are not exported.  Note that you cannot make this work simply by
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   167
// exporting the symbols, as some symbols have the same names as
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   168
// symbols in the standard libraries (eg, atan2, fabs) and would
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   169
// obscure them were they visible.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   170
Value* SharkBuilder::make_function(const char* name,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   171
                                   const char* params,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   172
                                   const char* ret) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   173
  return SharkContext::current().get_external(name, make_ftype(params, ret));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   174
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   175
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   176
// Create an object representing an external function by inlining a
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   177
// function pointer in the code.  This is not the LLVM way, but it's
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   178
// the only way to access functions in libjvm.so and functions like
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   179
// __kernel_dmb on ARM which is accessed via an absolute address.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   180
Value* SharkBuilder::make_function(address     func,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   181
                                   const char* params,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   182
                                   const char* ret) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   183
  return CreateIntToPtr(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   184
    LLVMValue::intptr_constant((intptr_t) func),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   185
    PointerType::getUnqual(make_ftype(params, ret)));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   186
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   188
// VM calls
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   189
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   190
Value* SharkBuilder::find_exception_handler() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   191
  return make_function(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   192
    (address) SharkRuntime::find_exception_handler, "TIi", "i");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   193
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   194
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   195
Value* SharkBuilder::monitorenter() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   196
  return make_function((address) SharkRuntime::monitorenter, "TM", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   197
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   198
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   199
Value* SharkBuilder::monitorexit() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   200
  return make_function((address) SharkRuntime::monitorexit, "TM", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   201
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   202
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   203
Value* SharkBuilder::new_instance() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   204
  return make_function((address) SharkRuntime::new_instance, "Ti", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   205
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   206
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   207
Value* SharkBuilder::newarray() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   208
  return make_function((address) SharkRuntime::newarray, "Tii", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   209
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   210
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   211
Value* SharkBuilder::anewarray() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   212
  return make_function((address) SharkRuntime::anewarray, "Tii", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   213
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   214
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   215
Value* SharkBuilder::multianewarray() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   216
  return make_function((address) SharkRuntime::multianewarray, "TiiI", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   217
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   218
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   219
Value* SharkBuilder::register_finalizer() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   220
  return make_function((address) SharkRuntime::register_finalizer, "TO", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   221
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   222
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   223
Value* SharkBuilder::safepoint() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   224
  return make_function((address) SafepointSynchronize::block, "T", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   225
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   226
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   227
Value* SharkBuilder::throw_ArithmeticException() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   228
  return make_function(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   229
    (address) SharkRuntime::throw_ArithmeticException, "TCi", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   230
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   231
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   232
Value* SharkBuilder::throw_ArrayIndexOutOfBoundsException() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   233
  return make_function(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   234
    (address) SharkRuntime::throw_ArrayIndexOutOfBoundsException, "TCii", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   235
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   236
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   237
Value* SharkBuilder::throw_ClassCastException() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   238
  return make_function(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   239
    (address) SharkRuntime::throw_ClassCastException, "TCi", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   240
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   241
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   242
Value* SharkBuilder::throw_NullPointerException() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   243
  return make_function(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   244
    (address) SharkRuntime::throw_NullPointerException, "TCi", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   245
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   246
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   247
// High-level non-VM calls
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   248
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   249
Value* SharkBuilder::f2i() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   250
  return make_function((address) SharedRuntime::f2i, "f", "i");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   251
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   252
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   253
Value* SharkBuilder::f2l() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   254
  return make_function((address) SharedRuntime::f2l, "f", "l");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   255
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   256
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   257
Value* SharkBuilder::d2i() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   258
  return make_function((address) SharedRuntime::d2i, "d", "i");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   259
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   260
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   261
Value* SharkBuilder::d2l() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   262
  return make_function((address) SharedRuntime::d2l, "d", "l");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   263
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   264
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   265
Value* SharkBuilder::is_subtype_of() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   266
  return make_function((address) SharkRuntime::is_subtype_of, "OO", "c");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   267
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   268
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   269
Value* SharkBuilder::current_time_millis() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   270
  return make_function((address) os::javaTimeMillis, "", "l");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   271
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   272
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   273
Value* SharkBuilder::sin() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   274
  return make_function("llvm.sin.f64", "d", "d");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   275
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   276
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   277
Value* SharkBuilder::cos() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   278
  return make_function("llvm.cos.f64", "d", "d");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   279
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   280
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   281
Value* SharkBuilder::tan() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   282
  return make_function((address) ::tan, "d", "d");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   283
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   284
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   285
Value* SharkBuilder::atan2() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   286
  return make_function((address) ::atan2, "dd", "d");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   287
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   288
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   289
Value* SharkBuilder::sqrt() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   290
  return make_function("llvm.sqrt.f64", "d", "d");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   291
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   292
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   293
Value* SharkBuilder::log() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   294
  return make_function("llvm.log.f64", "d", "d");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   295
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   296
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   297
Value* SharkBuilder::log10() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   298
  return make_function("llvm.log10.f64", "d", "d");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   299
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   300
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   301
Value* SharkBuilder::pow() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   302
  return make_function("llvm.pow.f64", "dd", "d");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   303
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   304
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   305
Value* SharkBuilder::exp() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   306
  return make_function("llvm.exp.f64", "d", "d");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   307
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   308
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   309
Value* SharkBuilder::fabs() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   310
  return make_function((address) ::fabs, "d", "d");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   311
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   312
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   313
Value* SharkBuilder::unsafe_field_offset_to_byte_offset() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   314
  extern jlong Unsafe_field_offset_to_byte_offset(jlong field_offset);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   315
  return make_function((address) Unsafe_field_offset_to_byte_offset, "l", "l");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   316
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   317
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   318
Value* SharkBuilder::osr_migration_end() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   319
  return make_function((address) SharedRuntime::OSR_migration_end, "C", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   320
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   321
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   322
// Semi-VM calls
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   323
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   324
Value* SharkBuilder::throw_StackOverflowError() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   325
  return make_function((address) ZeroStack::handle_overflow, "T", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   326
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   327
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   328
Value* SharkBuilder::uncommon_trap() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   329
  return make_function((address) SharkRuntime::uncommon_trap, "Ti", "i");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   330
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   331
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   332
Value* SharkBuilder::deoptimized_entry_point() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   333
  return make_function((address) CppInterpreter::main_loop, "iT", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   334
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   335
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   336
// Native-Java transition
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   337
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   338
Value* SharkBuilder::check_special_condition_for_native_trans() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   339
  return make_function(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   340
    (address) JavaThread::check_special_condition_for_native_trans,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   341
    "T", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   342
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   343
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   344
// Low-level non-VM calls
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   345
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   346
// The ARM-specific code here is to work around unimplemented
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   347
// atomic exchange and memory barrier intrinsics in LLVM.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   348
//
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   349
// Delegating to external functions for these would normally
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   350
// incur a speed penalty, but Linux on ARM is a special case
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   351
// in that atomic operations on that platform are handled by
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   352
// external functions anyway.  It would be *preferable* for
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   353
// the calls to be hidden away in LLVM, but it's not hurting
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   354
// performance so having the calls here is acceptable.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   355
//
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   356
// If you are building Shark on a platform without atomic
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   357
// exchange and/or memory barrier intrinsics then it is only
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   358
// acceptable to mimic this approach if your platform cannot
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   359
// perform these operations without delegating to a function.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   360
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   361
#ifdef ARM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   362
static jint zero_cmpxchg_int(volatile jint *ptr, jint oldval, jint newval) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   363
  return Atomic::cmpxchg(newval, ptr, oldval);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   364
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   365
#endif // ARM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   366
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   367
Value* SharkBuilder::cmpxchg_int() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   368
  return make_function(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   369
#ifdef ARM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   370
    (address) zero_cmpxchg_int,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   371
#else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   372
    "llvm.atomic.cmp.swap.i32.p0i32",
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   373
#endif // ARM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   374
    "Iii", "i");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   375
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   376
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   377
#ifdef ARM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   378
static intptr_t zero_cmpxchg_ptr(volatile intptr_t* ptr,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   379
                                 intptr_t           oldval,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   380
                                 intptr_t           newval) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   381
  return Atomic::cmpxchg_ptr(newval, ptr, oldval);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   382
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   383
#endif // ARM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   384
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   385
Value* SharkBuilder::cmpxchg_ptr() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   386
  return make_function(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   387
#ifdef ARM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   388
    (address) zero_cmpxchg_ptr,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   389
#else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   390
    "llvm.atomic.cmp.swap.i" LP64_ONLY("64") NOT_LP64("32") ".p0i" LP64_ONLY("64") NOT_LP64("32"),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   391
#endif // ARM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   392
    "Xxx", "x");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   393
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   394
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   395
Value* SharkBuilder::frame_address() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   396
  return make_function("llvm.frameaddress", "i", "C");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   397
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   398
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   399
Value* SharkBuilder::memory_barrier() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   400
  return make_function(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   401
#ifdef ARM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   402
    (address) 0xffff0fa0, // __kernel_dmb
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   403
#else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   404
    "llvm.memory.barrier",
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   405
#endif // ARM
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   406
    "11111", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   407
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   408
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   409
Value* SharkBuilder::memset() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   410
#if SHARK_LLVM_VERSION >= 28
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   411
  // LLVM 2.8 added a fifth isVolatile field for memset
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   412
  // introduced with LLVM r100304
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   413
  return make_function("llvm.memset.i32", "Cciii", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   414
#else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   415
  return make_function("llvm.memset.i32", "Ccii", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   416
#endif
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   417
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   418
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   419
Value* SharkBuilder::unimplemented() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   420
  return make_function((address) report_unimplemented, "Ci", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   421
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   422
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   423
Value* SharkBuilder::should_not_reach_here() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   424
  return make_function((address) report_should_not_reach_here, "Ci", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   425
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   426
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   427
Value* SharkBuilder::dump() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   428
  return make_function((address) SharkRuntime::dump, "Cx", "v");
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   429
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   430
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   431
// Public interface to low-level non-VM calls
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   432
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   433
CallInst* SharkBuilder::CreateCmpxchgInt(Value* exchange_value,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   434
                                         Value* dst,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   435
                                         Value* compare_value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   436
  return CreateCall3(cmpxchg_int(), dst, compare_value, exchange_value);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   437
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   438
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   439
CallInst* SharkBuilder::CreateCmpxchgPtr(Value* exchange_value,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   440
                                         Value* dst,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   441
                                         Value* compare_value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   442
  return CreateCall3(cmpxchg_ptr(), dst, compare_value, exchange_value);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   443
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   444
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   445
CallInst* SharkBuilder::CreateGetFrameAddress() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   446
  return CreateCall(frame_address(), LLVMValue::jint_constant(0));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   447
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   448
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   449
CallInst *SharkBuilder::CreateMemoryBarrier(int flags) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   450
  Value *args[] = {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   451
    LLVMValue::bit_constant((flags & BARRIER_LOADLOAD) ? 1 : 0),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   452
    LLVMValue::bit_constant((flags & BARRIER_LOADSTORE) ? 1 : 0),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   453
    LLVMValue::bit_constant((flags & BARRIER_STORELOAD) ? 1 : 0),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   454
    LLVMValue::bit_constant((flags & BARRIER_STORESTORE) ? 1 : 0),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   455
    LLVMValue::bit_constant(1)};
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   456
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   457
  return CreateCall(memory_barrier(), args, args + 5);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   458
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   459
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   460
CallInst* SharkBuilder::CreateMemset(Value* dst,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   461
                                     Value* value,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   462
                                     Value* len,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   463
                                     Value* align) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   464
#if SHARK_LLVM_VERSION >= 28
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   465
  return CreateCall5(memset(), dst, value, len, align,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   466
                     LLVMValue::jint_constant(0));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   467
#else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   468
  return CreateCall4(memset(), dst, value, len, align);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   469
#endif
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   470
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   471
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   472
CallInst* SharkBuilder::CreateUnimplemented(const char* file, int line) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   473
  return CreateCall2(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   474
    unimplemented(),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   475
    CreateIntToPtr(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   476
      LLVMValue::intptr_constant((intptr_t) file),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   477
      PointerType::getUnqual(SharkType::jbyte_type())),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   478
    LLVMValue::jint_constant(line));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   479
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   480
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   481
CallInst* SharkBuilder::CreateShouldNotReachHere(const char* file, int line) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   482
  return CreateCall2(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   483
    should_not_reach_here(),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   484
    CreateIntToPtr(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   485
      LLVMValue::intptr_constant((intptr_t) file),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   486
      PointerType::getUnqual(SharkType::jbyte_type())),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   487
    LLVMValue::jint_constant(line));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   488
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   489
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   490
#ifndef PRODUCT
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   491
CallInst* SharkBuilder::CreateDump(Value* value) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   492
  const char *name;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   493
  if (value->hasName())
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   494
    // XXX this leaks, but it's only debug code
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   495
    name = strdup(value->getName().str().c_str());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   496
  else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   497
    name = "unnamed_value";
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   498
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   499
  if (isa<PointerType>(value->getType()))
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   500
    value = CreatePtrToInt(value, SharkType::intptr_type());
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   501
  else if (value->getType()->
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   502
#if SHARK_LLVM_VERSION >= 27
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   503
           isIntegerTy()
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   504
#else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   505
           isInteger()
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   506
#endif
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   507
           )
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   508
    value = CreateIntCast(value, SharkType::intptr_type(), false);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   509
  else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   510
    Unimplemented();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   511
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   512
  return CreateCall2(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   513
    dump(),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   514
    CreateIntToPtr(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   515
      LLVMValue::intptr_constant((intptr_t) name),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   516
      PointerType::getUnqual(SharkType::jbyte_type())),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   517
    value);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   518
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   519
#endif // PRODUCT
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   520
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   521
// HotSpot memory barriers
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   522
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   523
void SharkBuilder::CreateUpdateBarrierSet(BarrierSet* bs, Value* field) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   524
  if (bs->kind() != BarrierSet::CardTableModRef)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   525
    Unimplemented();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   526
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   527
  CreateStore(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   528
    LLVMValue::jbyte_constant(CardTableModRefBS::dirty_card),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   529
    CreateIntToPtr(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   530
      CreateAdd(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   531
        LLVMValue::intptr_constant(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   532
          (intptr_t) ((CardTableModRefBS *) bs)->byte_map_base),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   533
        CreateLShr(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   534
          CreatePtrToInt(field, SharkType::intptr_type()),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   535
          LLVMValue::intptr_constant(CardTableModRefBS::card_shift))),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   536
      PointerType::getUnqual(SharkType::jbyte_type())));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   537
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   538
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   539
// Helpers for accessing the code buffer
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   540
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   541
Value* SharkBuilder::code_buffer_address(int offset) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   542
  return CreateAdd(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   543
    code_buffer()->base_pc(),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   544
    LLVMValue::intptr_constant(offset));
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   545
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   546
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   547
Value* SharkBuilder::CreateInlineOop(jobject object, const char* name) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   548
  return CreateLoad(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   549
    CreateIntToPtr(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   550
      code_buffer_address(code_buffer()->inline_oop(object)),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   551
      PointerType::getUnqual(SharkType::oop_type())),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   552
    name);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   553
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   554
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   555
Value* SharkBuilder::CreateInlineData(void*       data,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   556
                                      size_t      size,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   557
                                      const Type* type,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   558
                                      const char* name) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   559
  return CreateIntToPtr(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   560
    code_buffer_address(code_buffer()->inline_data(data, size)),
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   561
    type,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   562
    name);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   563
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   564
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   565
// Helpers for creating basic blocks.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   566
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   567
BasicBlock* SharkBuilder::GetBlockInsertionPoint() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   568
  BasicBlock *cur = GetInsertBlock();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   569
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   570
  // BasicBlock::Create takes an insertBefore argument, so
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   571
  // we need to find the block _after_ the current block
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   572
  Function::iterator iter = cur->getParent()->begin();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   573
  Function::iterator end  = cur->getParent()->end();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   574
  while (iter != end) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   575
    iter++;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   576
    if (&*iter == cur) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   577
      iter++;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   578
      break;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   579
    }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   580
  }
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   581
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   582
  if (iter == end)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   583
    return NULL;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   584
  else
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   585
    return iter;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   586
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   587
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   588
BasicBlock* SharkBuilder::CreateBlock(BasicBlock* ip, const char* name) const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   589
  return BasicBlock::Create(
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   590
    SharkContext::current(), name, GetInsertBlock()->getParent(), ip);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   591
}