Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/graphKit.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 | b9bc6cae88f2 |
children | 1d7922586cf6 |
comparison
equal
deleted
inserted
replaced
6054:56d1af561395 | 6057:8f972594effc |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 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. |
3746 | 3746 |
3747 // Final sync IdealKit and GraphKit. | 3747 // Final sync IdealKit and GraphKit. |
3748 final_sync(ideal); | 3748 final_sync(ideal); |
3749 } | 3749 } |
3750 #undef __ | 3750 #undef __ |
3751 | |
3752 | |
3753 | |
3754 Node* GraphKit::load_String_offset(Node* ctrl, Node* str) { | |
3755 if (java_lang_String::has_offset_field()) { | |
3756 int offset_offset = java_lang_String::offset_offset_in_bytes(); | |
3757 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), | |
3758 false, NULL, 0); | |
3759 const TypePtr* offset_field_type = string_type->add_offset(offset_offset); | |
3760 int offset_field_idx = C->get_alias_index(offset_field_type); | |
3761 return make_load(ctrl, | |
3762 basic_plus_adr(str, str, offset_offset), | |
3763 TypeInt::INT, T_INT, offset_field_idx); | |
3764 } else { | |
3765 return intcon(0); | |
3766 } | |
3767 } | |
3768 | |
3769 Node* GraphKit::load_String_length(Node* ctrl, Node* str) { | |
3770 if (java_lang_String::has_count_field()) { | |
3771 int count_offset = java_lang_String::count_offset_in_bytes(); | |
3772 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), | |
3773 false, NULL, 0); | |
3774 const TypePtr* count_field_type = string_type->add_offset(count_offset); | |
3775 int count_field_idx = C->get_alias_index(count_field_type); | |
3776 return make_load(ctrl, | |
3777 basic_plus_adr(str, str, count_offset), | |
3778 TypeInt::INT, T_INT, count_field_idx); | |
3779 } else { | |
3780 return load_array_length(load_String_value(ctrl, str)); | |
3781 } | |
3782 } | |
3783 | |
3784 Node* GraphKit::load_String_value(Node* ctrl, Node* str) { | |
3785 int value_offset = java_lang_String::value_offset_in_bytes(); | |
3786 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), | |
3787 false, NULL, 0); | |
3788 const TypePtr* value_field_type = string_type->add_offset(value_offset); | |
3789 const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull, | |
3790 TypeAry::make(TypeInt::CHAR,TypeInt::POS), | |
3791 ciTypeArrayKlass::make(T_CHAR), true, 0); | |
3792 int value_field_idx = C->get_alias_index(value_field_type); | |
3793 return make_load(ctrl, basic_plus_adr(str, str, value_offset), | |
3794 value_type, T_OBJECT, value_field_idx); | |
3795 } | |
3796 | |
3797 void GraphKit::store_String_offset(Node* ctrl, Node* str, Node* value) { | |
3798 int offset_offset = java_lang_String::offset_offset_in_bytes(); | |
3799 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), | |
3800 false, NULL, 0); | |
3801 const TypePtr* offset_field_type = string_type->add_offset(offset_offset); | |
3802 int offset_field_idx = C->get_alias_index(offset_field_type); | |
3803 store_to_memory(ctrl, basic_plus_adr(str, offset_offset), | |
3804 value, T_INT, offset_field_idx); | |
3805 } | |
3806 | |
3807 void GraphKit::store_String_value(Node* ctrl, Node* str, Node* value) { | |
3808 int value_offset = java_lang_String::value_offset_in_bytes(); | |
3809 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), | |
3810 false, NULL, 0); | |
3811 const TypePtr* value_field_type = string_type->add_offset(value_offset); | |
3812 const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull, | |
3813 TypeAry::make(TypeInt::CHAR,TypeInt::POS), | |
3814 ciTypeArrayKlass::make(T_CHAR), true, 0); | |
3815 int value_field_idx = C->get_alias_index(value_field_type); | |
3816 store_to_memory(ctrl, basic_plus_adr(str, value_offset), | |
3817 value, T_OBJECT, value_field_idx); | |
3818 } | |
3819 | |
3820 void GraphKit::store_String_length(Node* ctrl, Node* str, Node* value) { | |
3821 int count_offset = java_lang_String::count_offset_in_bytes(); | |
3822 const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), | |
3823 false, NULL, 0); | |
3824 const TypePtr* count_field_type = string_type->add_offset(count_offset); | |
3825 int count_field_idx = C->get_alias_index(count_field_type); | |
3826 store_to_memory(ctrl, basic_plus_adr(str, count_offset), | |
3827 value, T_INT, count_field_idx); | |
3828 } |