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