src/share/vm/shark/sharkFunction.hpp

Wed, 11 Aug 2010 05:51:21 -0700

author
twisti
date
Wed, 11 Aug 2010 05:51:21 -0700
changeset 2047
d2ede61b7a12
child 2314
f95d63e2154a
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>

twisti@2047 1 /*
twisti@2047 2 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
twisti@2047 3 * Copyright 2008, 2009 Red Hat, Inc.
twisti@2047 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
twisti@2047 5 *
twisti@2047 6 * This code is free software; you can redistribute it and/or modify it
twisti@2047 7 * under the terms of the GNU General Public License version 2 only, as
twisti@2047 8 * published by the Free Software Foundation.
twisti@2047 9 *
twisti@2047 10 * This code is distributed in the hope that it will be useful, but WITHOUT
twisti@2047 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
twisti@2047 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
twisti@2047 13 * version 2 for more details (a copy is included in the LICENSE file that
twisti@2047 14 * accompanied this code).
twisti@2047 15 *
twisti@2047 16 * You should have received a copy of the GNU General Public License version
twisti@2047 17 * 2 along with this work; if not, write to the Free Software Foundation,
twisti@2047 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
twisti@2047 19 *
twisti@2047 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
twisti@2047 21 * or visit www.oracle.com if you need additional information or have any
twisti@2047 22 * questions.
twisti@2047 23 *
twisti@2047 24 */
twisti@2047 25
twisti@2047 26 class SharkTopLevelBlock;
twisti@2047 27 class DeferredZeroCheck;
twisti@2047 28
twisti@2047 29 class SharkFunction : public SharkTargetInvariants {
twisti@2047 30 friend class SharkStackWithNormalFrame;
twisti@2047 31
twisti@2047 32 public:
twisti@2047 33 static llvm::Function* build(ciEnv* env,
twisti@2047 34 SharkBuilder* builder,
twisti@2047 35 ciTypeFlow* flow,
twisti@2047 36 const char* name) {
twisti@2047 37 SharkFunction function(env, builder, flow, name);
twisti@2047 38 return function.function();
twisti@2047 39 }
twisti@2047 40
twisti@2047 41 private:
twisti@2047 42 SharkFunction(ciEnv* env,
twisti@2047 43 SharkBuilder* builder,
twisti@2047 44 ciTypeFlow* flow,
twisti@2047 45 const char* name)
twisti@2047 46 : SharkTargetInvariants(env, builder, flow) { initialize(name); }
twisti@2047 47
twisti@2047 48 private:
twisti@2047 49 void initialize(const char* name);
twisti@2047 50
twisti@2047 51 private:
twisti@2047 52 llvm::Function* _function;
twisti@2047 53 SharkTopLevelBlock** _blocks;
twisti@2047 54 GrowableArray<DeferredZeroCheck*> _deferred_zero_checks;
twisti@2047 55 SharkStack* _stack;
twisti@2047 56
twisti@2047 57 public:
twisti@2047 58 llvm::Function* function() const {
twisti@2047 59 return _function;
twisti@2047 60 }
twisti@2047 61 int block_count() const {
twisti@2047 62 return flow()->block_count();
twisti@2047 63 }
twisti@2047 64 SharkTopLevelBlock* block(int i) const {
twisti@2047 65 assert(i < block_count(), "should be");
twisti@2047 66 return _blocks[i];
twisti@2047 67 }
twisti@2047 68 GrowableArray<DeferredZeroCheck*>* deferred_zero_checks() {
twisti@2047 69 return &_deferred_zero_checks;
twisti@2047 70 }
twisti@2047 71 SharkStack* stack() const {
twisti@2047 72 return _stack;
twisti@2047 73 }
twisti@2047 74
twisti@2047 75 // On-stack replacement
twisti@2047 76 private:
twisti@2047 77 bool is_osr() const {
twisti@2047 78 return flow()->is_osr_flow();
twisti@2047 79 }
twisti@2047 80 const llvm::FunctionType* entry_point_type() const {
twisti@2047 81 if (is_osr())
twisti@2047 82 return SharkType::osr_entry_point_type();
twisti@2047 83 else
twisti@2047 84 return SharkType::entry_point_type();
twisti@2047 85 }
twisti@2047 86
twisti@2047 87 // Block management
twisti@2047 88 private:
twisti@2047 89 llvm::BasicBlock* _block_insertion_point;
twisti@2047 90
twisti@2047 91 void set_block_insertion_point(llvm::BasicBlock* block_insertion_point) {
twisti@2047 92 _block_insertion_point = block_insertion_point;
twisti@2047 93 }
twisti@2047 94 llvm::BasicBlock* block_insertion_point() const {
twisti@2047 95 return _block_insertion_point;
twisti@2047 96 }
twisti@2047 97
twisti@2047 98 public:
twisti@2047 99 llvm::BasicBlock* CreateBlock(const char* name = "") const {
twisti@2047 100 return llvm::BasicBlock::Create(
twisti@2047 101 SharkContext::current(), name, function(), block_insertion_point());
twisti@2047 102 }
twisti@2047 103
twisti@2047 104 // Deferred zero checks
twisti@2047 105 public:
twisti@2047 106 void add_deferred_zero_check(SharkTopLevelBlock* block,
twisti@2047 107 SharkValue* value);
twisti@2047 108
twisti@2047 109 private:
twisti@2047 110 void do_deferred_zero_checks();
twisti@2047 111 };

mercurial