src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPoolObject.java
author pchilanomate
Fri, 31 Aug 2018 10:22:04 -0400
changeset 51610 cdef4df6b0e7
parent 51420 6bb7b8d0da76
child 52381 7f90bc64b0fc
permissions -rw-r--r--
8206424: Use locking for cleaning ProtectionDomainTable Summary: ServiceThread is now in charge of cleaning ProtectionDomainTable entries Reviewed-by: coleenp, iklam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
     1
/*
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
     4
 *
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
     8
 *
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    13
 * accompanied this code).
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    14
 *
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    18
 *
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    21
 * questions.
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    22
 */
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    23
package jdk.vm.ci.hotspot;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    24
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    25
import jdk.vm.ci.meta.JavaConstant;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    26
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    27
/**
51420
6bb7b8d0da76 8209535: [JVMCI] Do not swallow NoClassDefFoundError when converting JVMCI methods and fields to reflection objects
dnsimon
parents: 47668
diff changeset
    28
 * Represents a constant that was retrieved from a constant pool. Used to keep track of the constant
6bb7b8d0da76 8209535: [JVMCI] Do not swallow NoClassDefFoundError when converting JVMCI methods and fields to reflection objects
dnsimon
parents: 47668
diff changeset
    29
 * pool slot for the constant.
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    30
 */
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    31
public final class HotSpotConstantPoolObject extends HotSpotObjectConstantImpl {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    32
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    33
    static JavaConstant forObject(HotSpotResolvedObjectType type, int cpi, Object object) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    34
        return new HotSpotConstantPoolObject(type, cpi, object);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    35
    }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    36
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    37
    public static JavaConstant forObject(HotSpotResolvedObjectType type, int cpi, JavaConstant object) {
51420
6bb7b8d0da76 8209535: [JVMCI] Do not swallow NoClassDefFoundError when converting JVMCI methods and fields to reflection objects
dnsimon
parents: 47668
diff changeset
    38
        return forObject(type, cpi, ((HotSpotObjectConstantImpl) object).object());
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    39
    }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    40
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    41
    private final HotSpotResolvedObjectType type;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    42
    private final int cpi;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    43
51420
6bb7b8d0da76 8209535: [JVMCI] Do not swallow NoClassDefFoundError when converting JVMCI methods and fields to reflection objects
dnsimon
parents: 47668
diff changeset
    44
    public HotSpotResolvedObjectType getCpType() {
6bb7b8d0da76 8209535: [JVMCI] Do not swallow NoClassDefFoundError when converting JVMCI methods and fields to reflection objects
dnsimon
parents: 47668
diff changeset
    45
        return type;
6bb7b8d0da76 8209535: [JVMCI] Do not swallow NoClassDefFoundError when converting JVMCI methods and fields to reflection objects
dnsimon
parents: 47668
diff changeset
    46
    }
6bb7b8d0da76 8209535: [JVMCI] Do not swallow NoClassDefFoundError when converting JVMCI methods and fields to reflection objects
dnsimon
parents: 47668
diff changeset
    47
6bb7b8d0da76 8209535: [JVMCI] Do not swallow NoClassDefFoundError when converting JVMCI methods and fields to reflection objects
dnsimon
parents: 47668
diff changeset
    48
    public int getCpi() {
6bb7b8d0da76 8209535: [JVMCI] Do not swallow NoClassDefFoundError when converting JVMCI methods and fields to reflection objects
dnsimon
parents: 47668
diff changeset
    49
        return cpi;
6bb7b8d0da76 8209535: [JVMCI] Do not swallow NoClassDefFoundError when converting JVMCI methods and fields to reflection objects
dnsimon
parents: 47668
diff changeset
    50
    }
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    51
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    52
    HotSpotConstantPoolObject(HotSpotResolvedObjectType type, int cpi, Object object) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    53
        super(object, false);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    54
        this.type = type;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    55
        this.cpi = cpi;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    56
    }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    57
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    58
    @Override
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    59
    public boolean equals(Object o) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    60
        if (o instanceof HotSpotConstantPoolObject) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    61
            if (super.equals(o)) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    62
                HotSpotConstantPoolObject other = (HotSpotConstantPoolObject) o;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    63
                return type == other.type && cpi == other.cpi;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    64
            }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    65
        }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    66
        return false;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    67
    }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    68
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    69
    @Override
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    70
    public String toValueString() {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    71
        return getCpType().getName() + getCpi();
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    72
    }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    73
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    74
    @Override
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    75
    public String toString() {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    76
        return super.toString() + "@" + toValueString();
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    77
    }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    78
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents:
diff changeset
    79
}