Sun, 10 Feb 2013 22:35:38 -0800
8006430: TraceTypeProfile is a product flag while it should be a diagnostic flag
Summary: make sure all diagnostic and experimental flag kinds are checked in Flag::is_unlocked()
Reviewed-by: kvn
duke@435 | 1 | /* |
mikael@4153 | 2 | * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP |
stefank@2314 | 26 | #define SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "asm/assembler.hpp" |
stefank@2314 | 29 | #include "memory/allocation.hpp" |
stefank@2314 | 30 | |
duke@435 | 31 | // All the basic framework for stubcode generation/debugging/printing. |
duke@435 | 32 | |
duke@435 | 33 | |
duke@435 | 34 | // A StubCodeDesc describes a piece of generated code (usually stubs). |
duke@435 | 35 | // This information is mainly useful for debugging and printing. |
duke@435 | 36 | // Currently, code descriptors are simply chained in a linked list, |
duke@435 | 37 | // this may have to change if searching becomes too slow. |
duke@435 | 38 | |
zgu@3900 | 39 | class StubCodeDesc: public CHeapObj<mtCode> { |
duke@435 | 40 | protected: |
duke@435 | 41 | static StubCodeDesc* _list; // the list of all descriptors |
duke@435 | 42 | static int _count; // length of list |
duke@435 | 43 | |
duke@435 | 44 | StubCodeDesc* _next; // the next element in the linked list |
duke@435 | 45 | const char* _group; // the group to which the stub code belongs |
duke@435 | 46 | const char* _name; // the name assigned to the stub code |
duke@435 | 47 | int _index; // serial number assigned to the stub |
duke@435 | 48 | address _begin; // points to the first byte of the stub code (included) |
duke@435 | 49 | address _end; // points to the first byte after the stub code (excluded) |
duke@435 | 50 | |
duke@435 | 51 | void set_end(address end) { |
duke@435 | 52 | assert(_begin <= end, "begin & end not properly ordered"); |
duke@435 | 53 | _end = end; |
duke@435 | 54 | } |
duke@435 | 55 | |
duke@435 | 56 | void set_begin(address begin) { |
duke@435 | 57 | assert(begin >= _begin, "begin may not decrease"); |
duke@435 | 58 | assert(_end == NULL || begin <= _end, "begin & end not properly ordered"); |
duke@435 | 59 | _begin = begin; |
duke@435 | 60 | } |
duke@435 | 61 | |
duke@435 | 62 | friend class StubCodeMark; |
duke@435 | 63 | friend class StubCodeGenerator; |
duke@435 | 64 | |
duke@435 | 65 | public: |
duke@435 | 66 | static StubCodeDesc* desc_for(address pc); // returns the code descriptor for the code containing pc or NULL |
duke@435 | 67 | static StubCodeDesc* desc_for_index(int); // returns the code descriptor for the index or NULL |
duke@435 | 68 | static const char* name_for(address pc); // returns the name of the code containing pc or NULL |
duke@435 | 69 | |
duke@435 | 70 | StubCodeDesc(const char* group, const char* name, address begin) { |
duke@435 | 71 | assert(name != NULL, "no name specified"); |
duke@435 | 72 | _next = _list; |
duke@435 | 73 | _group = group; |
duke@435 | 74 | _name = name; |
duke@435 | 75 | _index = ++_count; // (never zero) |
duke@435 | 76 | _begin = begin; |
duke@435 | 77 | _end = NULL; |
duke@435 | 78 | _list = this; |
duke@435 | 79 | }; |
duke@435 | 80 | |
duke@435 | 81 | const char* group() const { return _group; } |
duke@435 | 82 | const char* name() const { return _name; } |
duke@435 | 83 | int index() const { return _index; } |
duke@435 | 84 | address begin() const { return _begin; } |
duke@435 | 85 | address end() const { return _end; } |
duke@435 | 86 | int size_in_bytes() const { return _end - _begin; } |
duke@435 | 87 | bool contains(address pc) const { return _begin <= pc && pc < _end; } |
bobv@2036 | 88 | void print_on(outputStream* st) const; |
bobv@2036 | 89 | void print() const { print_on(tty); } |
duke@435 | 90 | }; |
duke@435 | 91 | |
duke@435 | 92 | // The base class for all stub-generating code generators. |
duke@435 | 93 | // Provides utility functions. |
duke@435 | 94 | |
duke@435 | 95 | class StubCodeGenerator: public StackObj { |
duke@435 | 96 | protected: |
duke@435 | 97 | MacroAssembler* _masm; |
duke@435 | 98 | |
duke@435 | 99 | StubCodeDesc* _first_stub; |
duke@435 | 100 | StubCodeDesc* _last_stub; |
never@2954 | 101 | bool _print_code; |
duke@435 | 102 | |
duke@435 | 103 | public: |
never@2954 | 104 | StubCodeGenerator(CodeBuffer* code, bool print_code = false); |
duke@435 | 105 | ~StubCodeGenerator(); |
duke@435 | 106 | |
duke@435 | 107 | MacroAssembler* assembler() const { return _masm; } |
duke@435 | 108 | |
duke@435 | 109 | virtual void stub_prolog(StubCodeDesc* cdesc); // called by StubCodeMark constructor |
duke@435 | 110 | virtual void stub_epilog(StubCodeDesc* cdesc); // called by StubCodeMark destructor |
duke@435 | 111 | }; |
duke@435 | 112 | |
duke@435 | 113 | |
duke@435 | 114 | // Stack-allocated helper class used to assciate a stub code with a name. |
duke@435 | 115 | // All stub code generating functions that use a StubCodeMark will be registered |
duke@435 | 116 | // in the global StubCodeDesc list and the generated stub code can be identified |
duke@435 | 117 | // later via an address pointing into it. |
duke@435 | 118 | |
duke@435 | 119 | class StubCodeMark: public StackObj { |
duke@435 | 120 | protected: |
duke@435 | 121 | StubCodeGenerator* _cgen; |
duke@435 | 122 | StubCodeDesc* _cdesc; |
duke@435 | 123 | |
duke@435 | 124 | public: |
duke@435 | 125 | StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name); |
duke@435 | 126 | ~StubCodeMark(); |
duke@435 | 127 | |
duke@435 | 128 | }; |
stefank@2314 | 129 | |
stefank@2314 | 130 | #endif // SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP |