Print this page
rev 1021 : 6858164: invokedynamic code needs some cleanup (post-6655638)
Note: The bug ID for this change set was erroneously used to call for review of 6815692.
Summary: Fix several crashers, remove needless paths for boxed-style bootstrap method call, refactor & simplify APIs for rewriter constantPoolOop, remove sun.dyn.CallSiteImpl
Reviewed-by: ?
rev 1025 : imported patch indy.compiler.patch
rev 1026 : imported patch indy.compiler.inline.patch

Split Close
Expand all
Collapse all
          --- old/src/share/vm/ci/ciEnv.cpp
          +++ new/src/share/vm/ci/ciEnv.cpp
↓ open down ↓ 412 lines elided ↑ open up ↑
 413  413                                    bool require_local) {
 414  414    GUARDED_VM_ENTRY(return get_klass_by_name_impl(accessing_klass,
 415  415                                                   klass_name,
 416  416                                                   require_local);)
 417  417  }
 418  418  
 419  419  // ------------------------------------------------------------------
 420  420  // ciEnv::get_klass_by_index_impl
 421  421  //
 422  422  // Implementation of get_klass_by_index.
 423      -ciKlass* ciEnv::get_klass_by_index_impl(ciInstanceKlass* accessor,
      423 +ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool,
 424  424                                          int index,
 425      -                                        bool& is_accessible) {
 426      -  assert(accessor->get_instanceKlass()->is_linked(), "must be linked before accessing constant pool");
      425 +                                        bool& is_accessible,
      426 +                                        ciInstanceKlass* accessor) {
 427  427    EXCEPTION_CONTEXT;
 428      -  constantPoolHandle cpool(THREAD, accessor->get_instanceKlass()->constants());
 429  428    KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
 430  429    symbolHandle klass_name;
 431  430    if (klass.is_null()) {
 432  431      // The klass has not been inserted into the constant pool.
 433  432      // Try to look it up by name.
 434  433      {
 435  434        // We have to lock the cpool to keep the oop from being resolved
 436  435        // while we are accessing it.
 437  436        ObjectLocker ol(cpool, THREAD);
 438  437  
↓ open down ↓ 41 lines elided ↑ open up ↑
 480  479  
 481  480    // It is known to be accessible, since it was found in the constant pool.
 482  481    is_accessible = true;
 483  482    return get_object(klass())->as_klass();
 484  483  }
 485  484  
 486  485  // ------------------------------------------------------------------
 487  486  // ciEnv::get_klass_by_index
 488  487  //
 489  488  // Get a klass from the constant pool.
 490      -ciKlass* ciEnv::get_klass_by_index(ciInstanceKlass* accessor,
      489 +ciKlass* ciEnv::get_klass_by_index(constantPoolHandle cpool,
 491  490                                     int index,
 492      -                                   bool& is_accessible) {
 493      -  GUARDED_VM_ENTRY(return get_klass_by_index_impl(accessor, index, is_accessible);)
      491 +                                   bool& is_accessible,
      492 +                                   ciInstanceKlass* accessor) {
      493 +  GUARDED_VM_ENTRY(return get_klass_by_index_impl(cpool, index, is_accessible, accessor);)
 494  494  }
 495  495  
 496  496  // ------------------------------------------------------------------
 497  497  // ciEnv::get_constant_by_index_impl
 498  498  //
 499  499  // Implementation of get_constant_by_index().
 500      -ciConstant ciEnv::get_constant_by_index_impl(ciInstanceKlass* accessor,
 501      -                                             int index) {
      500 +ciConstant ciEnv::get_constant_by_index_impl(constantPoolHandle cpool,
      501 +                                             int index,
      502 +                                             ciInstanceKlass* accessor) {
 502  503    EXCEPTION_CONTEXT;
 503      -  instanceKlass* ik_accessor = accessor->get_instanceKlass();
 504      -  assert(ik_accessor->is_linked(), "must be linked before accessing constant pool");
 505      -  constantPoolOop cpool = ik_accessor->constants();
 506  504    constantTag tag = cpool->tag_at(index);
 507  505    if (tag.is_int()) {
 508  506      return ciConstant(T_INT, (jint)cpool->int_at(index));
 509  507    } else if (tag.is_long()) {
 510  508      return ciConstant((jlong)cpool->long_at(index));
 511  509    } else if (tag.is_float()) {
 512  510      return ciConstant((jfloat)cpool->float_at(index));
 513  511    } else if (tag.is_double()) {
 514  512      return ciConstant((jdouble)cpool->double_at(index));
 515  513    } else if (tag.is_string() || tag.is_unresolved_string()) {
↓ open down ↓ 7 lines elided ↑ open up ↑
 523  521          record_out_of_memory_failure();
 524  522          return ciConstant();
 525  523        }
 526  524      }
 527  525      ciObject* constant = get_object(string);
 528  526      assert (constant->is_instance(), "must be an instance, or not? ");
 529  527      return ciConstant(T_OBJECT, constant);
 530  528    } else if (tag.is_klass() || tag.is_unresolved_klass()) {
 531  529      // 4881222: allow ldc to take a class type
 532  530      bool ignore;
 533      -    ciKlass* klass = get_klass_by_index_impl(accessor, index, ignore);
      531 +    ciKlass* klass = get_klass_by_index_impl(cpool, index, ignore, accessor);
 534  532      if (HAS_PENDING_EXCEPTION) {
 535  533        CLEAR_PENDING_EXCEPTION;
 536  534        record_out_of_memory_failure();
 537  535        return ciConstant();
 538  536      }
 539  537      assert (klass->is_instance_klass() || klass->is_array_klass(),
 540  538              "must be an instance or array klass ");
 541  539      return ciConstant(T_OBJECT, klass);
      540 +  } else if (tag.is_object()) {
      541 +    oop obj = cpool->object_at(index);
      542 +    assert(obj->is_instance(), "must be an instance");
      543 +    ciObject* ciobj = get_object(obj);
      544 +    return ciConstant(T_OBJECT, ciobj);
 542  545    } else {
 543  546      ShouldNotReachHere();
 544  547      return ciConstant();
 545  548    }
 546  549  }
 547  550  
 548  551  // ------------------------------------------------------------------
 549  552  // ciEnv::is_unresolved_string_impl
 550  553  //
 551  554  // Implementation of is_unresolved_string().
↓ open down ↓ 16 lines elided ↑ open up ↑
 568  571    constantTag tag = cpool->tag_at(index);
 569  572    return tag.is_unresolved_klass();
 570  573  }
 571  574  
 572  575  // ------------------------------------------------------------------
 573  576  // ciEnv::get_constant_by_index
 574  577  //
 575  578  // Pull a constant out of the constant pool.  How appropriate.
 576  579  //
 577  580  // Implementation note: this query is currently in no way cached.
 578      -ciConstant ciEnv::get_constant_by_index(ciInstanceKlass* accessor,
 579      -                                        int index) {
 580      -  GUARDED_VM_ENTRY(return get_constant_by_index_impl(accessor, index); )
      581 +ciConstant ciEnv::get_constant_by_index(constantPoolHandle cpool,
      582 +                                        int index,
      583 +                                        ciInstanceKlass* accessor) {
      584 +  GUARDED_VM_ENTRY(return get_constant_by_index_impl(cpool, index, accessor);)
 581  585  }
 582  586  
 583  587  // ------------------------------------------------------------------
 584  588  // ciEnv::is_unresolved_string
 585  589  //
 586  590  // Check constant pool
 587  591  //
 588  592  // Implementation note: this query is currently in no way cached.
 589  593  bool ciEnv::is_unresolved_string(ciInstanceKlass* accessor,
 590      -                                        int index) const {
      594 +                                 int index) const {
 591  595    GUARDED_VM_ENTRY(return is_unresolved_string_impl(accessor->get_instanceKlass(), index); )
 592  596  }
 593  597  
 594  598  // ------------------------------------------------------------------
 595  599  // ciEnv::is_unresolved_klass
 596  600  //
 597  601  // Check constant pool
 598  602  //
 599  603  // Implementation note: this query is currently in no way cached.
 600  604  bool ciEnv::is_unresolved_klass(ciInstanceKlass* accessor,
 601      -                                        int index) const {
      605 +                                int index) const {
 602  606    GUARDED_VM_ENTRY(return is_unresolved_klass_impl(accessor->get_instanceKlass(), index); )
 603  607  }
 604  608  
 605  609  // ------------------------------------------------------------------
 606  610  // ciEnv::get_field_by_index_impl
 607  611  //
 608  612  // Implementation of get_field_by_index.
 609  613  //
 610  614  // Implementation note: the results of field lookups are cached
 611  615  // in the accessor klass.
↓ open down ↓ 60 lines elided ↑ open up ↑
 672  676      break;
 673  677    default: ShouldNotReachHere();
 674  678    }
 675  679  
 676  680    return dest_method();
 677  681  }
 678  682  
 679  683  
 680  684  // ------------------------------------------------------------------
 681  685  // ciEnv::get_method_by_index_impl
 682      -ciMethod* ciEnv::get_method_by_index_impl(ciInstanceKlass* accessor,
 683      -                                     int index, Bytecodes::Code bc) {
 684      -  // Get the method's declared holder.
 685      -
 686      -  assert(accessor->get_instanceKlass()->is_linked(), "must be linked before accessing constant pool");
 687      -  constantPoolHandle cpool = accessor->get_instanceKlass()->constants();
      686 +ciMethod* ciEnv::get_method_by_index_impl(constantPoolHandle cpool,
      687 +                                          int index, Bytecodes::Code bc,
      688 +                                          ciInstanceKlass* accessor) {
 688  689    int holder_index = cpool->klass_ref_index_at(index);
 689  690    bool holder_is_accessible;
 690      -  ciKlass* holder = get_klass_by_index_impl(accessor, holder_index, holder_is_accessible);
      691 +  ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
 691  692    ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
 692  693  
 693  694    // Get the method's name and signature.
 694  695    symbolOop name_sym = cpool->name_ref_at(index);
 695  696    symbolOop sig_sym  = cpool->signature_ref_at(index);
 696  697  
 697  698    if (holder_is_accessible) { // Our declared holder is loaded.
 698  699      instanceKlass* lookup = declared_holder->get_instanceKlass();
 699  700      methodOop m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);
 700  701      if (m != NULL) {
↓ open down ↓ 7 lines elided ↑ open up ↑
 708  709    // lookup.
 709  710  
 710  711    return get_unloaded_method(declared_holder,
 711  712                               get_object(name_sym)->as_symbol(),
 712  713                               get_object(sig_sym)->as_symbol());
 713  714  }
 714  715  
 715  716  
 716  717  // ------------------------------------------------------------------
 717  718  // ciEnv::get_fake_invokedynamic_method_impl
 718      -ciMethod* ciEnv::get_fake_invokedynamic_method_impl(ciInstanceKlass* accessor,
      719 +ciMethod* ciEnv::get_fake_invokedynamic_method_impl(constantPoolHandle cpool,
 719  720                                                      int index, Bytecodes::Code bc) {
 720  721    assert(bc == Bytecodes::_invokedynamic, "must be invokedynamic");
 721      -  assert(accessor->get_instanceKlass()->is_linked(), "must be linked before accessing constant pool");
 722      -  constantPoolHandle cpool = accessor->get_instanceKlass()->constants();
 723  722  
 724  723    // Get the CallSite from the constant pool cache.
 725  724    ConstantPoolCacheEntry* cpc_entry = cpool->cache()->secondary_entry_at(index);
 726  725    assert(cpc_entry != NULL && cpc_entry->is_secondary_entry(), "sanity");
 727  726    Handle call_site = cpc_entry->f1();
 728  727  
 729  728    // Call site might not be linked yet.
 730  729    if (call_site.is_null()) {
 731  730      ciInstanceKlass* mh_klass = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass();
 732  731      ciSymbol*       sig_sym   = get_object(cpool->signature_ref_at(index))->as_symbol();
↓ open down ↓ 26 lines elided ↑ open up ↑
 759  758      return current()->Object_klass();
 760  759    } else {
 761  760      ShouldNotReachHere();
 762  761    }
 763  762    return NULL;
 764  763  }
 765  764  
 766  765  
 767  766  // ------------------------------------------------------------------
 768  767  // ciEnv::get_method_by_index
 769      -ciMethod* ciEnv::get_method_by_index(ciInstanceKlass* accessor,
 770      -                                     int index, Bytecodes::Code bc) {
      768 +ciMethod* ciEnv::get_method_by_index(constantPoolHandle cpool,
      769 +                                     int index, Bytecodes::Code bc,
      770 +                                     ciInstanceKlass* accessor) {
 771  771    if (bc == Bytecodes::_invokedynamic) {
 772      -    GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(accessor, index, bc);)
      772 +    GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(cpool, index, bc);)
 773  773    } else {
 774      -    GUARDED_VM_ENTRY(return get_method_by_index_impl(accessor, index, bc);)
      774 +    GUARDED_VM_ENTRY(return get_method_by_index_impl(cpool, index, bc, accessor);)
 775  775    }
 776  776  }
 777  777  
 778  778  
 779  779  // ------------------------------------------------------------------
 780  780  // ciEnv::name_buffer
 781  781  char *ciEnv::name_buffer(int req_len) {
 782  782    if (_name_buffer_len < req_len) {
 783  783      if (_name_buffer == NULL) {
 784  784        _name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len);
↓ open down ↓ 307 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX