Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/shark/sharkContext.cpp
32285 views
/*1* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.2* Copyright 2009, 2010 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#include "precompiled.hpp"26#include "oops/arrayOop.hpp"27#include "oops/oop.hpp"28#include "shark/llvmHeaders.hpp"29#include "shark/sharkContext.hpp"30#include "utilities/globalDefinitions.hpp"31#include "memory/allocation.hpp"3233using namespace llvm;3435SharkContext::SharkContext(const char* name)36: LLVMContext(),37_free_queue(NULL) {38// Create a module to build our functions into39_module = new Module(name, *this);4041// Create basic types42_void_type = Type::getVoidTy(*this);43_bit_type = Type::getInt1Ty(*this);44_jbyte_type = Type::getInt8Ty(*this);45_jshort_type = Type::getInt16Ty(*this);46_jint_type = Type::getInt32Ty(*this);47_jlong_type = Type::getInt64Ty(*this);48_jfloat_type = Type::getFloatTy(*this);49_jdouble_type = Type::getDoubleTy(*this);5051// Create compound types52_itableOffsetEntry_type = PointerType::getUnqual(53ArrayType::get(jbyte_type(), itableOffsetEntry::size() * wordSize));5455_Metadata_type = PointerType::getUnqual(56ArrayType::get(jbyte_type(), sizeof(Metadata)));5758_klass_type = PointerType::getUnqual(59ArrayType::get(jbyte_type(), sizeof(Klass)));6061_jniEnv_type = PointerType::getUnqual(62ArrayType::get(jbyte_type(), sizeof(JNIEnv)));6364_jniHandleBlock_type = PointerType::getUnqual(65ArrayType::get(jbyte_type(), sizeof(JNIHandleBlock)));6667_Method_type = PointerType::getUnqual(68ArrayType::get(jbyte_type(), sizeof(Method)));6970_monitor_type = ArrayType::get(71jbyte_type(), frame::interpreter_frame_monitor_size() * wordSize);7273_oop_type = PointerType::getUnqual(74ArrayType::get(jbyte_type(), sizeof(oopDesc)));7576_thread_type = PointerType::getUnqual(77ArrayType::get(jbyte_type(), sizeof(JavaThread)));7879_zeroStack_type = PointerType::getUnqual(80ArrayType::get(jbyte_type(), sizeof(ZeroStack)));8182std::vector<Type*> params;83params.push_back(Method_type());84params.push_back(intptr_type());85params.push_back(thread_type());86_entry_point_type = FunctionType::get(jint_type(), params, false);8788params.clear();89params.push_back(Method_type());90params.push_back(PointerType::getUnqual(jbyte_type()));91params.push_back(intptr_type());92params.push_back(thread_type());93_osr_entry_point_type = FunctionType::get(jint_type(), params, false);9495// Create mappings96for (int i = 0; i < T_CONFLICT; i++) {97switch (i) {98case T_BOOLEAN:99_to_stackType[i] = jint_type();100_to_arrayType[i] = jbyte_type();101break;102103case T_BYTE:104_to_stackType[i] = jint_type();105_to_arrayType[i] = jbyte_type();106break;107108case T_CHAR:109_to_stackType[i] = jint_type();110_to_arrayType[i] = jshort_type();111break;112113case T_SHORT:114_to_stackType[i] = jint_type();115_to_arrayType[i] = jshort_type();116break;117118case T_INT:119_to_stackType[i] = jint_type();120_to_arrayType[i] = jint_type();121break;122123case T_LONG:124_to_stackType[i] = jlong_type();125_to_arrayType[i] = jlong_type();126break;127128case T_FLOAT:129_to_stackType[i] = jfloat_type();130_to_arrayType[i] = jfloat_type();131break;132133case T_DOUBLE:134_to_stackType[i] = jdouble_type();135_to_arrayType[i] = jdouble_type();136break;137138case T_OBJECT:139case T_ARRAY:140_to_stackType[i] = oop_type();141_to_arrayType[i] = oop_type();142break;143144case T_ADDRESS:145_to_stackType[i] = intptr_type();146_to_arrayType[i] = NULL;147break;148149default:150_to_stackType[i] = NULL;151_to_arrayType[i] = NULL;152}153}154}155156class SharkFreeQueueItem : public CHeapObj<mtNone> {157public:158SharkFreeQueueItem(llvm::Function* function, SharkFreeQueueItem *next)159: _function(function), _next(next) {}160161private:162llvm::Function* _function;163SharkFreeQueueItem* _next;164165public:166llvm::Function* function() const {167return _function;168}169SharkFreeQueueItem* next() const {170return _next;171}172};173174void SharkContext::push_to_free_queue(Function* function) {175_free_queue = new SharkFreeQueueItem(function, _free_queue);176}177178Function* SharkContext::pop_from_free_queue() {179if (_free_queue == NULL)180return NULL;181182SharkFreeQueueItem *item = _free_queue;183Function *function = item->function();184_free_queue = item->next();185delete item;186return function;187}188189190