当前位置: 首页>>代码示例>>C++>>正文


C++ Klass::up_cast_abstract方法代码示例

本文整理汇总了C++中Klass::up_cast_abstract方法的典型用法代码示例。如果您正苦于以下问题:C++ Klass::up_cast_abstract方法的具体用法?C++ Klass::up_cast_abstract怎么用?C++ Klass::up_cast_abstract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Klass的用法示例。


在下文中一共展示了Klass::up_cast_abstract方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: analyze_call

CHAResult* CHA::analyze_call(KlassHandle calling_klass, KlassHandle static_receiver, KlassHandle actual_receiver, 
                             symbolHandle name, symbolHandle signature) {
  assert(static_receiver->oop_is_instance(), "must be instance klass");
  
  methodHandle m;
  // Only do exact lookup if receiver klass has been linked.  Otherwise,
  // the vtables has not been setup, and the LinkResolver will fail.
  if (instanceKlass::cast(static_receiver())->is_linked() && instanceKlass::cast(actual_receiver())->is_linked()) {    
    if (static_receiver->is_interface()) {
      // no point trying to resolve unless actual receiver is a klass
      if (!actual_receiver->is_interface()) {
        m = LinkResolver::resolve_interface_call_or_null(actual_receiver, static_receiver, name, signature, calling_klass);
      }
    } else {
      m = LinkResolver::resolve_virtual_call_or_null(actual_receiver, static_receiver, name, signature, calling_klass);
    }

    if (m.is_null()) {
      // didn't find method (e.g., could be abstract method)
      return new CHAResult(actual_receiver, name, signature, NULL, NULL, m, false);
    } 
    if( Klass::can_be_statically_bound(m()) ||
        m()->is_private() || 
        actual_receiver->subklass() == NULL ) {
      // always optimize final methods, private methods or methods with no
      // subclasses.
      return new CHAResult(actual_receiver, name, signature, NULL, NULL, m);
    } 
    if (!UseCHA) {
      // don't optimize this call
      return new CHAResult(actual_receiver, name, signature, NULL, NULL, m, false);
    }
  }

  // If the method is abstract then each non-abstract subclass must implement 
  // the method and inlining is not possible.  If there is exactly 1 subclass
  // then there can be only 1 implementation and we are OK.  
  if( !m.is_null() && m()->is_abstract() ) {// Method is abstract?
    Klass *sr = Klass::cast(static_receiver());
    if( sr == sr->up_cast_abstract() )
      return new CHAResult(actual_receiver, name, signature, NULL, NULL, m, false);
    // Fall into the next code; it will find the one implementation
    // and that implementation is correct.
  }

  _used = true;
  GrowableArray<methodHandle>* methods  = new GrowableArray<methodHandle>(CHA::max_result());
  GrowableArray<KlassHandle>* receivers = new GrowableArray<KlassHandle>(CHA::max_result());

  // Since 'm' is visible from the actual receiver we can call it if the
  // runtime receiver class does not override 'm'.  
  if( !m.is_null() && m()->method_holder() != actual_receiver() &&
      !m->is_abstract() ) {
    receivers->push(actual_receiver);
    methods->push(m);
  }
  if (static_receiver->is_interface()) {
    instanceKlassHandle sr = static_receiver();
    process_interface(sr, receivers, methods, name, signature);
  } else {
    process_class(static_receiver, receivers, methods, name, signature);
  }

  methodHandle dummy;
  CHAResult* res = new CHAResult(actual_receiver, name, signature, receivers, methods, dummy);

  //res->print();
  return res;
}
开发者ID:subxiang,项目名称:jdk-source-code,代码行数:69,代码来源:cha.cpp


注:本文中的Klass::up_cast_abstract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。