src/share/vm/oops/cpCache.cpp

changeset 8914
75000d7dd468
parent 8739
0b85ccd62409
child 8856
ac27a9c85bea
child 8997
f8a45a60bc6b
     1.1 --- a/src/share/vm/oops/cpCache.cpp	Mon Nov 21 22:56:59 2016 -0800
     1.2 +++ b/src/share/vm/oops/cpCache.cpp	Tue Dec 13 14:37:04 2016 -0500
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -144,7 +144,8 @@
    1.11  
    1.12  void ConstantPoolCacheEntry::set_direct_or_vtable_call(Bytecodes::Code invoke_code,
    1.13                                                         methodHandle method,
    1.14 -                                                       int vtable_index) {
    1.15 +                                                       int vtable_index,
    1.16 +                                                       bool sender_is_interface) {
    1.17    bool is_vtable_call = (vtable_index >= 0);  // FIXME: split this method on this boolean
    1.18    assert(method->interpreter_entry() != NULL, "should have been set at this point");
    1.19    assert(!method->is_obsolete(),  "attempt to write obsolete method to cpCache");
    1.20 @@ -208,7 +209,13 @@
    1.21    if (byte_no == 1) {
    1.22      assert(invoke_code != Bytecodes::_invokevirtual &&
    1.23             invoke_code != Bytecodes::_invokeinterface, "");
    1.24 +    // Don't mark invokespecial to method as resolved if sender is an interface.  The receiver
    1.25 +    // has to be checked that it is a subclass of the current class every time this bytecode
    1.26 +    // is executed.
    1.27 +    if (invoke_code != Bytecodes::_invokespecial || !sender_is_interface ||
    1.28 +        method->name() == vmSymbols::object_initializer_name()) {
    1.29      set_bytecode_1(invoke_code);
    1.30 +    }
    1.31    } else if (byte_no == 2)  {
    1.32      if (change_to_virtual) {
    1.33        assert(invoke_code == Bytecodes::_invokeinterface, "");
    1.34 @@ -238,17 +245,18 @@
    1.35    NOT_PRODUCT(verify(tty));
    1.36  }
    1.37  
    1.38 -void ConstantPoolCacheEntry::set_direct_call(Bytecodes::Code invoke_code, methodHandle method) {
    1.39 +void ConstantPoolCacheEntry::set_direct_call(Bytecodes::Code invoke_code, methodHandle method,
    1.40 +                                             bool sender_is_interface) {
    1.41    int index = Method::nonvirtual_vtable_index;
    1.42    // index < 0; FIXME: inline and customize set_direct_or_vtable_call
    1.43 -  set_direct_or_vtable_call(invoke_code, method, index);
    1.44 +  set_direct_or_vtable_call(invoke_code, method, index, sender_is_interface);
    1.45  }
    1.46  
    1.47  void ConstantPoolCacheEntry::set_vtable_call(Bytecodes::Code invoke_code, methodHandle method, int index) {
    1.48    // either the method is a miranda or its holder should accept the given index
    1.49    assert(method->method_holder()->is_interface() || method->method_holder()->verify_vtable_index(index), "");
    1.50    // index >= 0; FIXME: inline and customize set_direct_or_vtable_call
    1.51 -  set_direct_or_vtable_call(invoke_code, method, index);
    1.52 +  set_direct_or_vtable_call(invoke_code, method, index, false);
    1.53  }
    1.54  
    1.55  void ConstantPoolCacheEntry::set_itable_call(Bytecodes::Code invoke_code, methodHandle method, int index) {

mercurial