Fri, 27 Feb 2009 13:27:09 -0800
6810672: Comment typos
Summary: I have collected some typos I have found while looking at the code.
Reviewed-by: kvn, never
duke@435 | 1 | /* |
xdono@772 | 2 | * Copyright 1997-2008 Sun Microsystems, Inc. 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 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | #include "incls/_precompiled.incl" |
duke@435 | 26 | #include "incls/_assembler.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | |
duke@435 | 29 | // Implementation of AbstractAssembler |
duke@435 | 30 | // |
duke@435 | 31 | // The AbstractAssembler is generating code into a CodeBuffer. To make code generation faster, |
duke@435 | 32 | // the assembler keeps a copy of the code buffers boundaries & modifies them when |
duke@435 | 33 | // emitting bytes rather than using the code buffers accessor functions all the time. |
twisti@1040 | 34 | // The code buffer is updated via set_code_end(...) after emitting a whole instruction. |
duke@435 | 35 | |
duke@435 | 36 | AbstractAssembler::AbstractAssembler(CodeBuffer* code) { |
duke@435 | 37 | if (code == NULL) return; |
duke@435 | 38 | CodeSection* cs = code->insts(); |
duke@435 | 39 | cs->clear_mark(); // new assembler kills old mark |
duke@435 | 40 | _code_section = cs; |
duke@435 | 41 | _code_begin = cs->start(); |
duke@435 | 42 | _code_limit = cs->limit(); |
duke@435 | 43 | _code_pos = cs->end(); |
duke@435 | 44 | _oop_recorder= code->oop_recorder(); |
duke@435 | 45 | if (_code_begin == NULL) { |
duke@435 | 46 | vm_exit_out_of_memory1(0, "CodeCache: no room for %s", code->name()); |
duke@435 | 47 | } |
duke@435 | 48 | } |
duke@435 | 49 | |
duke@435 | 50 | void AbstractAssembler::set_code_section(CodeSection* cs) { |
duke@435 | 51 | assert(cs->outer() == code_section()->outer(), "sanity"); |
duke@435 | 52 | assert(cs->is_allocated(), "need to pre-allocate this section"); |
duke@435 | 53 | cs->clear_mark(); // new assembly into this section kills old mark |
duke@435 | 54 | _code_section = cs; |
duke@435 | 55 | _code_begin = cs->start(); |
duke@435 | 56 | _code_limit = cs->limit(); |
duke@435 | 57 | _code_pos = cs->end(); |
duke@435 | 58 | } |
duke@435 | 59 | |
duke@435 | 60 | // Inform CodeBuffer that incoming code and relocation will be for stubs |
duke@435 | 61 | address AbstractAssembler::start_a_stub(int required_space) { |
duke@435 | 62 | CodeBuffer* cb = code(); |
duke@435 | 63 | CodeSection* cs = cb->stubs(); |
duke@435 | 64 | assert(_code_section == cb->insts(), "not in insts?"); |
duke@435 | 65 | sync(); |
duke@435 | 66 | if (cs->maybe_expand_to_ensure_remaining(required_space) |
duke@435 | 67 | && cb->blob() == NULL) { |
duke@435 | 68 | return NULL; |
duke@435 | 69 | } |
duke@435 | 70 | set_code_section(cs); |
duke@435 | 71 | return pc(); |
duke@435 | 72 | } |
duke@435 | 73 | |
duke@435 | 74 | // Inform CodeBuffer that incoming code and relocation will be code |
duke@435 | 75 | // Should not be called if start_a_stub() returned NULL |
duke@435 | 76 | void AbstractAssembler::end_a_stub() { |
duke@435 | 77 | assert(_code_section == code()->stubs(), "not in stubs?"); |
duke@435 | 78 | sync(); |
duke@435 | 79 | set_code_section(code()->insts()); |
duke@435 | 80 | } |
duke@435 | 81 | |
duke@435 | 82 | // Inform CodeBuffer that incoming code and relocation will be for stubs |
duke@435 | 83 | address AbstractAssembler::start_a_const(int required_space, int required_align) { |
duke@435 | 84 | CodeBuffer* cb = code(); |
duke@435 | 85 | CodeSection* cs = cb->consts(); |
duke@435 | 86 | assert(_code_section == cb->insts(), "not in insts?"); |
duke@435 | 87 | sync(); |
duke@435 | 88 | address end = cs->end(); |
duke@435 | 89 | int pad = -(intptr_t)end & (required_align-1); |
duke@435 | 90 | if (cs->maybe_expand_to_ensure_remaining(pad + required_space)) { |
duke@435 | 91 | if (cb->blob() == NULL) return NULL; |
duke@435 | 92 | end = cs->end(); // refresh pointer |
duke@435 | 93 | } |
duke@435 | 94 | if (pad > 0) { |
duke@435 | 95 | while (--pad >= 0) { *end++ = 0; } |
duke@435 | 96 | cs->set_end(end); |
duke@435 | 97 | } |
duke@435 | 98 | set_code_section(cs); |
duke@435 | 99 | return end; |
duke@435 | 100 | } |
duke@435 | 101 | |
duke@435 | 102 | // Inform CodeBuffer that incoming code and relocation will be code |
duke@435 | 103 | // Should not be called if start_a_const() returned NULL |
duke@435 | 104 | void AbstractAssembler::end_a_const() { |
duke@435 | 105 | assert(_code_section == code()->consts(), "not in consts?"); |
duke@435 | 106 | sync(); |
duke@435 | 107 | set_code_section(code()->insts()); |
duke@435 | 108 | } |
duke@435 | 109 | |
duke@435 | 110 | |
duke@435 | 111 | void AbstractAssembler::flush() { |
duke@435 | 112 | sync(); |
duke@435 | 113 | ICache::invalidate_range(addr_at(0), offset()); |
duke@435 | 114 | } |
duke@435 | 115 | |
duke@435 | 116 | |
duke@435 | 117 | void AbstractAssembler::a_byte(int x) { |
duke@435 | 118 | emit_byte(x); |
duke@435 | 119 | } |
duke@435 | 120 | |
duke@435 | 121 | |
duke@435 | 122 | void AbstractAssembler::a_long(jint x) { |
duke@435 | 123 | emit_long(x); |
duke@435 | 124 | } |
duke@435 | 125 | |
duke@435 | 126 | // Labels refer to positions in the (to be) generated code. There are bound |
duke@435 | 127 | // and unbound |
duke@435 | 128 | // |
duke@435 | 129 | // Bound labels refer to known positions in the already generated code. |
duke@435 | 130 | // offset() is the position the label refers to. |
duke@435 | 131 | // |
duke@435 | 132 | // Unbound labels refer to unknown positions in the code to be generated; it |
duke@435 | 133 | // may contain a list of unresolved displacements that refer to it |
duke@435 | 134 | #ifndef PRODUCT |
duke@435 | 135 | void AbstractAssembler::print(Label& L) { |
duke@435 | 136 | if (L.is_bound()) { |
duke@435 | 137 | tty->print_cr("bound label to %d|%d", L.loc_pos(), L.loc_sect()); |
duke@435 | 138 | } else if (L.is_unbound()) { |
duke@435 | 139 | L.print_instructions((MacroAssembler*)this); |
duke@435 | 140 | } else { |
duke@435 | 141 | tty->print_cr("label in inconsistent state (loc = %d)", L.loc()); |
duke@435 | 142 | } |
duke@435 | 143 | } |
duke@435 | 144 | #endif // PRODUCT |
duke@435 | 145 | |
duke@435 | 146 | |
duke@435 | 147 | void AbstractAssembler::bind(Label& L) { |
duke@435 | 148 | if (L.is_bound()) { |
duke@435 | 149 | // Assembler can bind a label more than once to the same place. |
duke@435 | 150 | guarantee(L.loc() == locator(), "attempt to redefine label"); |
duke@435 | 151 | return; |
duke@435 | 152 | } |
duke@435 | 153 | L.bind_loc(locator()); |
duke@435 | 154 | L.patch_instructions((MacroAssembler*)this); |
duke@435 | 155 | } |
duke@435 | 156 | |
duke@435 | 157 | void AbstractAssembler::generate_stack_overflow_check( int frame_size_in_bytes) { |
duke@435 | 158 | if (UseStackBanging) { |
duke@435 | 159 | // Each code entry causes one stack bang n pages down the stack where n |
duke@435 | 160 | // is configurable by StackBangPages. The setting depends on the maximum |
duke@435 | 161 | // depth of VM call stack or native before going back into java code, |
duke@435 | 162 | // since only java code can raise a stack overflow exception using the |
duke@435 | 163 | // stack banging mechanism. The VM and native code does not detect stack |
duke@435 | 164 | // overflow. |
duke@435 | 165 | // The code in JavaCalls::call() checks that there is at least n pages |
duke@435 | 166 | // available, so all entry code needs to do is bang once for the end of |
duke@435 | 167 | // this shadow zone. |
duke@435 | 168 | // The entry code may need to bang additional pages if the framesize |
duke@435 | 169 | // is greater than a page. |
duke@435 | 170 | |
duke@435 | 171 | const int page_size = os::vm_page_size(); |
duke@435 | 172 | int bang_end = StackShadowPages*page_size; |
duke@435 | 173 | |
duke@435 | 174 | // This is how far the previous frame's stack banging extended. |
duke@435 | 175 | const int bang_end_safe = bang_end; |
duke@435 | 176 | |
duke@435 | 177 | if (frame_size_in_bytes > page_size) { |
duke@435 | 178 | bang_end += frame_size_in_bytes; |
duke@435 | 179 | } |
duke@435 | 180 | |
duke@435 | 181 | int bang_offset = bang_end_safe; |
duke@435 | 182 | while (bang_offset <= bang_end) { |
duke@435 | 183 | // Need at least one stack bang at end of shadow zone. |
duke@435 | 184 | bang_stack_with_offset(bang_offset); |
duke@435 | 185 | bang_offset += page_size; |
duke@435 | 186 | } |
duke@435 | 187 | } // end (UseStackBanging) |
duke@435 | 188 | } |
duke@435 | 189 | |
duke@435 | 190 | void Label::add_patch_at(CodeBuffer* cb, int branch_loc) { |
duke@435 | 191 | assert(_loc == -1, "Label is unbound"); |
duke@435 | 192 | if (_patch_index < PatchCacheSize) { |
duke@435 | 193 | _patches[_patch_index] = branch_loc; |
duke@435 | 194 | } else { |
duke@435 | 195 | if (_patch_overflow == NULL) { |
duke@435 | 196 | _patch_overflow = cb->create_patch_overflow(); |
duke@435 | 197 | } |
duke@435 | 198 | _patch_overflow->push(branch_loc); |
duke@435 | 199 | } |
duke@435 | 200 | ++_patch_index; |
duke@435 | 201 | } |
duke@435 | 202 | |
duke@435 | 203 | void Label::patch_instructions(MacroAssembler* masm) { |
duke@435 | 204 | assert(is_bound(), "Label is bound"); |
duke@435 | 205 | CodeBuffer* cb = masm->code(); |
duke@435 | 206 | int target_sect = CodeBuffer::locator_sect(loc()); |
duke@435 | 207 | address target = cb->locator_address(loc()); |
duke@435 | 208 | while (_patch_index > 0) { |
duke@435 | 209 | --_patch_index; |
duke@435 | 210 | int branch_loc; |
duke@435 | 211 | if (_patch_index >= PatchCacheSize) { |
duke@435 | 212 | branch_loc = _patch_overflow->pop(); |
duke@435 | 213 | } else { |
duke@435 | 214 | branch_loc = _patches[_patch_index]; |
duke@435 | 215 | } |
duke@435 | 216 | int branch_sect = CodeBuffer::locator_sect(branch_loc); |
duke@435 | 217 | address branch = cb->locator_address(branch_loc); |
duke@435 | 218 | if (branch_sect == CodeBuffer::SECT_CONSTS) { |
duke@435 | 219 | // The thing to patch is a constant word. |
duke@435 | 220 | *(address*)branch = target; |
duke@435 | 221 | continue; |
duke@435 | 222 | } |
duke@435 | 223 | |
duke@435 | 224 | #ifdef ASSERT |
duke@435 | 225 | // Cross-section branches only work if the |
duke@435 | 226 | // intermediate section boundaries are frozen. |
duke@435 | 227 | if (target_sect != branch_sect) { |
duke@435 | 228 | for (int n = MIN2(target_sect, branch_sect), |
duke@435 | 229 | nlimit = (target_sect + branch_sect) - n; |
duke@435 | 230 | n < nlimit; n++) { |
duke@435 | 231 | CodeSection* cs = cb->code_section(n); |
duke@435 | 232 | assert(cs->is_frozen(), "cross-section branch needs stable offsets"); |
duke@435 | 233 | } |
duke@435 | 234 | } |
duke@435 | 235 | #endif //ASSERT |
duke@435 | 236 | |
duke@435 | 237 | // Push the target offset into the branch instruction. |
duke@435 | 238 | masm->pd_patch_instruction(branch, target); |
duke@435 | 239 | } |
duke@435 | 240 | } |
duke@435 | 241 | |
duke@435 | 242 | |
duke@435 | 243 | void AbstractAssembler::block_comment(const char* comment) { |
duke@435 | 244 | if (sect() == CodeBuffer::SECT_INSTS) { |
duke@435 | 245 | code_section()->outer()->block_comment(offset(), comment); |
duke@435 | 246 | } |
duke@435 | 247 | } |
duke@435 | 248 | |
coleenp@672 | 249 | bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { |
coleenp@672 | 250 | // Exception handler checks the nmethod's implicit null checks table |
coleenp@672 | 251 | // only when this method returns false. |
coleenp@672 | 252 | if (UseCompressedOops) { |
coleenp@672 | 253 | // The first page after heap_base is unmapped and |
coleenp@672 | 254 | // the 'offset' is equal to [heap_base + offset] for |
coleenp@672 | 255 | // narrow oop implicit null checks. |
coleenp@672 | 256 | uintptr_t heap_base = (uintptr_t)Universe::heap_base(); |
coleenp@672 | 257 | if ((uintptr_t)offset >= heap_base) { |
coleenp@672 | 258 | // Normalize offset for the next check. |
coleenp@672 | 259 | offset = (intptr_t)(pointer_delta((void*)offset, (void*)heap_base, 1)); |
coleenp@672 | 260 | } |
coleenp@672 | 261 | } |
coleenp@672 | 262 | return offset < 0 || os::vm_page_size() <= offset; |
coleenp@672 | 263 | } |
duke@435 | 264 | |
duke@435 | 265 | #ifndef PRODUCT |
duke@435 | 266 | void Label::print_instructions(MacroAssembler* masm) const { |
duke@435 | 267 | CodeBuffer* cb = masm->code(); |
duke@435 | 268 | for (int i = 0; i < _patch_index; ++i) { |
duke@435 | 269 | int branch_loc; |
duke@435 | 270 | if (i >= PatchCacheSize) { |
duke@435 | 271 | branch_loc = _patch_overflow->at(i - PatchCacheSize); |
duke@435 | 272 | } else { |
duke@435 | 273 | branch_loc = _patches[i]; |
duke@435 | 274 | } |
duke@435 | 275 | int branch_pos = CodeBuffer::locator_pos(branch_loc); |
duke@435 | 276 | int branch_sect = CodeBuffer::locator_sect(branch_loc); |
duke@435 | 277 | address branch = cb->locator_address(branch_loc); |
duke@435 | 278 | tty->print_cr("unbound label"); |
duke@435 | 279 | tty->print("@ %d|%d ", branch_pos, branch_sect); |
duke@435 | 280 | if (branch_sect == CodeBuffer::SECT_CONSTS) { |
duke@435 | 281 | tty->print_cr(PTR_FORMAT, *(address*)branch); |
duke@435 | 282 | continue; |
duke@435 | 283 | } |
duke@435 | 284 | masm->pd_print_patched_instruction(branch); |
duke@435 | 285 | tty->cr(); |
duke@435 | 286 | } |
duke@435 | 287 | } |
duke@435 | 288 | #endif // ndef PRODUCT |