1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
333 }
334
335 void interface_method_at_put(int which, int class_index, int name_and_type_index) {
336 tag_at_put(which, JVM_CONSTANT_InterfaceMethodref);
337 *int_at_addr(which) = ((jint) name_and_type_index<<16) | class_index; // Not so nice
338 }
339
340 void name_and_type_at_put(int which, int name_index, int signature_index) {
341 tag_at_put(which, JVM_CONSTANT_NameAndType);
342 *int_at_addr(which) = ((jint) signature_index<<16) | name_index; // Not so nice
343 }
344
345 // Tag query
346
347 constantTag tag_at(int which) const { return (constantTag)tags()->at_acquire(which); }
348
349 // Fetching constants
350
351 Klass* klass_at(int which, TRAPS) {
352 constantPoolHandle h_this(THREAD, this);
353 return klass_at_impl(h_this, which, CHECK_NULL);
354 }
355
356 Symbol* klass_name_at(int which); // Returns the name, w/o resolving.
357
358 Klass* resolved_klass_at(int which) const { // Used by Compiler
359 guarantee(tag_at(which).is_klass(), "Corrupted constant pool");
360 // Must do an acquire here in case another thread resolved the klass
361 // behind our back, lest we later load stale values thru the oop.
362 return CPSlot((Klass*)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_klass();
363 }
364
365 // This method should only be used with a cpool lock or during parsing or gc
366 Symbol* unresolved_klass_at(int which) { // Temporary until actual use
367 Symbol* s = CPSlot((Symbol*)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_symbol();
368 // check that the klass is still unresolved.
369 assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool");
370 return s;
371 }
372
373 // RedefineClasses() API support:
|
1 /*
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
333 }
334
335 void interface_method_at_put(int which, int class_index, int name_and_type_index) {
336 tag_at_put(which, JVM_CONSTANT_InterfaceMethodref);
337 *int_at_addr(which) = ((jint) name_and_type_index<<16) | class_index; // Not so nice
338 }
339
340 void name_and_type_at_put(int which, int name_index, int signature_index) {
341 tag_at_put(which, JVM_CONSTANT_NameAndType);
342 *int_at_addr(which) = ((jint) signature_index<<16) | name_index; // Not so nice
343 }
344
345 // Tag query
346
347 constantTag tag_at(int which) const { return (constantTag)tags()->at_acquire(which); }
348
349 // Fetching constants
350
351 Klass* klass_at(int which, TRAPS) {
352 constantPoolHandle h_this(THREAD, this);
353 return klass_at_impl(h_this, which, THREAD);
354 }
355
356 Symbol* klass_name_at(int which); // Returns the name, w/o resolving.
357
358 Klass* resolved_klass_at(int which) const { // Used by Compiler
359 guarantee(tag_at(which).is_klass(), "Corrupted constant pool");
360 // Must do an acquire here in case another thread resolved the klass
361 // behind our back, lest we later load stale values thru the oop.
362 return CPSlot((Klass*)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_klass();
363 }
364
365 // This method should only be used with a cpool lock or during parsing or gc
366 Symbol* unresolved_klass_at(int which) { // Temporary until actual use
367 Symbol* s = CPSlot((Symbol*)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_symbol();
368 // check that the klass is still unresolved.
369 assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool");
370 return s;
371 }
372
373 // RedefineClasses() API support:
|