--- a/hotspot/src/share/vm/classfile/javaClasses.cpp Fri May 11 14:54:35 2012 -0700
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp Mon May 14 09:36:00 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -143,7 +143,27 @@
}
+int java_lang_String::value_offset = 0;
+int java_lang_String::offset_offset = 0;
+int java_lang_String::count_offset = 0;
+int java_lang_String::hash_offset = 0;
+
+bool java_lang_String::initialized = false;
+
+void java_lang_String::compute_offsets() {
+ assert(!initialized, "offsets should be initialized only once");
+
+ klassOop k = SystemDictionary::String_klass();
+ compute_offset(value_offset, k, vmSymbols::value_name(), vmSymbols::char_array_signature());
+ compute_optional_offset(offset_offset, k, vmSymbols::offset_name(), vmSymbols::int_signature());
+ compute_optional_offset(count_offset, k, vmSymbols::count_name(), vmSymbols::int_signature());
+ compute_optional_offset(hash_offset, k, vmSymbols::hash_name(), vmSymbols::int_signature());
+
+ initialized = true;
+}
+
Handle java_lang_String::basic_create(int length, bool tenured, TRAPS) {
+ assert(initialized, "Must be initialized");
// Create the String object first, so there's a chance that the String
// and the char array it points to end up in the same cache line.
oop obj;
@@ -2837,10 +2857,6 @@
-int java_lang_String::value_offset;
-int java_lang_String::offset_offset;
-int java_lang_String::count_offset;
-int java_lang_String::hash_offset;
int java_lang_Class::_klass_offset;
int java_lang_Class::_array_klass_offset;
int java_lang_Class::_resolved_constructor_offset;
@@ -3000,12 +3016,6 @@
const int x = heapOopSize;
const int header = instanceOopDesc::base_offset_in_bytes();
- // Do the String Class
- java_lang_String::value_offset = java_lang_String::hc_value_offset * x + header;
- java_lang_String::offset_offset = java_lang_String::hc_offset_offset * x + header;
- java_lang_String::count_offset = java_lang_String::offset_offset + sizeof (jint);
- java_lang_String::hash_offset = java_lang_String::count_offset + sizeof (jint);
-
// Throwable Class
java_lang_Throwable::backtrace_offset = java_lang_Throwable::hc_backtrace_offset * x + header;
java_lang_Throwable::detailMessage_offset = java_lang_Throwable::hc_detailMessage_offset * x + header;
@@ -3200,9 +3210,13 @@
// java.lang.String
CHECK_OFFSET("java/lang/String", java_lang_String, value, "[C");
- CHECK_OFFSET("java/lang/String", java_lang_String, offset, "I");
- CHECK_OFFSET("java/lang/String", java_lang_String, count, "I");
- CHECK_OFFSET("java/lang/String", java_lang_String, hash, "I");
+ if (java_lang_String::has_offset_field()) {
+ CHECK_OFFSET("java/lang/String", java_lang_String, offset, "I");
+ CHECK_OFFSET("java/lang/String", java_lang_String, count, "I");
+ }
+ if (java_lang_String::has_hash_field()) {
+ CHECK_OFFSET("java/lang/String", java_lang_String, hash, "I");
+ }
// java.lang.Class