557 // Note that the scratch buffer blob and locs memory are
558 // allocated at the beginning of the compile task, and
559 // may be shared by several calls to scratch_emit_size.
560 // The allocation of the scratch buffer blob is particularly
561 // expensive, since it has to grab the code cache lock.
562 BufferBlob* blob = this->scratch_buffer_blob();
563 assert(blob != NULL, "Initialize BufferBlob at start");
564 assert(blob->size() > MAX_inst_size, "sanity");
565 relocInfo* locs_buf = scratch_locs_memory();
566 address blob_begin = blob->content_begin();
567 address blob_end = (address)locs_buf;
568 assert(blob->contains(blob_end), "sanity");
569 CodeBuffer buf(blob_begin, blob_end - blob_begin);
570 buf.initialize_consts_size(_scratch_const_size);
571 buf.initialize_stubs_size(MAX_stubs_size);
572 assert(locs_buf != NULL, "sanity");
573 int lsize = MAX_locs_size / 3;
574 buf.consts()->initialize_shared_locs(&locs_buf[lsize * 0], lsize);
575 buf.insts()->initialize_shared_locs( &locs_buf[lsize * 1], lsize);
576 buf.stubs()->initialize_shared_locs( &locs_buf[lsize * 2], lsize);
577
578 // Do the emission.
579
580 Label fakeL; // Fake label for branch instructions.
581 Label* saveL = NULL;
582 uint save_bnum = 0;
583 bool is_branch = n->is_MachBranch();
584 if (is_branch) {
585 MacroAssembler masm(&buf);
586 masm.bind(fakeL);
587 n->as_MachBranch()->save_label(&saveL, &save_bnum);
588 n->as_MachBranch()->label_set(&fakeL, 0);
589 }
590 n->emit(buf, this->regalloc());
591
592 // Emitting into the scratch buffer should not fail
593 assert (!failing(), "Must not have pending failure. Reason is: %s", failure_reason());
594
595 if (is_branch) // Restore label.
596 n->as_MachBranch()->label_set(saveL, save_bnum);
|
557 // Note that the scratch buffer blob and locs memory are
558 // allocated at the beginning of the compile task, and
559 // may be shared by several calls to scratch_emit_size.
560 // The allocation of the scratch buffer blob is particularly
561 // expensive, since it has to grab the code cache lock.
562 BufferBlob* blob = this->scratch_buffer_blob();
563 assert(blob != NULL, "Initialize BufferBlob at start");
564 assert(blob->size() > MAX_inst_size, "sanity");
565 relocInfo* locs_buf = scratch_locs_memory();
566 address blob_begin = blob->content_begin();
567 address blob_end = (address)locs_buf;
568 assert(blob->contains(blob_end), "sanity");
569 CodeBuffer buf(blob_begin, blob_end - blob_begin);
570 buf.initialize_consts_size(_scratch_const_size);
571 buf.initialize_stubs_size(MAX_stubs_size);
572 assert(locs_buf != NULL, "sanity");
573 int lsize = MAX_locs_size / 3;
574 buf.consts()->initialize_shared_locs(&locs_buf[lsize * 0], lsize);
575 buf.insts()->initialize_shared_locs( &locs_buf[lsize * 1], lsize);
576 buf.stubs()->initialize_shared_locs( &locs_buf[lsize * 2], lsize);
577 // Mark as scratch buffer.
578 buf.consts()->set_scratch_emit();
579 buf.insts()->set_scratch_emit();
580 buf.stubs()->set_scratch_emit();
581
582 // Do the emission.
583
584 Label fakeL; // Fake label for branch instructions.
585 Label* saveL = NULL;
586 uint save_bnum = 0;
587 bool is_branch = n->is_MachBranch();
588 if (is_branch) {
589 MacroAssembler masm(&buf);
590 masm.bind(fakeL);
591 n->as_MachBranch()->save_label(&saveL, &save_bnum);
592 n->as_MachBranch()->label_set(&fakeL, 0);
593 }
594 n->emit(buf, this->regalloc());
595
596 // Emitting into the scratch buffer should not fail
597 assert (!failing(), "Must not have pending failure. Reason is: %s", failure_reason());
598
599 if (is_branch) // Restore label.
600 n->as_MachBranch()->label_set(saveL, save_bnum);
|