src/share/vm/code/icBuffer.hpp

Thu, 24 May 2018 18:41:44 +0800

author
aoqi
date
Thu, 24 May 2018 18:41:44 +0800
changeset 8856
ac27a9c85bea
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_CODE_ICBUFFER_HPP
aoqi@0 26 #define SHARE_VM_CODE_ICBUFFER_HPP
aoqi@0 27
aoqi@0 28 #include "asm/codeBuffer.hpp"
aoqi@0 29 #include "code/stubs.hpp"
aoqi@0 30 #include "interpreter/bytecodes.hpp"
aoqi@0 31 #include "memory/allocation.hpp"
aoqi@0 32
aoqi@0 33 //
aoqi@0 34 // For CompiledIC's:
aoqi@0 35 //
aoqi@0 36 // In cases where we do not have MT-safe state transformation,
aoqi@0 37 // we go to a transition state, using ICStubs. At a safepoint,
aoqi@0 38 // the inline caches are transferred from the transitional code:
aoqi@0 39 //
aoqi@0 40 // instruction_address --> 01 set xxx_oop, Ginline_cache_klass
aoqi@0 41 // 23 jump_to Gtemp, yyyy
aoqi@0 42 // 4 nop
aoqi@0 43
aoqi@0 44 class ICStub: public Stub {
aoqi@0 45 private:
aoqi@0 46 int _size; // total size of the stub incl. code
aoqi@0 47 address _ic_site; // points at call instruction of owning ic-buffer
aoqi@0 48 /* stub code follows here */
aoqi@0 49 protected:
aoqi@0 50 friend class ICStubInterface;
aoqi@0 51 // This will be called only by ICStubInterface
aoqi@0 52 void initialize(int size,
aoqi@0 53 CodeStrings strings) { _size = size; _ic_site = NULL; }
aoqi@0 54 void finalize(); // called when a method is removed
aoqi@0 55
aoqi@0 56 // General info
aoqi@0 57 int size() const { return _size; }
aoqi@0 58 static int code_size_to_size(int code_size) { return round_to(sizeof(ICStub), CodeEntryAlignment) + code_size; }
aoqi@0 59
aoqi@0 60 public:
aoqi@0 61 // Creation
aoqi@0 62 void set_stub(CompiledIC *ic, void* cached_value, address dest_addr);
aoqi@0 63
aoqi@0 64 // Code info
aoqi@0 65 address code_begin() const { return (address)this + round_to(sizeof(ICStub), CodeEntryAlignment); }
aoqi@0 66 address code_end() const { return (address)this + size(); }
aoqi@0 67
aoqi@0 68 // Call site info
aoqi@0 69 address ic_site() const { return _ic_site; }
aoqi@0 70 void clear();
aoqi@0 71 bool is_empty() const { return _ic_site == NULL; }
aoqi@0 72
aoqi@0 73 // stub info
aoqi@0 74 address destination() const; // destination of jump instruction
aoqi@0 75 void* cached_value() const; // cached_value for stub
aoqi@0 76
aoqi@0 77 // Debugging
aoqi@0 78 void verify() PRODUCT_RETURN;
aoqi@0 79 void print() PRODUCT_RETURN;
aoqi@0 80
aoqi@0 81 // Creation
aoqi@0 82 friend ICStub* ICStub_from_destination_address(address destination_address);
aoqi@0 83 };
aoqi@0 84
aoqi@0 85 // ICStub Creation
aoqi@0 86 inline ICStub* ICStub_from_destination_address(address destination_address) {
aoqi@0 87 ICStub* stub = (ICStub*) (destination_address - round_to(sizeof(ICStub), CodeEntryAlignment));
aoqi@0 88 #ifdef ASSERT
aoqi@0 89 stub->verify();
aoqi@0 90 #endif
aoqi@0 91 return stub;
aoqi@0 92 }
aoqi@0 93
aoqi@0 94 class InlineCacheBuffer: public AllStatic {
aoqi@0 95 private:
aoqi@0 96 // friends
aoqi@0 97 friend class ICStub;
aoqi@0 98
aoqi@0 99 static int ic_stub_code_size();
aoqi@0 100
aoqi@0 101 static StubQueue* _buffer;
aoqi@0 102 static ICStub* _next_stub;
aoqi@0 103
aoqi@0 104 static CompiledICHolder* _pending_released;
aoqi@0 105 static int _pending_count;
aoqi@0 106
aoqi@0 107 static StubQueue* buffer() { return _buffer; }
aoqi@0 108 static void set_next_stub(ICStub* next_stub) { _next_stub = next_stub; }
aoqi@0 109 static ICStub* get_next_stub() { return _next_stub; }
aoqi@0 110
aoqi@0 111 static void init_next_stub();
aoqi@0 112
aoqi@0 113 static ICStub* new_ic_stub();
aoqi@0 114
aoqi@0 115
aoqi@0 116 // Machine-dependent implementation of ICBuffer
aoqi@0 117 static void assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point);
aoqi@0 118 static address ic_buffer_entry_point (address code_begin);
aoqi@0 119 static void* ic_buffer_cached_value (address code_begin);
aoqi@0 120
aoqi@0 121 public:
aoqi@0 122
aoqi@0 123 // Initialization; must be called before first usage
aoqi@0 124 static void initialize();
aoqi@0 125
aoqi@0 126 // Access
aoqi@0 127 static bool contains(address instruction_address);
aoqi@0 128
aoqi@0 129 // removes the ICStubs after backpatching
aoqi@0 130 static void update_inline_caches();
aoqi@0 131
aoqi@0 132 // for debugging
aoqi@0 133 static bool is_empty();
aoqi@0 134
aoqi@0 135 static void release_pending_icholders();
aoqi@0 136 static void queue_for_release(CompiledICHolder* icholder);
aoqi@0 137 static int pending_icholder_count() { return _pending_count; }
aoqi@0 138
aoqi@0 139 // New interface
aoqi@0 140 static void create_transition_stub(CompiledIC *ic, void* cached_value, address entry);
aoqi@0 141 static address ic_destination_for(CompiledIC *ic);
aoqi@0 142 static void* cached_value_for(CompiledIC *ic);
aoqi@0 143 };
aoqi@0 144
aoqi@0 145 #endif // SHARE_VM_CODE_ICBUFFER_HPP

mercurial