1 /* 2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. 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 it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 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 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_CODE_CODE_CACHE_EXTENSIONS_EXT_HPP 26 #define SHARE_VM_CODE_CODE_CACHE_EXTENSIONS_EXT_HPP 27 28 #include "utilities/macros.hpp" 29 #include "memory/allocation.hpp" 30 #include "utilities/globalDefinitions.hpp" 31 #include "interpreter/bytecodes.hpp" 32 33 class AdapterHandlerEntry; 34 class CodeBlob; 35 class CodeBuffer; 36 class InterpreterMacroAssembler; 37 class Template; 38 39 // All the methods defined here are placeholders for possible extensions. 40 41 class CodeCacheExtensions: AllStatic { 42 friend class CodeCacheDumper; 43 44 public: 45 // init both code saving and loading 46 // Must be called very early, before any code is generated. 47 static void initialize() {} 48 49 // Check whether the generated interpreter will be saved. 50 static bool saving_generated_interpreter() { return false; } 51 52 // Check whether a pregenerated interpreter is used. 53 static bool use_pregenerated_interpreter() { return false; } 54 55 // Placeholder for additional VM initialization code 56 static void complete_step(CodeCacheExtensionsSteps::Step phase) {} 57 58 // Return false for newly generated code, on systems where it is not 59 // executable. 60 static bool is_executable(void *pc) { return true; } 61 62 // Return whether dynamically generated code can be executable 63 static bool support_dynamic_code() { return true; } 64 65 // Skip new code generation when known to be useless. 66 static bool skip_code_generation() { return false; } 67 68 // Skip stubs used only for compiled code support. 69 static bool skip_compiler_support() { return false; } 70 71 // Ignore UseFastSignatureHandlers when returning false 72 static bool support_fast_signature_handlers() { return true; } 73 74 ///////////////////////// 75 // Handle generated code: 76 // - allow newly generated code to be shared 77 // - allow pregenerated code to be used in place of the newly generated one 78 // (modifying pc). 79 // - support remapping when doing both save and load 80 // 'remap' can be set to false if the addresses handled are not referenced 81 // from code generated later. 82 83 // Associate a name to a generated codelet and possibly modify the pc 84 // Note: use instead the specialized versions when they exist: 85 // - handle_generated_blob for CodeBlob 86 // - handle_generated_handler for SignatureHandlers 87 // See also the optimized calls below that handle several PCs at once. 88 static void handle_generated_pc(address &pc, const char *name) {} 89 90 // Adds a safe definition of the codelet, for codelets used right after 91 // generation (else we would need to immediately stop the JVM and convert 92 // the generated code to executable format before being able to go further). 93 static void handle_generated_pc(address &pc, const char *name, address default_entry) {} 94 95 // Special cases 96 97 // Special case for CodeBlobs, which may require blob specific actions. 98 static CodeBlob* handle_generated_blob(CodeBlob* blob, const char *name = NULL) { return blob; } 99 100 // Special case for Signature Handlers. 101 static void handle_generated_handler(address &handler_start, const char *name, address handler_end) {} 102 103 // Support for generating different variants of the interpreter 104 // that can be dynamically selected after reload. 105 // 106 // - init_interpreter_assembler allows to configure the assembler for 107 // the current variant 108 // 109 // - needs_other_interpreter_variant returns true as long as other 110 // variants are needed. 111 // 112 // - skip_template_interpreter_entries returns true if new entries 113 // need not be generated for this masm setup and this bytecode 114 // 115 // - completed_template_interpreter_entries is called after new 116 // entries have been generated and installed, for any non skipped 117 // bytecode. 118 static void init_interpreter_assembler(InterpreterMacroAssembler* masm, CodeBuffer* code) {} 119 static bool needs_other_interpreter_variant() { return false; } 120 static bool skip_template_interpreter_entries(Bytecodes::Code code) { return false; } 121 static void completed_template_interpreter_entries(InterpreterMacroAssembler* masm, Bytecodes::Code code) {} 122 123 // Code size optimization. May optimize the requested size. 124 static void size_blob(const char* name, int *updatable_size) {} 125 126 // ergonomics 127 static void set_ergonomics_flags() {} 128 }; 129 130 #endif // SHARE_VM_CODE_CODE_CACHE_EXTENSIONS_EXT_HPP