Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/shark/sharkFunction.hpp
32285 views
/*1* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.2* Copyright 2008, 2009 Red Hat, Inc.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef SHARE_VM_SHARK_SHARKFUNCTION_HPP26#define SHARE_VM_SHARK_SHARKFUNCTION_HPP2728#include "ci/ciEnv.hpp"29#include "ci/ciStreams.hpp"30#include "ci/ciTypeFlow.hpp"31#include "memory/allocation.hpp"32#include "shark/llvmHeaders.hpp"33#include "shark/llvmValue.hpp"34#include "shark/sharkBuilder.hpp"35#include "shark/sharkContext.hpp"36#include "shark/sharkInvariants.hpp"37#include "shark/sharkStack.hpp"3839class SharkTopLevelBlock;40class DeferredZeroCheck;4142class SharkFunction : public SharkTargetInvariants {43friend class SharkStackWithNormalFrame;4445public:46static llvm::Function* build(ciEnv* env,47SharkBuilder* builder,48ciTypeFlow* flow,49const char* name) {50SharkFunction function(env, builder, flow, name);51return function.function();52}5354private:55SharkFunction(ciEnv* env,56SharkBuilder* builder,57ciTypeFlow* flow,58const char* name)59: SharkTargetInvariants(env, builder, flow) { initialize(name); }6061private:62void initialize(const char* name);6364private:65llvm::Function* _function;66SharkTopLevelBlock** _blocks;67GrowableArray<DeferredZeroCheck*> _deferred_zero_checks;68SharkStack* _stack;6970public:71llvm::Function* function() const {72return _function;73}74int block_count() const {75return flow()->block_count();76}77SharkTopLevelBlock* block(int i) const {78assert(i < block_count(), "should be");79return _blocks[i];80}81GrowableArray<DeferredZeroCheck*>* deferred_zero_checks() {82return &_deferred_zero_checks;83}84SharkStack* stack() const {85return _stack;86}8788// On-stack replacement89private:90bool is_osr() const {91return flow()->is_osr_flow();92}93llvm::FunctionType* entry_point_type() const {94if (is_osr())95return SharkType::osr_entry_point_type();96else97return SharkType::entry_point_type();98}99100// Block management101private:102llvm::BasicBlock* _block_insertion_point;103104void set_block_insertion_point(llvm::BasicBlock* block_insertion_point) {105_block_insertion_point = block_insertion_point;106}107llvm::BasicBlock* block_insertion_point() const {108return _block_insertion_point;109}110111public:112llvm::BasicBlock* CreateBlock(const char* name = "") const {113return llvm::BasicBlock::Create(114SharkContext::current(), name, function(), block_insertion_point());115}116117// Deferred zero checks118public:119void add_deferred_zero_check(SharkTopLevelBlock* block,120SharkValue* value);121122private:123void do_deferred_zero_checks();124};125126#endif // SHARE_VM_SHARK_SHARKFUNCTION_HPP127128129