1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/shark/sharkFunction.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,127 @@ 1.4 +/* 1.5 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright 2008, 2009 Red Hat, Inc. 1.7 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 + * 1.9 + * This code is free software; you can redistribute it and/or modify it 1.10 + * under the terms of the GNU General Public License version 2 only, as 1.11 + * published by the Free Software Foundation. 1.12 + * 1.13 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.15 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.16 + * version 2 for more details (a copy is included in the LICENSE file that 1.17 + * accompanied this code). 1.18 + * 1.19 + * You should have received a copy of the GNU General Public License version 1.20 + * 2 along with this work; if not, write to the Free Software Foundation, 1.21 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.22 + * 1.23 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.24 + * or visit www.oracle.com if you need additional information or have any 1.25 + * questions. 1.26 + * 1.27 + */ 1.28 + 1.29 +#ifndef SHARE_VM_SHARK_SHARKFUNCTION_HPP 1.30 +#define SHARE_VM_SHARK_SHARKFUNCTION_HPP 1.31 + 1.32 +#include "ci/ciEnv.hpp" 1.33 +#include "ci/ciStreams.hpp" 1.34 +#include "ci/ciTypeFlow.hpp" 1.35 +#include "memory/allocation.hpp" 1.36 +#include "shark/llvmHeaders.hpp" 1.37 +#include "shark/llvmValue.hpp" 1.38 +#include "shark/sharkBuilder.hpp" 1.39 +#include "shark/sharkContext.hpp" 1.40 +#include "shark/sharkInvariants.hpp" 1.41 +#include "shark/sharkStack.hpp" 1.42 + 1.43 +class SharkTopLevelBlock; 1.44 +class DeferredZeroCheck; 1.45 + 1.46 +class SharkFunction : public SharkTargetInvariants { 1.47 + friend class SharkStackWithNormalFrame; 1.48 + 1.49 + public: 1.50 + static llvm::Function* build(ciEnv* env, 1.51 + SharkBuilder* builder, 1.52 + ciTypeFlow* flow, 1.53 + const char* name) { 1.54 + SharkFunction function(env, builder, flow, name); 1.55 + return function.function(); 1.56 + } 1.57 + 1.58 + private: 1.59 + SharkFunction(ciEnv* env, 1.60 + SharkBuilder* builder, 1.61 + ciTypeFlow* flow, 1.62 + const char* name) 1.63 + : SharkTargetInvariants(env, builder, flow) { initialize(name); } 1.64 + 1.65 + private: 1.66 + void initialize(const char* name); 1.67 + 1.68 + private: 1.69 + llvm::Function* _function; 1.70 + SharkTopLevelBlock** _blocks; 1.71 + GrowableArray<DeferredZeroCheck*> _deferred_zero_checks; 1.72 + SharkStack* _stack; 1.73 + 1.74 + public: 1.75 + llvm::Function* function() const { 1.76 + return _function; 1.77 + } 1.78 + int block_count() const { 1.79 + return flow()->block_count(); 1.80 + } 1.81 + SharkTopLevelBlock* block(int i) const { 1.82 + assert(i < block_count(), "should be"); 1.83 + return _blocks[i]; 1.84 + } 1.85 + GrowableArray<DeferredZeroCheck*>* deferred_zero_checks() { 1.86 + return &_deferred_zero_checks; 1.87 + } 1.88 + SharkStack* stack() const { 1.89 + return _stack; 1.90 + } 1.91 + 1.92 + // On-stack replacement 1.93 + private: 1.94 + bool is_osr() const { 1.95 + return flow()->is_osr_flow(); 1.96 + } 1.97 + llvm::FunctionType* entry_point_type() const { 1.98 + if (is_osr()) 1.99 + return SharkType::osr_entry_point_type(); 1.100 + else 1.101 + return SharkType::entry_point_type(); 1.102 + } 1.103 + 1.104 + // Block management 1.105 + private: 1.106 + llvm::BasicBlock* _block_insertion_point; 1.107 + 1.108 + void set_block_insertion_point(llvm::BasicBlock* block_insertion_point) { 1.109 + _block_insertion_point = block_insertion_point; 1.110 + } 1.111 + llvm::BasicBlock* block_insertion_point() const { 1.112 + return _block_insertion_point; 1.113 + } 1.114 + 1.115 + public: 1.116 + llvm::BasicBlock* CreateBlock(const char* name = "") const { 1.117 + return llvm::BasicBlock::Create( 1.118 + SharkContext::current(), name, function(), block_insertion_point()); 1.119 + } 1.120 + 1.121 + // Deferred zero checks 1.122 + public: 1.123 + void add_deferred_zero_check(SharkTopLevelBlock* block, 1.124 + SharkValue* value); 1.125 + 1.126 + private: 1.127 + void do_deferred_zero_checks(); 1.128 +}; 1.129 + 1.130 +#endif // SHARE_VM_SHARK_SHARKFUNCTION_HPP