502 // expensive, since it has to grab the code cache lock. 503 BufferBlob* blob = this->scratch_buffer_blob(); 504 assert(blob != NULL, "Initialize BufferBlob at start"); 505 assert(blob->size() > MAX_inst_size, "sanity"); 506 relocInfo* locs_buf = scratch_locs_memory(); 507 address blob_begin = blob->content_begin(); 508 address blob_end = (address)locs_buf; 509 assert(blob->content_contains(blob_end), "sanity"); 510 CodeBuffer buf(blob_begin, blob_end - blob_begin); 511 buf.initialize_consts_size(_scratch_const_size); 512 buf.initialize_stubs_size(MAX_stubs_size); 513 assert(locs_buf != NULL, "sanity"); 514 int lsize = MAX_locs_size / 3; 515 buf.consts()->initialize_shared_locs(&locs_buf[lsize * 0], lsize); 516 buf.insts()->initialize_shared_locs( &locs_buf[lsize * 1], lsize); 517 buf.stubs()->initialize_shared_locs( &locs_buf[lsize * 2], lsize); 518 519 // Do the emission. 520 521 Label fakeL; // Fake label for branch instructions. 522 bool is_branch = n->is_Branch() && n->as_Mach()->ideal_Opcode() != Op_Jump; 523 if (is_branch) { 524 MacroAssembler masm(&buf); 525 masm.bind(fakeL); 526 n->as_Mach()->label_set(&fakeL, 0); 527 } 528 n->emit(buf, this->regalloc()); 529 if (is_branch) // Clear the reference to fake label. 530 n->as_Mach()->label_set(NULL, 0); 531 532 // End scratch_emit_size section. 533 set_in_scratch_emit_size(false); 534 535 return buf.insts_size(); 536 } 537 538 539 // ============================================================================ 540 //------------------------------Compile standard------------------------------- 541 debug_only( int Compile::_debug_idx = 100000; ) 542 543 // Compile a method. entry_bci is -1 for normal compilations and indicates 544 // the continuation bci for on stack replacement. 545 546 547 Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr_bci, bool subsume_loads, bool do_escape_analysis ) 548 : Phase(Compiler), 549 _env(ci_env), 550 _log(ci_env->log()), | 502 // expensive, since it has to grab the code cache lock. 503 BufferBlob* blob = this->scratch_buffer_blob(); 504 assert(blob != NULL, "Initialize BufferBlob at start"); 505 assert(blob->size() > MAX_inst_size, "sanity"); 506 relocInfo* locs_buf = scratch_locs_memory(); 507 address blob_begin = blob->content_begin(); 508 address blob_end = (address)locs_buf; 509 assert(blob->content_contains(blob_end), "sanity"); 510 CodeBuffer buf(blob_begin, blob_end - blob_begin); 511 buf.initialize_consts_size(_scratch_const_size); 512 buf.initialize_stubs_size(MAX_stubs_size); 513 assert(locs_buf != NULL, "sanity"); 514 int lsize = MAX_locs_size / 3; 515 buf.consts()->initialize_shared_locs(&locs_buf[lsize * 0], lsize); 516 buf.insts()->initialize_shared_locs( &locs_buf[lsize * 1], lsize); 517 buf.stubs()->initialize_shared_locs( &locs_buf[lsize * 2], lsize); 518 519 // Do the emission. 520 521 Label fakeL; // Fake label for branch instructions. 522 Label* saveL = NULL; 523 uint save_bnum = 0; 524 bool is_branch = n->is_MachBranch(); 525 if (is_branch) { 526 MacroAssembler masm(&buf); 527 masm.bind(fakeL); 528 n->as_MachBranch()->save_label(&saveL, &save_bnum); 529 n->as_MachBranch()->label_set(&fakeL, 0); 530 } 531 n->emit(buf, this->regalloc()); 532 if (is_branch) // Restore label. 533 n->as_MachBranch()->label_set(saveL, save_bnum); 534 535 // End scratch_emit_size section. 536 set_in_scratch_emit_size(false); 537 538 return buf.insts_size(); 539 } 540 541 542 // ============================================================================ 543 //------------------------------Compile standard------------------------------- 544 debug_only( int Compile::_debug_idx = 100000; ) 545 546 // Compile a method. entry_bci is -1 for normal compilations and indicates 547 // the continuation bci for on stack replacement. 548 549 550 Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr_bci, bool subsume_loads, bool do_escape_analysis ) 551 : Phase(Compiler), 552 _env(ci_env), 553 _log(ci_env->log()), |