aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/opto/graphKit.cpp
diff options
context:
space:
mode:
authorkvn <none@none>2012-05-14 09:36:00 -0700
committerkvn <none@none>2012-05-14 09:36:00 -0700
commit3ce9df51cfbc6b04c29b613f76e44159da85f1b0 (patch)
tree8b219fba8186a24e048edc2d9f4b035b2bebaa52 /src/share/vm/opto/graphKit.cpp
parenta71026f727535bc66d3ab98e79dadec2f552aa5f (diff)
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
Diffstat (limited to 'src/share/vm/opto/graphKit.cpp')
-rw-r--r--src/share/vm/opto/graphKit.cpp80
1 files changed, 79 insertions, 1 deletions
diff --git a/src/share/vm/opto/graphKit.cpp b/src/share/vm/opto/graphKit.cpp
index 61d922760..b3dca9531 100644
--- a/src/share/vm/opto/graphKit.cpp
+++ b/src/share/vm/opto/graphKit.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -3748,3 +3748,81 @@ void GraphKit::g1_write_barrier_post(Node* oop_store,
final_sync(ideal);
}
#undef __
+
+
+
+Node* GraphKit::load_String_offset(Node* ctrl, Node* str) {
+ if (java_lang_String::has_offset_field()) {
+ int offset_offset = java_lang_String::offset_offset_in_bytes();
+ const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
+ false, NULL, 0);
+ const TypePtr* offset_field_type = string_type->add_offset(offset_offset);
+ int offset_field_idx = C->get_alias_index(offset_field_type);
+ return make_load(ctrl,
+ basic_plus_adr(str, str, offset_offset),
+ TypeInt::INT, T_INT, offset_field_idx);
+ } else {
+ return intcon(0);
+ }
+}
+
+Node* GraphKit::load_String_length(Node* ctrl, Node* str) {
+ if (java_lang_String::has_count_field()) {
+ int count_offset = java_lang_String::count_offset_in_bytes();
+ const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
+ false, NULL, 0);
+ const TypePtr* count_field_type = string_type->add_offset(count_offset);
+ int count_field_idx = C->get_alias_index(count_field_type);
+ return make_load(ctrl,
+ basic_plus_adr(str, str, count_offset),
+ TypeInt::INT, T_INT, count_field_idx);
+ } else {
+ return load_array_length(load_String_value(ctrl, str));
+ }
+}
+
+Node* GraphKit::load_String_value(Node* ctrl, Node* str) {
+ int value_offset = java_lang_String::value_offset_in_bytes();
+ const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
+ false, NULL, 0);
+ const TypePtr* value_field_type = string_type->add_offset(value_offset);
+ const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull,
+ TypeAry::make(TypeInt::CHAR,TypeInt::POS),
+ ciTypeArrayKlass::make(T_CHAR), true, 0);
+ int value_field_idx = C->get_alias_index(value_field_type);
+ return make_load(ctrl, basic_plus_adr(str, str, value_offset),
+ value_type, T_OBJECT, value_field_idx);
+}
+
+void GraphKit::store_String_offset(Node* ctrl, Node* str, Node* value) {
+ int offset_offset = java_lang_String::offset_offset_in_bytes();
+ const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
+ false, NULL, 0);
+ const TypePtr* offset_field_type = string_type->add_offset(offset_offset);
+ int offset_field_idx = C->get_alias_index(offset_field_type);
+ store_to_memory(ctrl, basic_plus_adr(str, offset_offset),
+ value, T_INT, offset_field_idx);
+}
+
+void GraphKit::store_String_value(Node* ctrl, Node* str, Node* value) {
+ int value_offset = java_lang_String::value_offset_in_bytes();
+ const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
+ false, NULL, 0);
+ const TypePtr* value_field_type = string_type->add_offset(value_offset);
+ const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull,
+ TypeAry::make(TypeInt::CHAR,TypeInt::POS),
+ ciTypeArrayKlass::make(T_CHAR), true, 0);
+ int value_field_idx = C->get_alias_index(value_field_type);
+ store_to_memory(ctrl, basic_plus_adr(str, value_offset),
+ value, T_OBJECT, value_field_idx);
+}
+
+void GraphKit::store_String_length(Node* ctrl, Node* str, Node* value) {
+ int count_offset = java_lang_String::count_offset_in_bytes();
+ const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
+ false, NULL, 0);
+ const TypePtr* count_field_type = string_type->add_offset(count_offset);
+ int count_field_idx = C->get_alias_index(count_field_type);
+ store_to_memory(ctrl, basic_plus_adr(str, count_offset),
+ value, T_INT, count_field_idx);
+}