Print this page
rev 1838 : 6961690: load oops from constant table on SPARC
Summary: oops should be loaded from the constant table of an nmethod instead of materializing them with a long code sequence.
Reviewed-by:

Split Close
Expand all
Collapse all
          --- old/src/share/vm/opto/compile.cpp
          +++ new/src/share/vm/opto/compile.cpp
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20   20   * or visit www.oracle.com if you need additional information or have any
  21   21   * questions.
  22   22   *
  23   23   */
  24   24  
  25   25  #include "incls/_precompiled.incl"
  26   26  #include "incls/_compile.cpp.incl"
  27   27  
       28 +
       29 +// -------------------- Compile::mach_constant_base_node -----------------------
       30 +// Constant table base node singleton.
       31 +MachConstantBaseNode* Compile::mach_constant_base_node() {
       32 +  if (_mach_constant_base_node == NULL) {
       33 +    _mach_constant_base_node = new (C) MachConstantBaseNode();
       34 +    _mach_constant_base_node->set_req(0, C->root());
       35 +  }
       36 +  return _mach_constant_base_node;
       37 +}
       38 +
       39 +
  28   40  /// Support for intrinsics.
  29   41  
  30   42  // Return the index at which m must be inserted (or already exists).
  31   43  // The sort order is by the address of the ciMethod, with is_virtual as minor key.
  32   44  int Compile::intrinsic_insertion_index(ciMethod* m, bool is_virtual) {
  33   45  #ifdef ASSERT
  34   46    for (int i = 1; i < _intrinsics->length(); i++) {
  35   47      CallGenerator* cg1 = _intrinsics->at(i-1);
  36   48      CallGenerator* cg2 = _intrinsics->at(i);
  37   49      assert(cg1->method() != cg2->method()
↓ open down ↓ 337 lines elided ↑ open up ↑
 375  387      if (is_osr_compilation()) {
 376  388        tty->print("[OSR]%3d", _compile_id);
 377  389      } else {
 378  390        tty->print("%3d", _compile_id);
 379  391      }
 380  392    }
 381  393  #endif
 382  394  }
 383  395  
 384  396  
 385      -void Compile::init_scratch_buffer_blob() {
 386      -  if( scratch_buffer_blob() != NULL )  return;
      397 +void Compile::init_scratch_buffer_blob(int const_size) {
      398 +  if (scratch_buffer_blob() != NULL)  return;
 387  399  
 388  400    // Construct a temporary CodeBuffer to have it construct a BufferBlob
 389  401    // Cache this BufferBlob for this compile.
 390  402    ResourceMark rm;
 391      -  int size = (MAX_inst_size + MAX_stubs_size + MAX_const_size);
      403 +  _scratch_const_size = const_size;
      404 +  int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size);
 392  405    BufferBlob* blob = BufferBlob::create("Compile::scratch_buffer", size);
 393  406    // Record the buffer blob for next time.
 394  407    set_scratch_buffer_blob(blob);
 395  408    // Have we run out of code space?
 396  409    if (scratch_buffer_blob() == NULL) {
 397  410      // Let CompilerBroker disable further compilations.
 398  411      record_failure("Not enough space for scratch buffer in CodeCache");
 399  412      return;
 400  413    }
 401  414  
 402  415    // Initialize the relocation buffers
 403  416    relocInfo* locs_buf = (relocInfo*) blob->content_end() - MAX_locs_size;
 404  417    set_scratch_locs_memory(locs_buf);
 405  418  }
 406  419  
 407  420  
      421 +void Compile::clear_scratch_buffer_blob() {
      422 +  assert(scratch_buffer_blob(), "no BufferBlob set");
      423 +  set_scratch_buffer_blob(NULL);
      424 +  set_scratch_locs_memory(NULL);
      425 +}
      426 +
      427 +
 408  428  //-----------------------scratch_emit_size-------------------------------------
 409  429  // Helper function that computes size by emitting code
 410  430  uint Compile::scratch_emit_size(const Node* n) {
      431 +  // Start scratch_emit_size section.
      432 +  set_in_scratch_emit_size(true);
      433 +
 411  434    // Emit into a trash buffer and count bytes emitted.
 412  435    // This is a pretty expensive way to compute a size,
 413  436    // but it works well enough if seldom used.
 414  437    // All common fixed-size instructions are given a size
 415  438    // method by the AD file.
 416  439    // Note that the scratch buffer blob and locs memory are
 417  440    // allocated at the beginning of the compile task, and
 418  441    // may be shared by several calls to scratch_emit_size.
 419  442    // The allocation of the scratch buffer blob is particularly
 420  443    // expensive, since it has to grab the code cache lock.
 421  444    BufferBlob* blob = this->scratch_buffer_blob();
 422  445    assert(blob != NULL, "Initialize BufferBlob at start");
 423  446    assert(blob->size() > MAX_inst_size, "sanity");
 424  447    relocInfo* locs_buf = scratch_locs_memory();
 425  448    address blob_begin = blob->content_begin();
 426  449    address blob_end   = (address)locs_buf;
 427  450    assert(blob->content_contains(blob_end), "sanity");
 428  451    CodeBuffer buf(blob_begin, blob_end - blob_begin);
 429      -  buf.initialize_consts_size(MAX_const_size);
      452 +  buf.initialize_consts_size(_scratch_const_size);
 430  453    buf.initialize_stubs_size(MAX_stubs_size);
 431  454    assert(locs_buf != NULL, "sanity");
 432      -  int lsize = MAX_locs_size / 2;
 433      -  buf.insts()->initialize_shared_locs(&locs_buf[0],     lsize);
 434      -  buf.stubs()->initialize_shared_locs(&locs_buf[lsize], lsize);
      455 +  int lsize = MAX_locs_size / 3;
      456 +  buf.consts()->initialize_shared_locs(&locs_buf[lsize * 0], lsize);
      457 +  buf.insts()->initialize_shared_locs( &locs_buf[lsize * 1], lsize);
      458 +  buf.stubs()->initialize_shared_locs( &locs_buf[lsize * 2], lsize);
      459 +
      460 +  // Do the emission.
 435  461    n->emit(buf, this->regalloc());
      462 +
      463 +  // End scratch_emit_size section.
      464 +  set_in_scratch_emit_size(false);
      465 +
 436  466    return buf.insts_size();
 437  467  }
 438  468  
 439  469  
 440  470  // ============================================================================
 441  471  //------------------------------Compile standard-------------------------------
 442  472  debug_only( int Compile::_debug_idx = 100000; )
 443  473  
 444  474  // Compile a method.  entry_bci is -1 for normal compilations and indicates
 445  475  // the continuation bci for on stack replacement.
↓ open down ↓ 13 lines elided ↑ open up ↑
 459  489                    _initial_gvn(NULL),
 460  490                    _for_igvn(NULL),
 461  491                    _warm_calls(NULL),
 462  492                    _subsume_loads(subsume_loads),
 463  493                    _do_escape_analysis(do_escape_analysis),
 464  494                    _failure_reason(NULL),
 465  495                    _code_buffer("Compile::Fill_buffer"),
 466  496                    _orig_pc_slot(0),
 467  497                    _orig_pc_slot_offset_in_bytes(0),
 468  498                    _has_method_handle_invokes(false),
      499 +                  _mach_constant_base_node(NULL),
 469  500                    _node_bundling_limit(0),
 470  501                    _node_bundling_base(NULL),
 471  502                    _java_calls(0),
 472  503                    _inner_loops(0),
      504 +                  _scratch_const_size(-1),
      505 +                  _in_scratch_emit_size(false),
 473  506  #ifndef PRODUCT
 474  507                    _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")),
 475  508                    _printer(IdealGraphPrinter::printer()),
 476  509  #endif
 477  510                    _congraph(NULL) {
 478  511    C = this;
 479  512  
 480  513    CompileWrapper cw(this);
 481  514  #ifndef PRODUCT
 482  515    if (TimeCompiler2) {
↓ open down ↓ 243 lines elided ↑ open up ↑
 726  759      _initial_gvn(NULL),
 727  760      _for_igvn(NULL),
 728  761      _warm_calls(NULL),
 729  762      _orig_pc_slot(0),
 730  763      _orig_pc_slot_offset_in_bytes(0),
 731  764      _subsume_loads(true),
 732  765      _do_escape_analysis(false),
 733  766      _failure_reason(NULL),
 734  767      _code_buffer("Compile::Fill_buffer"),
 735  768      _has_method_handle_invokes(false),
      769 +    _mach_constant_base_node(NULL),
 736  770      _node_bundling_limit(0),
 737  771      _node_bundling_base(NULL),
 738  772      _java_calls(0),
 739  773      _inner_loops(0),
 740  774  #ifndef PRODUCT
 741  775      _trace_opto_output(TraceOptoOutput),
 742  776      _printer(NULL),
 743  777  #endif
 744  778      _congraph(NULL) {
 745  779    C = this;
↓ open down ↓ 2069 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX