1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2014, 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. |
59 |
59 |
60 static bool initialized; |
60 static bool initialized; |
61 |
61 |
62 static Handle basic_create(int length, TRAPS); |
62 static Handle basic_create(int length, TRAPS); |
63 |
63 |
64 static void set_value( oop string, typeArrayOop buffer) { |
|
65 assert(initialized, "Must be initialized"); |
|
66 string->obj_field_put(value_offset, (oop)buffer); |
|
67 } |
|
68 static void set_offset(oop string, int offset) { |
64 static void set_offset(oop string, int offset) { |
69 assert(initialized, "Must be initialized"); |
65 assert(initialized, "Must be initialized"); |
70 if (offset_offset > 0) { |
66 if (offset_offset > 0) { |
71 string->int_field_put(offset_offset, offset); |
67 string->int_field_put(offset_offset, offset); |
72 } |
68 } |
120 static int hash_offset_in_bytes() { |
116 static int hash_offset_in_bytes() { |
121 assert(initialized && (hash_offset > 0), "Must be initialized"); |
117 assert(initialized && (hash_offset > 0), "Must be initialized"); |
122 return hash_offset; |
118 return hash_offset; |
123 } |
119 } |
124 |
120 |
|
121 static void set_value(oop string, typeArrayOop buffer) { |
|
122 assert(initialized && (value_offset > 0), "Must be initialized"); |
|
123 string->obj_field_put(value_offset, (oop)buffer); |
|
124 } |
|
125 static void set_hash(oop string, unsigned int hash) { |
|
126 assert(initialized && (hash_offset > 0), "Must be initialized"); |
|
127 string->int_field_put(hash_offset, hash); |
|
128 } |
|
129 |
125 // Accessors |
130 // Accessors |
126 static typeArrayOop value(oop java_string) { |
131 static typeArrayOop value(oop java_string) { |
127 assert(initialized && (value_offset > 0), "Must be initialized"); |
132 assert(initialized && (value_offset > 0), "Must be initialized"); |
128 assert(is_instance(java_string), "must be java_string"); |
133 assert(is_instance(java_string), "must be java_string"); |
129 return (typeArrayOop) java_string->obj_field(value_offset); |
134 return (typeArrayOop) java_string->obj_field(value_offset); |
|
135 } |
|
136 static unsigned int hash(oop java_string) { |
|
137 assert(initialized && (hash_offset > 0), "Must be initialized"); |
|
138 assert(is_instance(java_string), "must be java_string"); |
|
139 return java_string->int_field(hash_offset); |
130 } |
140 } |
131 static int offset(oop java_string) { |
141 static int offset(oop java_string) { |
132 assert(initialized, "Must be initialized"); |
142 assert(initialized, "Must be initialized"); |
133 assert(is_instance(java_string), "must be java_string"); |
143 assert(is_instance(java_string), "must be java_string"); |
134 if (offset_offset > 0) { |
144 if (offset_offset > 0) { |