changeset 14717:aa1a43bfdf4e

make HotSpotResolvedJavaMethod leaner
author twisti
date Fri, 21 Mar 2014 14:26:58 -0700
parents 03704aa6e71b
children 25359cbb95e3
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java src/share/vm/graal/graalCompilerToVM.cpp src/share/vm/graal/graalJavaAccess.hpp src/share/vm/runtime/vmStructs.cpp
diffstat 7 files changed, 50 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Fri Mar 21 13:54:43 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Fri Mar 21 14:26:58 2014 -0700
@@ -1022,8 +1022,15 @@
     @HotSpotVMField(name = "Method::_access_flags", type = "AccessFlags", get = HotSpotVMField.Type.OFFSET) @Stable public int methodAccessFlagsOffset;
     @HotSpotVMField(name = "Method::_constMethod", type = "ConstMethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodConstMethodOffset;
     @HotSpotVMField(name = "Method::_intrinsic_id", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodIntrinsicIdOffset;
+    @HotSpotVMField(name = "Method::_flags", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodFlagsOffset;
     @HotSpotVMField(name = "Method::_vtable_index", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodVtableIndexOffset;
 
+    @HotSpotVMConstant(name = "Method::_jfr_towrite") @Stable public int methodFlagsJfrTowrite;
+    @HotSpotVMConstant(name = "Method::_caller_sensitive") @Stable public int methodFlagsCallerSensitive;
+    @HotSpotVMConstant(name = "Method::_force_inline") @Stable public int methodFlagsForceInline;
+    @HotSpotVMConstant(name = "Method::_dont_inline") @Stable public int methodFlagsDontInline;
+    @HotSpotVMConstant(name = "Method::_hidden") @Stable public int methodFlagsHidden;
+
     @HotSpotVMConstant(name = "JVM_ACC_MONITOR_MATCH") @Stable public int jvmAccMonitorMatch;
     @HotSpotVMConstant(name = "JVM_ACC_HAS_MONITOR_BYTECODES") @Stable public int jvmAccHasMonitorBytecodes;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Fri Mar 21 13:54:43 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Fri Mar 21 14:26:58 2014 -0700
@@ -99,12 +99,12 @@
     long getKlassImplementor(long metaspaceKlass);
 
     /**
-     * Initializes a {@link HotSpotResolvedJavaMethod} object from a metaspace Method object.
+     * Determines if a given metaspace method is ignored by security stack walks.
      * 
      * @param metaspaceMethod the metaspace Method object
-     * @param method address of a metaspace Method object
+     * @return true if the method is ignored
      */
-    void initializeMethod(long metaspaceMethod, HotSpotResolvedJavaMethod method);
+    boolean methodIsIgnoredBySecurityStackWalk(long metaspaceMethod);
 
     /**
      * Converts a name to a metaspace klass.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Fri Mar 21 13:54:43 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Fri Mar 21 14:26:58 2014 -0700
@@ -104,8 +104,7 @@
     @Override
     public native boolean hasFinalizableSubclass(long metaspaceKlass);
 
-    @Override
-    public native void initializeMethod(long metaspaceMethod, HotSpotResolvedJavaMethod method);
+    public native boolean methodIsIgnoredBySecurityStackWalk(long metaspaceMethod);
 
     @Override
     public native long getClassInitializer(long metaspaceKlass);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Fri Mar 21 13:54:43 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Fri Mar 21 14:26:58 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,10 +53,6 @@
     private final HotSpotResolvedObjectType holder;
     private final HotSpotConstantPool constantPool;
     private final HotSpotSignature signature;
-    private boolean callerSensitive;
-    private boolean forceInline;
-    private boolean dontInline;
-    private boolean ignoredBySecurityStackWalk;
     private HotSpotMethodData methodData;
     private byte[] code;
     private SpeculationLog speculationLog;
@@ -109,8 +105,6 @@
 
         final int signatureIndex = unsafe.getChar(constMethod + config.constMethodSignatureIndexOffset);
         this.signature = (HotSpotSignature) constantPool.lookupSignature(signatureIndex);
-
-        runtime().getCompilerToVM().initializeMethod(metaspaceMethod, this);
     }
 
     /**
@@ -139,11 +133,20 @@
     }
 
     /**
+     * Returns this method's flags ({@code Method::_flags}).
+     * 
+     * @return flags of this method
+     */
+    private int getFlags() {
+        return unsafe.getByte(metaspaceMethod + runtime().getConfig().methodFlagsOffset);
+    }
+
+    /**
      * Returns this method's constant method flags ({@code ConstMethod::_flags}).
      * 
      * @return flags of this method's ConstMethod
      */
-    private long getConstMethodFlags() {
+    private int getConstMethodFlags() {
         return unsafe.getChar(getConstMethod() + runtime().getConfig().constMethodFlagsOffset);
     }
 
@@ -169,8 +172,7 @@
      * modifiers as well as the HotSpot internal modifiers.
      */
     public int getAllModifiers() {
-        HotSpotVMConfig config = runtime().getConfig();
-        return unsafe.getInt(metaspaceMethod + config.methodAccessFlagsOffset);
+        return unsafe.getInt(metaspaceMethod + runtime().getConfig().methodAccessFlagsOffset);
     }
 
     @Override
@@ -245,19 +247,36 @@
     }
 
     /**
-     * Returns true if this method has a CallerSensitive annotation.
+     * Returns true if this method has a {@code CallerSensitive} annotation.
      * 
      * @return true if CallerSensitive annotation present, false otherwise
      */
     public boolean isCallerSensitive() {
-        return callerSensitive;
+        return (getFlags() & runtime().getConfig().methodFlagsCallerSensitive) != 0;
+    }
+
+    /**
+     * Returns true if this method has a {@code ForceInline} annotation.
+     * 
+     * @return true if ForceInline annotation present, false otherwise
+     */
+    public boolean isForceInline() {
+        return (getFlags() & runtime().getConfig().methodFlagsForceInline) != 0;
+    }
+
+    /**
+     * Returns true if this method has a {@code DontInline} annotation.
+     * 
+     * @return true if DontInline annotation present, false otherwise
+     */
+    public boolean isDontInline() {
+        return (getFlags() & runtime().getConfig().methodFlagsDontInline) != 0;
     }
 
     /**
      * Manually adds a DontInline annotation to this method.
      */
     public void setNotInlineable() {
-        dontInline = true;
         runtime().getCompilerToVM().doNotInlineOrCompile(metaspaceMethod);
     }
 
@@ -268,7 +287,7 @@
      * @return true if special method ignored by security stack walks, false otherwise
      */
     public boolean ignoredBySecurityStackWalk() {
-        return ignoredBySecurityStackWalk;
+        return runtime().getCompilerToVM().methodIsIgnoredBySecurityStackWalk(metaspaceMethod);
     }
 
     public boolean hasBalancedMonitors() {
@@ -502,7 +521,7 @@
 
     @Override
     public boolean canBeInlined() {
-        if (dontInline) {
+        if (isDontInline()) {
             return false;
         }
         return runtime().getCompilerToVM().canInlineMethod(metaspaceMethod);
@@ -510,7 +529,7 @@
 
     @Override
     public boolean shouldBeInlined() {
-        if (forceInline) {
+        if (isForceInline()) {
             return true;
         }
         return runtime().getCompilerToVM().shouldInlineMethod(metaspaceMethod);
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Fri Mar 21 13:54:43 2014 +0100
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Fri Mar 21 14:26:58 2014 -0700
@@ -329,13 +329,9 @@
   return (jlong) (address) klass->implementor();
 C2V_END
 
-C2V_VMENTRY(void, initializeMethod,(JNIEnv *, jobject, jlong metaspace_method, jobject hotspot_method))
+C2V_VMENTRY(jboolean, methodIsIgnoredBySecurityStackWalk,(JNIEnv *, jobject, jlong metaspace_method))
   methodHandle method = asMethod(metaspace_method);
-  InstanceKlass::cast(HotSpotResolvedJavaMethod::klass())->initialize(CHECK);
-  HotSpotResolvedJavaMethod::set_callerSensitive(hotspot_method, method->caller_sensitive());
-  HotSpotResolvedJavaMethod::set_forceInline(hotspot_method, method->force_inline());
-  HotSpotResolvedJavaMethod::set_dontInline(hotspot_method, method->dont_inline());
-  HotSpotResolvedJavaMethod::set_ignoredBySecurityStackWalk(hotspot_method, method->is_ignored_by_security_stack_walk());
+  return method->is_ignored_by_security_stack_walk();
 C2V_END
 
 C2V_VMENTRY(jboolean, canInlineMethod,(JNIEnv *, jobject, jlong metaspace_method))
@@ -805,7 +801,7 @@
   {CC"findUniqueConcreteMethod",                     CC"("METASPACE_METHOD")"METASPACE_METHOD,                         FN_PTR(findUniqueConcreteMethod)},
   {CC"getKlassImplementor",                          CC"("METASPACE_KLASS")"METASPACE_KLASS,                           FN_PTR(getKlassImplementor)},
   {CC"getStackTraceElement",                         CC"("METASPACE_METHOD"I)"STACK_TRACE_ELEMENT,                     FN_PTR(getStackTraceElement)},
-  {CC"initializeMethod",                             CC"("METASPACE_METHOD HS_RESOLVED_METHOD")V",                     FN_PTR(initializeMethod)},
+  {CC"methodIsIgnoredBySecurityStackWalk",           CC"("METASPACE_METHOD")Z",                                        FN_PTR(methodIsIgnoredBySecurityStackWalk)},
   {CC"doNotInlineOrCompile",                         CC"("METASPACE_METHOD")V",                                        FN_PTR(doNotInlineOrCompile)},
   {CC"canInlineMethod",                              CC"("METASPACE_METHOD")Z",                                        FN_PTR(canInlineMethod)},
   {CC"shouldInlineMethod",                           CC"("METASPACE_METHOD")Z",                                        FN_PTR(shouldInlineMethod)},
--- a/src/share/vm/graal/graalJavaAccess.hpp	Fri Mar 21 13:54:43 2014 +0100
+++ b/src/share/vm/graal/graalJavaAccess.hpp	Fri Mar 21 14:26:58 2014 -0700
@@ -55,10 +55,6 @@
     oop_field(HotSpotResolvedJavaMethod, name, "Ljava/lang/String;")                                                                                           \
     oop_field(HotSpotResolvedJavaMethod, holder, "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedObjectType;")                                                  \
     long_field(HotSpotResolvedJavaMethod, metaspaceMethod)                                                                                                     \
-    boolean_field(HotSpotResolvedJavaMethod, callerSensitive)                                                                                                  \
-    boolean_field(HotSpotResolvedJavaMethod, forceInline)                                                                                                      \
-    boolean_field(HotSpotResolvedJavaMethod, dontInline)                                                                                                       \
-    boolean_field(HotSpotResolvedJavaMethod, ignoredBySecurityStackWalk)                                                                                       \
   end_class                                                                                                                                                    \
   start_class(HotSpotJavaType)                                                                                                                                 \
     oop_field(HotSpotJavaType, name, "Ljava/lang/String;")                                                                                                     \
--- a/src/share/vm/runtime/vmStructs.cpp	Fri Mar 21 13:54:43 2014 +0100
+++ b/src/share/vm/runtime/vmStructs.cpp	Fri Mar 21 14:26:58 2014 -0700
@@ -374,6 +374,7 @@
   nonstatic_field(Method,               _vtable_index,                                 int)                                   \
   nonstatic_field(Method,               _method_size,                                  u2)                                    \
   nonstatic_field(Method,               _intrinsic_id,                                 u1)                                    \
+  nonstatic_field(Method,               _flags,                                        u1)                                    \
   nonproduct_nonstatic_field(Method,    _compiled_invocation_count,                    int)                                   \
   volatile_nonstatic_field(Method,      _code,                                         nmethod*)                              \
   nonstatic_field(Method,               _i2i_entry,                                    address)                               \