1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/shark/sharkFunction.hpp Wed Aug 11 05:51:21 2010 -0700 1.3 @@ -0,0 +1,111 @@ 1.4 +/* 1.5 + * Copyright (c) 1999, 2007, 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 +class SharkTopLevelBlock; 1.30 +class DeferredZeroCheck; 1.31 + 1.32 +class SharkFunction : public SharkTargetInvariants { 1.33 + friend class SharkStackWithNormalFrame; 1.34 + 1.35 + public: 1.36 + static llvm::Function* build(ciEnv* env, 1.37 + SharkBuilder* builder, 1.38 + ciTypeFlow* flow, 1.39 + const char* name) { 1.40 + SharkFunction function(env, builder, flow, name); 1.41 + return function.function(); 1.42 + } 1.43 + 1.44 + private: 1.45 + SharkFunction(ciEnv* env, 1.46 + SharkBuilder* builder, 1.47 + ciTypeFlow* flow, 1.48 + const char* name) 1.49 + : SharkTargetInvariants(env, builder, flow) { initialize(name); } 1.50 + 1.51 + private: 1.52 + void initialize(const char* name); 1.53 + 1.54 + private: 1.55 + llvm::Function* _function; 1.56 + SharkTopLevelBlock** _blocks; 1.57 + GrowableArray<DeferredZeroCheck*> _deferred_zero_checks; 1.58 + SharkStack* _stack; 1.59 + 1.60 + public: 1.61 + llvm::Function* function() const { 1.62 + return _function; 1.63 + } 1.64 + int block_count() const { 1.65 + return flow()->block_count(); 1.66 + } 1.67 + SharkTopLevelBlock* block(int i) const { 1.68 + assert(i < block_count(), "should be"); 1.69 + return _blocks[i]; 1.70 + } 1.71 + GrowableArray<DeferredZeroCheck*>* deferred_zero_checks() { 1.72 + return &_deferred_zero_checks; 1.73 + } 1.74 + SharkStack* stack() const { 1.75 + return _stack; 1.76 + } 1.77 + 1.78 + // On-stack replacement 1.79 + private: 1.80 + bool is_osr() const { 1.81 + return flow()->is_osr_flow(); 1.82 + } 1.83 + const llvm::FunctionType* entry_point_type() const { 1.84 + if (is_osr()) 1.85 + return SharkType::osr_entry_point_type(); 1.86 + else 1.87 + return SharkType::entry_point_type(); 1.88 + } 1.89 + 1.90 + // Block management 1.91 + private: 1.92 + llvm::BasicBlock* _block_insertion_point; 1.93 + 1.94 + void set_block_insertion_point(llvm::BasicBlock* block_insertion_point) { 1.95 + _block_insertion_point = block_insertion_point; 1.96 + } 1.97 + llvm::BasicBlock* block_insertion_point() const { 1.98 + return _block_insertion_point; 1.99 + } 1.100 + 1.101 + public: 1.102 + llvm::BasicBlock* CreateBlock(const char* name = "") const { 1.103 + return llvm::BasicBlock::Create( 1.104 + SharkContext::current(), name, function(), block_insertion_point()); 1.105 + } 1.106 + 1.107 + // Deferred zero checks 1.108 + public: 1.109 + void add_deferred_zero_check(SharkTopLevelBlock* block, 1.110 + SharkValue* value); 1.111 + 1.112 + private: 1.113 + void do_deferred_zero_checks(); 1.114 +};