1.1 --- a/src/share/vm/opto/graphKit.cpp Fri May 11 14:54:35 2012 -0700 1.2 +++ b/src/share/vm/opto/graphKit.cpp Mon May 14 09:36:00 2012 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -3748,3 +3748,81 @@ 1.11 final_sync(ideal); 1.12 } 1.13 #undef __ 1.14 + 1.15 + 1.16 + 1.17 +Node* GraphKit::load_String_offset(Node* ctrl, Node* str) { 1.18 + if (java_lang_String::has_offset_field()) { 1.19 + int offset_offset = java_lang_String::offset_offset_in_bytes(); 1.20 + const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 1.21 + false, NULL, 0); 1.22 + const TypePtr* offset_field_type = string_type->add_offset(offset_offset); 1.23 + int offset_field_idx = C->get_alias_index(offset_field_type); 1.24 + return make_load(ctrl, 1.25 + basic_plus_adr(str, str, offset_offset), 1.26 + TypeInt::INT, T_INT, offset_field_idx); 1.27 + } else { 1.28 + return intcon(0); 1.29 + } 1.30 +} 1.31 + 1.32 +Node* GraphKit::load_String_length(Node* ctrl, Node* str) { 1.33 + if (java_lang_String::has_count_field()) { 1.34 + int count_offset = java_lang_String::count_offset_in_bytes(); 1.35 + const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 1.36 + false, NULL, 0); 1.37 + const TypePtr* count_field_type = string_type->add_offset(count_offset); 1.38 + int count_field_idx = C->get_alias_index(count_field_type); 1.39 + return make_load(ctrl, 1.40 + basic_plus_adr(str, str, count_offset), 1.41 + TypeInt::INT, T_INT, count_field_idx); 1.42 + } else { 1.43 + return load_array_length(load_String_value(ctrl, str)); 1.44 + } 1.45 +} 1.46 + 1.47 +Node* GraphKit::load_String_value(Node* ctrl, Node* str) { 1.48 + int value_offset = java_lang_String::value_offset_in_bytes(); 1.49 + const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 1.50 + false, NULL, 0); 1.51 + const TypePtr* value_field_type = string_type->add_offset(value_offset); 1.52 + const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull, 1.53 + TypeAry::make(TypeInt::CHAR,TypeInt::POS), 1.54 + ciTypeArrayKlass::make(T_CHAR), true, 0); 1.55 + int value_field_idx = C->get_alias_index(value_field_type); 1.56 + return make_load(ctrl, basic_plus_adr(str, str, value_offset), 1.57 + value_type, T_OBJECT, value_field_idx); 1.58 +} 1.59 + 1.60 +void GraphKit::store_String_offset(Node* ctrl, Node* str, Node* value) { 1.61 + int offset_offset = java_lang_String::offset_offset_in_bytes(); 1.62 + const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 1.63 + false, NULL, 0); 1.64 + const TypePtr* offset_field_type = string_type->add_offset(offset_offset); 1.65 + int offset_field_idx = C->get_alias_index(offset_field_type); 1.66 + store_to_memory(ctrl, basic_plus_adr(str, offset_offset), 1.67 + value, T_INT, offset_field_idx); 1.68 +} 1.69 + 1.70 +void GraphKit::store_String_value(Node* ctrl, Node* str, Node* value) { 1.71 + int value_offset = java_lang_String::value_offset_in_bytes(); 1.72 + const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 1.73 + false, NULL, 0); 1.74 + const TypePtr* value_field_type = string_type->add_offset(value_offset); 1.75 + const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull, 1.76 + TypeAry::make(TypeInt::CHAR,TypeInt::POS), 1.77 + ciTypeArrayKlass::make(T_CHAR), true, 0); 1.78 + int value_field_idx = C->get_alias_index(value_field_type); 1.79 + store_to_memory(ctrl, basic_plus_adr(str, value_offset), 1.80 + value, T_OBJECT, value_field_idx); 1.81 +} 1.82 + 1.83 +void GraphKit::store_String_length(Node* ctrl, Node* str, Node* value) { 1.84 + int count_offset = java_lang_String::count_offset_in_bytes(); 1.85 + const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), 1.86 + false, NULL, 0); 1.87 + const TypePtr* count_field_type = string_type->add_offset(count_offset); 1.88 + int count_field_idx = C->get_alias_index(count_field_type); 1.89 + store_to_memory(ctrl, basic_plus_adr(str, count_offset), 1.90 + value, T_INT, count_field_idx); 1.91 +}