changeset 8443:b56e03b3e2d9

8175932: Improve host instance supports Reviewed-by: coleenp, mschoene Contributed-by: harold.seigel@oracle.com
author hseigel
date Mon, 20 Mar 2017 14:38:35 -0400
parents 733615d6afda
children 964d7f65d54f
files src/share/vm/interpreter/interpreterRuntime.cpp src/share/vm/oops/instanceKlass.hpp
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/interpreter/interpreterRuntime.cpp	Thu Mar 16 17:38:32 2017 +0000
+++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Mon Mar 20 14:38:35 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -768,7 +768,7 @@
   // it is not an interface.  The receiver for invokespecial calls within interface
   // methods must be checked for every call.
   InstanceKlass* sender = pool->pool_holder();
-  sender = sender->is_anonymous() ? InstanceKlass::cast(sender->host_klass()) : sender;
+  sender = sender->has_host_klass() ? InstanceKlass::cast(sender->host_klass()) : sender;
 
   switch (info.call_kind()) {
   case CallInfo::direct_call:
--- a/src/share/vm/oops/instanceKlass.hpp	Thu Mar 16 17:38:32 2017 +0000
+++ b/src/share/vm/oops/instanceKlass.hpp	Mon Mar 20 14:38:35 2017 -0400
@@ -565,9 +565,11 @@
   Klass* host_klass() const              {
     Klass** hk = (Klass**)adr_host_klass();
     if (hk == NULL) {
+      assert(!is_anonymous(), "Anonymous classes have host klasses");
       return NULL;
     } else {
       assert(*hk != NULL, "host klass should always be set if the address is not null");
+      assert(is_anonymous(), "Only anonymous classes have host klasses");
       return *hk;
     }
   }
@@ -579,6 +581,9 @@
       *addr = host;
     }
   }
+  bool has_host_klass() const              {
+    return adr_host_klass() != NULL;
+  }
   bool is_anonymous() const                {
     return (_misc_flags & _misc_is_anonymous) != 0;
   }