0N/A/*
3677N/A * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_OPTO_RUNTIME_HPP
1879N/A#define SHARE_VM_OPTO_RUNTIME_HPP
1879N/A
1879N/A#include "code/codeBlob.hpp"
1879N/A#include "opto/machnode.hpp"
1879N/A#include "opto/type.hpp"
1879N/A#include "runtime/biasedLocking.hpp"
1879N/A#include "runtime/deoptimization.hpp"
1879N/A#include "runtime/vframe.hpp"
1879N/A
0N/A//------------------------------OptoRuntime------------------------------------
0N/A// Opto compiler runtime routines
0N/A//
0N/A// These are all generated from Ideal graphs. They are called with the
0N/A// Java calling convention. Internally they call C++. They are made once at
0N/A// startup time and Opto compiles calls to them later.
0N/A// Things are broken up into quads: the signature they will be called with,
0N/A// the address of the generated code, the corresponding C++ code and an
0N/A// nmethod.
0N/A
0N/A// The signature (returned by "xxx_Type()") is used at startup time by the
0N/A// Generator to make the generated code "xxx_Java". Opto compiles calls
0N/A// to the generated code "xxx_Java". When the compiled code gets executed,
0N/A// it calls the C++ code "xxx_C". The generated nmethod is saved in the
0N/A// CodeCache. Exception handlers use the nmethod to get the callee-save
0N/A// register OopMaps.
0N/Aclass CallInfo;
0N/A
0N/A//
0N/A// NamedCounters are tagged counters which can be used for profiling
0N/A// code in various ways. Currently they are used by the lock coarsening code
0N/A//
0N/A
3863N/Aclass NamedCounter : public CHeapObj<mtCompiler> {
0N/Apublic:
0N/A enum CounterTag {
0N/A NoTag,
0N/A LockCounter,
0N/A EliminatedLockCounter,
0N/A BiasedLockingCounter
0N/A };
0N/A
0N/Aprivate:
0N/A const char * _name;
0N/A int _count;
0N/A CounterTag _tag;
0N/A NamedCounter* _next;
0N/A
0N/A public:
0N/A NamedCounter(const char *n, CounterTag tag = NoTag):
0N/A _name(n),
0N/A _count(0),
0N/A _next(NULL),
0N/A _tag(tag) {}
0N/A
0N/A const char * name() const { return _name; }
0N/A int count() const { return _count; }
0N/A address addr() { return (address)&_count; }
0N/A CounterTag tag() const { return _tag; }
0N/A void set_tag(CounterTag tag) { _tag = tag; }
0N/A
0N/A NamedCounter* next() const { return _next; }
0N/A void set_next(NamedCounter* next) {
0N/A assert(_next == NULL, "already set");
0N/A _next = next;
0N/A }
0N/A
0N/A};
0N/A
0N/Aclass BiasedLockingNamedCounter : public NamedCounter {
0N/A private:
0N/A BiasedLockingCounters _counters;
0N/A
0N/A public:
0N/A BiasedLockingNamedCounter(const char *n) :
0N/A NamedCounter(n, BiasedLockingCounter), _counters() {}
0N/A
0N/A BiasedLockingCounters* counters() { return &_counters; }
0N/A};
0N/A
0N/Atypedef const TypeFunc*(*TypeFunc_generator)();
0N/A
0N/Aclass OptoRuntime : public AllStatic {
0N/A friend class Matcher; // allow access to stub names
0N/A
0N/A private:
0N/A // define stubs
0N/A static address generate_stub(ciEnv* ci_env, TypeFunc_generator gen, address C_function, const char *name, int is_fancy_jump, bool pass_tls, bool save_arguments, bool return_pc);
0N/A
0N/A // References to generated stubs
0N/A static address _new_instance_Java;
0N/A static address _new_array_Java;
2797N/A static address _new_array_nozero_Java;
0N/A static address _multianewarray2_Java;
0N/A static address _multianewarray3_Java;
0N/A static address _multianewarray4_Java;
0N/A static address _multianewarray5_Java;
2630N/A static address _multianewarrayN_Java;
342N/A static address _g1_wb_pre_Java;
342N/A static address _g1_wb_post_Java;
0N/A static address _vtable_must_compile_Java;
0N/A static address _complete_monitor_locking_Java;
0N/A static address _rethrow_Java;
0N/A
0N/A static address _slow_arraycopy_Java;
0N/A static address _register_finalizer_Java;
0N/A
0N/A# ifdef ENABLE_ZAP_DEAD_LOCALS
0N/A static address _zap_dead_Java_locals_Java;
0N/A static address _zap_dead_native_locals_Java;
0N/A# endif
0N/A
0N/A
0N/A //
0N/A // Implementation of runtime methods
0N/A // =================================
0N/A
0N/A // Allocate storage for a Java instance.
0N/A static void new_instance_C(klassOopDesc* instance_klass, JavaThread *thread);
0N/A
0N/A // Allocate storage for a objArray or typeArray
0N/A static void new_array_C(klassOopDesc* array_klass, int len, JavaThread *thread);
2797N/A static void new_array_nozero_C(klassOopDesc* array_klass, int len, JavaThread *thread);
0N/A
1166N/A // Post-slow-path-allocation, pre-initializing-stores step for
1166N/A // implementing ReduceInitialCardMarks
1166N/A static void new_store_pre_barrier(JavaThread* thread);
0N/A
0N/A // Allocate storage for a multi-dimensional arrays
0N/A // Note: needs to be fixed for arbitrary number of dimensions
0N/A static void multianewarray2_C(klassOopDesc* klass, int len1, int len2, JavaThread *thread);
0N/A static void multianewarray3_C(klassOopDesc* klass, int len1, int len2, int len3, JavaThread *thread);
0N/A static void multianewarray4_C(klassOopDesc* klass, int len1, int len2, int len3, int len4, JavaThread *thread);
0N/A static void multianewarray5_C(klassOopDesc* klass, int len1, int len2, int len3, int len4, int len5, JavaThread *thread);
2630N/A static void multianewarrayN_C(klassOopDesc* klass, arrayOopDesc* dims, JavaThread *thread);
342N/A static void g1_wb_pre_C(oopDesc* orig, JavaThread* thread);
342N/A static void g1_wb_post_C(void* card_addr, JavaThread* thread);
0N/A
0N/Apublic:
0N/A // Slow-path Locking and Unlocking
0N/A static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
0N/A static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock);
0N/A
0N/Aprivate:
0N/A
0N/A // Implicit exception support
0N/A static void throw_null_exception_C(JavaThread* thread);
0N/A
0N/A // Exception handling
0N/A static address handle_exception_C (JavaThread* thread);
0N/A static address handle_exception_C_helper(JavaThread* thread, nmethod*& nm);
0N/A static address rethrow_C (oopDesc* exception, JavaThread *thread, address return_pc );
4131N/A static void deoptimize_caller_frame (JavaThread *thread);
0N/A static void deoptimize_caller_frame (JavaThread *thread, bool doit);
2901N/A static bool is_deoptimized_caller_frame (JavaThread *thread);
0N/A
0N/A // CodeBlob support
0N/A // ===================================================================
0N/A
0N/A static ExceptionBlob* _exception_blob;
0N/A static void generate_exception_blob();
0N/A
0N/A static void register_finalizer(oopDesc* obj, JavaThread* thread);
0N/A
0N/A // zaping dead locals, either from Java frames or from native frames
0N/A# ifdef ENABLE_ZAP_DEAD_LOCALS
0N/A static void zap_dead_Java_locals_C( JavaThread* thread);
0N/A static void zap_dead_native_locals_C( JavaThread* thread);
0N/A
0N/A static void zap_dead_java_or_native_locals( JavaThread*, bool (*)(frame*));
0N/A
0N/A public:
0N/A static int ZapDeadCompiledLocals_count;
0N/A
0N/A# endif
0N/A
0N/A
0N/A public:
0N/A
0N/A static bool is_callee_saved_register(MachRegisterNumbers reg);
0N/A
0N/A // One time only generate runtime code stubs
0N/A static void generate(ciEnv* env);
0N/A
0N/A // Returns the name of a stub
0N/A static const char* stub_name(address entry);
0N/A
0N/A // access to runtime stubs entry points for java code
0N/A static address new_instance_Java() { return _new_instance_Java; }
0N/A static address new_array_Java() { return _new_array_Java; }
2797N/A static address new_array_nozero_Java() { return _new_array_nozero_Java; }
0N/A static address multianewarray2_Java() { return _multianewarray2_Java; }
0N/A static address multianewarray3_Java() { return _multianewarray3_Java; }
0N/A static address multianewarray4_Java() { return _multianewarray4_Java; }
0N/A static address multianewarray5_Java() { return _multianewarray5_Java; }
2630N/A static address multianewarrayN_Java() { return _multianewarrayN_Java; }
342N/A static address g1_wb_pre_Java() { return _g1_wb_pre_Java; }
342N/A static address g1_wb_post_Java() { return _g1_wb_post_Java; }
0N/A static address vtable_must_compile_stub() { return _vtable_must_compile_Java; }
0N/A static address complete_monitor_locking_Java() { return _complete_monitor_locking_Java; }
0N/A
0N/A static address slow_arraycopy_Java() { return _slow_arraycopy_Java; }
0N/A static address register_finalizer_Java() { return _register_finalizer_Java; }
0N/A
0N/A
0N/A# ifdef ENABLE_ZAP_DEAD_LOCALS
0N/A static address zap_dead_locals_stub(bool is_native) { return is_native
0N/A ? _zap_dead_native_locals_Java
0N/A : _zap_dead_Java_locals_Java; }
0N/A static MachNode* node_to_call_zap_dead_locals(Node* n, int block_num, bool is_native);
0N/A# endif
0N/A
0N/A static ExceptionBlob* exception_blob() { return _exception_blob; }
0N/A
0N/A // Leaf routines helping with method data update
0N/A static void profile_receiver_type_C(DataLayout* data, oopDesc* receiver);
0N/A
0N/A // Implicit exception support
0N/A static void throw_div0_exception_C (JavaThread* thread);
0N/A static void throw_stack_overflow_error_C(JavaThread* thread);
0N/A
0N/A // Exception handling
0N/A static address rethrow_stub() { return _rethrow_Java; }
0N/A
0N/A
0N/A // Type functions
0N/A // ======================================================
0N/A
0N/A static const TypeFunc* new_instance_Type(); // object allocation (slow case)
0N/A static const TypeFunc* new_array_Type (); // [a]newarray (slow case)
0N/A static const TypeFunc* multianewarray_Type(int ndim); // multianewarray
0N/A static const TypeFunc* multianewarray2_Type(); // multianewarray
0N/A static const TypeFunc* multianewarray3_Type(); // multianewarray
0N/A static const TypeFunc* multianewarray4_Type(); // multianewarray
0N/A static const TypeFunc* multianewarray5_Type(); // multianewarray
2630N/A static const TypeFunc* multianewarrayN_Type(); // multianewarray
342N/A static const TypeFunc* g1_wb_pre_Type();
342N/A static const TypeFunc* g1_wb_post_Type();
0N/A static const TypeFunc* complete_monitor_enter_Type();
0N/A static const TypeFunc* complete_monitor_exit_Type();
0N/A static const TypeFunc* uncommon_trap_Type();
0N/A static const TypeFunc* athrow_Type();
0N/A static const TypeFunc* rethrow_Type();
0N/A static const TypeFunc* Math_D_D_Type(); // sin,cos & friends
0N/A static const TypeFunc* Math_DD_D_Type(); // mod,pow & friends
0N/A static const TypeFunc* modf_Type();
0N/A static const TypeFunc* l2f_Type();
3677N/A static const TypeFunc* void_long_Type();
0N/A
0N/A static const TypeFunc* flush_windows_Type();
0N/A
0N/A // arraycopy routine types
0N/A static const TypeFunc* fast_arraycopy_Type(); // bit-blasters
0N/A static const TypeFunc* checkcast_arraycopy_Type();
0N/A static const TypeFunc* generic_arraycopy_Type();
0N/A static const TypeFunc* slow_arraycopy_Type(); // the full routine
0N/A
1683N/A static const TypeFunc* array_fill_Type();
1683N/A
4056N/A static const TypeFunc* aescrypt_block_Type();
4056N/A static const TypeFunc* cipherBlockChaining_aescrypt_Type();
4056N/A
0N/A // leaf on stack replacement interpreter accessor types
0N/A static const TypeFunc* osr_end_Type();
0N/A
0N/A // leaf methodData routine types
0N/A static const TypeFunc* profile_receiver_type_Type();
0N/A
0N/A // leaf on stack replacement interpreter accessor types
0N/A static const TypeFunc* fetch_int_Type();
0N/A static const TypeFunc* fetch_long_Type();
0N/A static const TypeFunc* fetch_float_Type();
0N/A static const TypeFunc* fetch_double_Type();
0N/A static const TypeFunc* fetch_oop_Type();
0N/A static const TypeFunc* fetch_monitor_Type();
0N/A
0N/A static const TypeFunc* register_finalizer_Type();
0N/A
0N/A // Dtrace support
0N/A static const TypeFunc* dtrace_method_entry_exit_Type();
0N/A static const TypeFunc* dtrace_object_alloc_Type();
0N/A
0N/A# ifdef ENABLE_ZAP_DEAD_LOCALS
0N/A static const TypeFunc* zap_dead_locals_Type();
0N/A# endif
0N/A
0N/A private:
0N/A static NamedCounter * volatile _named_counters;
0N/A
0N/A public:
0N/A // helper function which creates a named counter labeled with the
0N/A // if they are available
0N/A static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
0N/A
0N/A // dumps all the named counters
0N/A static void print_named_counters();
0N/A
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_OPTO_RUNTIME_HPP