Mercurial > hg > graal-compiler
comparison src/share/vm/classfile/javaClasses.cpp @ 6057:8f972594effc
6924259: Remove String.count/String.offset
Summary: Allow a version of String class that doesn't have count and offset fields.
Reviewed-by: never, coleenp
author | kvn |
---|---|
date | Mon, 14 May 2012 09:36:00 -0700 |
parents | a81f60ddab06 |
children | 8b0a4867acf0 e9140bf80b4a |
comparison
equal
deleted
inserted
replaced
6054:56d1af561395 | 6057:8f972594effc |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
141 dest_offset = fd.offset(); | 141 dest_offset = fd.offset(); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 | 145 |
146 int java_lang_String::value_offset = 0; | |
147 int java_lang_String::offset_offset = 0; | |
148 int java_lang_String::count_offset = 0; | |
149 int java_lang_String::hash_offset = 0; | |
150 | |
151 bool java_lang_String::initialized = false; | |
152 | |
153 void java_lang_String::compute_offsets() { | |
154 assert(!initialized, "offsets should be initialized only once"); | |
155 | |
156 klassOop k = SystemDictionary::String_klass(); | |
157 compute_offset(value_offset, k, vmSymbols::value_name(), vmSymbols::char_array_signature()); | |
158 compute_optional_offset(offset_offset, k, vmSymbols::offset_name(), vmSymbols::int_signature()); | |
159 compute_optional_offset(count_offset, k, vmSymbols::count_name(), vmSymbols::int_signature()); | |
160 compute_optional_offset(hash_offset, k, vmSymbols::hash_name(), vmSymbols::int_signature()); | |
161 | |
162 initialized = true; | |
163 } | |
164 | |
146 Handle java_lang_String::basic_create(int length, bool tenured, TRAPS) { | 165 Handle java_lang_String::basic_create(int length, bool tenured, TRAPS) { |
166 assert(initialized, "Must be initialized"); | |
147 // Create the String object first, so there's a chance that the String | 167 // Create the String object first, so there's a chance that the String |
148 // and the char array it points to end up in the same cache line. | 168 // and the char array it points to end up in the same cache line. |
149 oop obj; | 169 oop obj; |
150 if (tenured) { | 170 if (tenured) { |
151 obj = instanceKlass::cast(SystemDictionary::String_klass())->allocate_permanent_instance(CHECK_NH); | 171 obj = instanceKlass::cast(SystemDictionary::String_klass())->allocate_permanent_instance(CHECK_NH); |
2835 return (instanceMirrorKlass::offset_of_static_fields() + static_err_offset); | 2855 return (instanceMirrorKlass::offset_of_static_fields() + static_err_offset); |
2836 } | 2856 } |
2837 | 2857 |
2838 | 2858 |
2839 | 2859 |
2840 int java_lang_String::value_offset; | |
2841 int java_lang_String::offset_offset; | |
2842 int java_lang_String::count_offset; | |
2843 int java_lang_String::hash_offset; | |
2844 int java_lang_Class::_klass_offset; | 2860 int java_lang_Class::_klass_offset; |
2845 int java_lang_Class::_array_klass_offset; | 2861 int java_lang_Class::_array_klass_offset; |
2846 int java_lang_Class::_resolved_constructor_offset; | 2862 int java_lang_Class::_resolved_constructor_offset; |
2847 int java_lang_Class::_oop_size_offset; | 2863 int java_lang_Class::_oop_size_offset; |
2848 int java_lang_Class::_static_oop_field_count_offset; | 2864 int java_lang_Class::_static_oop_field_count_offset; |
2998 // are not available to determine the offset_of_static_fields. | 3014 // are not available to determine the offset_of_static_fields. |
2999 void JavaClasses::compute_hard_coded_offsets() { | 3015 void JavaClasses::compute_hard_coded_offsets() { |
3000 const int x = heapOopSize; | 3016 const int x = heapOopSize; |
3001 const int header = instanceOopDesc::base_offset_in_bytes(); | 3017 const int header = instanceOopDesc::base_offset_in_bytes(); |
3002 | 3018 |
3003 // Do the String Class | |
3004 java_lang_String::value_offset = java_lang_String::hc_value_offset * x + header; | |
3005 java_lang_String::offset_offset = java_lang_String::hc_offset_offset * x + header; | |
3006 java_lang_String::count_offset = java_lang_String::offset_offset + sizeof (jint); | |
3007 java_lang_String::hash_offset = java_lang_String::count_offset + sizeof (jint); | |
3008 | |
3009 // Throwable Class | 3019 // Throwable Class |
3010 java_lang_Throwable::backtrace_offset = java_lang_Throwable::hc_backtrace_offset * x + header; | 3020 java_lang_Throwable::backtrace_offset = java_lang_Throwable::hc_backtrace_offset * x + header; |
3011 java_lang_Throwable::detailMessage_offset = java_lang_Throwable::hc_detailMessage_offset * x + header; | 3021 java_lang_Throwable::detailMessage_offset = java_lang_Throwable::hc_detailMessage_offset * x + header; |
3012 java_lang_Throwable::cause_offset = java_lang_Throwable::hc_cause_offset * x + header; | 3022 java_lang_Throwable::cause_offset = java_lang_Throwable::hc_cause_offset * x + header; |
3013 java_lang_Throwable::stackTrace_offset = java_lang_Throwable::hc_stackTrace_offset * x + header; | 3023 java_lang_Throwable::stackTrace_offset = java_lang_Throwable::hc_stackTrace_offset * x + header; |
3198 valid &= check_constant(klass_name, cpp_klass_name :: field_name, #field_name, field_sig) | 3208 valid &= check_constant(klass_name, cpp_klass_name :: field_name, #field_name, field_sig) |
3199 | 3209 |
3200 // java.lang.String | 3210 // java.lang.String |
3201 | 3211 |
3202 CHECK_OFFSET("java/lang/String", java_lang_String, value, "[C"); | 3212 CHECK_OFFSET("java/lang/String", java_lang_String, value, "[C"); |
3203 CHECK_OFFSET("java/lang/String", java_lang_String, offset, "I"); | 3213 if (java_lang_String::has_offset_field()) { |
3204 CHECK_OFFSET("java/lang/String", java_lang_String, count, "I"); | 3214 CHECK_OFFSET("java/lang/String", java_lang_String, offset, "I"); |
3205 CHECK_OFFSET("java/lang/String", java_lang_String, hash, "I"); | 3215 CHECK_OFFSET("java/lang/String", java_lang_String, count, "I"); |
3216 } | |
3217 if (java_lang_String::has_hash_field()) { | |
3218 CHECK_OFFSET("java/lang/String", java_lang_String, hash, "I"); | |
3219 } | |
3206 | 3220 |
3207 // java.lang.Class | 3221 // java.lang.Class |
3208 | 3222 |
3209 // Fake fields | 3223 // Fake fields |
3210 // CHECK_OFFSET("java/lang/Class", java_lang_Class, klass); // %%% this needs to be checked | 3224 // CHECK_OFFSET("java/lang/Class", java_lang_Class, klass); // %%% this needs to be checked |