Mon, 09 Jun 2008 11:51:19 -0400
6687581: Make CMS work with compressed oops
Summary: Make FreeChunk read markword instead of LSB in _klass pointer to indicate that it's a FreeChunk for compressed oops.
Reviewed-by: ysr, jmasa
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1997-2005 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/_symbolOop.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | bool symbolOopDesc::equals(const char* str, int len) const { |
duke@435 | 29 | int l = utf8_length(); |
duke@435 | 30 | if (l != len) return false; |
duke@435 | 31 | while (l-- > 0) { |
duke@435 | 32 | if (str[l] != (char) byte_at(l)) |
duke@435 | 33 | return false; |
duke@435 | 34 | } |
duke@435 | 35 | assert(l == -1, "we should be at the beginning"); |
duke@435 | 36 | return true; |
duke@435 | 37 | } |
duke@435 | 38 | |
duke@435 | 39 | char* symbolOopDesc::as_C_string(char* buf, int size) const { |
duke@435 | 40 | if (size > 0) { |
duke@435 | 41 | int len = MIN2(size - 1, utf8_length()); |
duke@435 | 42 | for (int i = 0; i < len; i++) { |
duke@435 | 43 | buf[i] = byte_at(i); |
duke@435 | 44 | } |
duke@435 | 45 | buf[len] = '\0'; |
duke@435 | 46 | } |
duke@435 | 47 | return buf; |
duke@435 | 48 | } |
duke@435 | 49 | |
duke@435 | 50 | char* symbolOopDesc::as_C_string() const { |
duke@435 | 51 | int len = utf8_length(); |
duke@435 | 52 | char* str = NEW_RESOURCE_ARRAY(char, len + 1); |
duke@435 | 53 | return as_C_string(str, len + 1); |
duke@435 | 54 | } |
duke@435 | 55 | |
duke@435 | 56 | char* symbolOopDesc::as_C_string_flexible_buffer(Thread* t, |
duke@435 | 57 | char* buf, int size) const { |
duke@435 | 58 | char* str; |
duke@435 | 59 | int len = utf8_length(); |
duke@435 | 60 | int buf_len = len + 1; |
duke@435 | 61 | if (size < buf_len) { |
duke@435 | 62 | str = NEW_RESOURCE_ARRAY(char, buf_len); |
duke@435 | 63 | } else { |
duke@435 | 64 | str = buf; |
duke@435 | 65 | } |
duke@435 | 66 | return as_C_string(str, buf_len); |
duke@435 | 67 | } |
duke@435 | 68 | |
duke@435 | 69 | void symbolOopDesc::print_symbol_on(outputStream* st) { |
duke@435 | 70 | st = st ? st : tty; |
duke@435 | 71 | for (int index = 0; index < utf8_length(); index++) |
duke@435 | 72 | st->put((char)byte_at(index)); |
duke@435 | 73 | } |
duke@435 | 74 | |
duke@435 | 75 | jchar* symbolOopDesc::as_unicode(int& length) const { |
duke@435 | 76 | symbolOopDesc* this_ptr = (symbolOopDesc*)this; |
duke@435 | 77 | length = UTF8::unicode_length((char*)this_ptr->bytes(), utf8_length()); |
duke@435 | 78 | jchar* result = NEW_RESOURCE_ARRAY(jchar, length); |
duke@435 | 79 | if (length > 0) { |
duke@435 | 80 | UTF8::convert_to_unicode((char*)this_ptr->bytes(), result, length); |
duke@435 | 81 | } |
duke@435 | 82 | return result; |
duke@435 | 83 | } |
duke@435 | 84 | |
duke@435 | 85 | const char* symbolOopDesc::as_klass_external_name(char* buf, int size) const { |
duke@435 | 86 | if (size > 0) { |
duke@435 | 87 | char* str = as_C_string(buf, size); |
duke@435 | 88 | int length = (int)strlen(str); |
duke@435 | 89 | // Turn all '/'s into '.'s (also for array klasses) |
duke@435 | 90 | for (int index = 0; index < length; index++) { |
duke@435 | 91 | if (str[index] == '/') { |
duke@435 | 92 | str[index] = '.'; |
duke@435 | 93 | } |
duke@435 | 94 | } |
duke@435 | 95 | return str; |
duke@435 | 96 | } else { |
duke@435 | 97 | return buf; |
duke@435 | 98 | } |
duke@435 | 99 | } |
duke@435 | 100 | |
duke@435 | 101 | const char* symbolOopDesc::as_klass_external_name() const { |
duke@435 | 102 | char* str = as_C_string(); |
duke@435 | 103 | int length = (int)strlen(str); |
duke@435 | 104 | // Turn all '/'s into '.'s (also for array klasses) |
duke@435 | 105 | for (int index = 0; index < length; index++) { |
duke@435 | 106 | if (str[index] == '/') { |
duke@435 | 107 | str[index] = '.'; |
duke@435 | 108 | } |
duke@435 | 109 | } |
duke@435 | 110 | return str; |
duke@435 | 111 | } |