Path: blob/master/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp
40949 views
/*1* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223#ifndef SHARE_JVMCI_JVMCICOMPILERTOVM_HPP24#define SHARE_JVMCI_JVMCICOMPILERTOVM_HPP2526#include "gc/shared/cardTable.hpp"27#include "jvmci/jvmciExceptions.hpp"28#include "runtime/javaCalls.hpp"29#include "runtime/signature.hpp"3031class CollectedHeap;32class JVMCIObjectArray;3334class CompilerToVM {35public:36class Data {37friend class JVMCIVMStructs;3839private:40static int Klass_vtable_start_offset;41static int Klass_vtable_length_offset;4243static int Method_extra_stack_entries;4445static address SharedRuntime_ic_miss_stub;46static address SharedRuntime_handle_wrong_method_stub;47static address SharedRuntime_deopt_blob_unpack;48static address SharedRuntime_deopt_blob_unpack_with_exception_in_tls;49static address SharedRuntime_deopt_blob_uncommon_trap;5051static size_t ThreadLocalAllocBuffer_alignment_reserve;5253static CollectedHeap* Universe_collectedHeap;54static int Universe_base_vtable_size;55static address Universe_narrow_oop_base;56static int Universe_narrow_oop_shift;57static address Universe_narrow_klass_base;58static int Universe_narrow_klass_shift;59static uintptr_t Universe_verify_oop_mask;60static uintptr_t Universe_verify_oop_bits;61static void* Universe_non_oop_bits;6263static bool _supports_inline_contig_alloc;64static HeapWord** _heap_end_addr;65static HeapWord* volatile* _heap_top_addr;66static int _max_oop_map_stack_offset;67static int _fields_annotations_base_offset;6869static CardTable::CardValue* cardtable_start_address;70static int cardtable_shift;7172static int vm_page_size;7374static int sizeof_vtableEntry;75static int sizeof_ExceptionTableElement;76static int sizeof_LocalVariableTableElement;77static int sizeof_ConstantPool;78static int sizeof_narrowKlass;79static int sizeof_arrayOopDesc;80static int sizeof_BasicLock;8182static address dsin;83static address dcos;84static address dtan;85static address dexp;86static address dlog;87static address dlog10;88static address dpow;8990static address symbol_init;91static address symbol_clinit;9293public:94static void initialize(JVMCI_TRAPS);9596static int max_oop_map_stack_offset() {97assert(_max_oop_map_stack_offset > 0, "must be initialized");98return Data::_max_oop_map_stack_offset;99}100};101102static bool cstring_equals(const char* const& s0, const char* const& s1) {103return strcmp(s0, s1) == 0;104}105106static unsigned cstring_hash(const char* const& s) {107int h = 0;108const char* p = s;109while (*p != '\0') {110h = 31 * h + *p;111p++;112}113return h;114}115116static JNINativeMethod methods[];117static JNINativeMethod jni_methods[];118119static JVMCIObjectArray initialize_intrinsics(JVMCI_TRAPS);120public:121static int methods_count();122123};124125126class JavaArgumentUnboxer : public SignatureIterator {127protected:128JavaCallArguments* _jca;129arrayOop _args;130int _index;131132Handle next_arg(BasicType expectedType);133134public:135JavaArgumentUnboxer(Symbol* signature,136JavaCallArguments* jca,137arrayOop args,138bool is_static)139: SignatureIterator(signature)140{141this->_return_type = T_ILLEGAL;142_jca = jca;143_index = 0;144_args = args;145if (!is_static) {146_jca->push_oop(next_arg(T_OBJECT));147}148do_parameters_on(this);149assert(_index == args->length(), "arg count mismatch with signature");150}151152private:153friend class SignatureIterator; // so do_parameters_on can call do_type154void do_type(BasicType type) {155if (is_reference_type(type)) {156_jca->push_oop(next_arg(T_OBJECT));157return;158}159Handle arg = next_arg(type);160int box_offset = java_lang_boxing_object::value_offset(type);161switch (type) {162case T_BOOLEAN: _jca->push_int(arg->bool_field(box_offset)); break;163case T_CHAR: _jca->push_int(arg->char_field(box_offset)); break;164case T_SHORT: _jca->push_int(arg->short_field(box_offset)); break;165case T_BYTE: _jca->push_int(arg->byte_field(box_offset)); break;166case T_INT: _jca->push_int(arg->int_field(box_offset)); break;167case T_LONG: _jca->push_long(arg->long_field(box_offset)); break;168case T_FLOAT: _jca->push_float(arg->float_field(box_offset)); break;169case T_DOUBLE: _jca->push_double(arg->double_field(box_offset)); break;170default: ShouldNotReachHere();171}172}173};174175class JNIHandleMark : public StackObj {176JavaThread* _thread;177public:178JNIHandleMark(JavaThread* thread) : _thread(thread) { push_jni_handle_block(thread); }179~JNIHandleMark() { pop_jni_handle_block(_thread); }180181private:182static void push_jni_handle_block(JavaThread* thread);183static void pop_jni_handle_block(JavaThread* thread);184};185186#endif // SHARE_JVMCI_JVMCICOMPILERTOVM_HPP187188189