435
436 public:
437 // (1) code buffer referring to pre-allocated instruction memory
438 CodeBuffer(address code_start, csize_t code_size) {
439 assert(code_start != NULL, "sanity");
440 initialize_misc("static buffer");
441 initialize(code_start, code_size);
442 verify_section_allocation();
443 }
444
445 // (2) CodeBuffer referring to pre-allocated CodeBlob.
446 CodeBuffer(CodeBlob* blob);
447
448 // (3) code buffer allocating codeBlob memory for code & relocation
449 // info but with lazy initialization. The name must be something
450 // informative.
451 CodeBuffer(const char* name) {
452 initialize_misc(name);
453 }
454
455
456 // (4) code buffer allocating codeBlob memory for code & relocation
457 // info. The name must be something informative and code_size must
458 // include both code and stubs sizes.
459 CodeBuffer(const char* name, csize_t code_size, csize_t locs_size) {
460 initialize_misc(name);
461 initialize(code_size, locs_size);
462 }
463
464 ~CodeBuffer();
465
466 // Initialize a CodeBuffer constructed using constructor 3. Using
467 // constructor 4 is equivalent to calling constructor 3 and then
468 // calling this method. It's been factored out for convenience of
469 // construction.
470 void initialize(csize_t code_size, csize_t locs_size);
471
472 CodeSection* consts() { return &_consts; }
473 CodeSection* insts() { return &_insts; }
474 CodeSection* stubs() { return &_stubs; }
475
536
537 // is a given address in the insts section? (2nd version is end-inclusive)
538 bool insts_contains(address pc) const { return _insts.contains(pc); }
539 bool insts_contains2(address pc) const { return _insts.contains2(pc); }
540
541 // Record any extra oops required to keep embedded metadata alive
542 void finalize_oop_references(methodHandle method);
543
544 // Allocated size in all sections, when aligned and concatenated
545 // (this is the eventual state of the content in its final
546 // CodeBlob).
547 csize_t total_content_size() const;
548
549 // Combined offset (relative to start of first section) of given
550 // section, as eventually found in the final CodeBlob.
551 csize_t total_offset_of(CodeSection* cs) const;
552
553 // allocated size of all relocation data, including index, rounded up
554 csize_t total_relocation_size() const;
555
556 // allocated size of any and all recorded oops
557 csize_t total_oop_size() const {
558 OopRecorder* recorder = oop_recorder();
559 return (recorder == NULL)? 0: recorder->oop_size();
560 }
561
562 // allocated size of any and all recorded metadata
563 csize_t total_metadata_size() const {
564 OopRecorder* recorder = oop_recorder();
565 return (recorder == NULL)? 0: recorder->metadata_size();
566 }
567
568 // Configuration functions, called immediately after the CB is constructed.
569 // The section sizes are subtracted from the original insts section.
570 // Note: Call them in reverse section order, because each steals from insts.
571 void initialize_consts_size(csize_t size) { initialize_section_size(&_consts, size); }
572 void initialize_stubs_size(csize_t size) { initialize_section_size(&_stubs, size); }
573 // Override default oop recorder.
574 void initialize_oop_recorder(OopRecorder* r);
575
|
435
436 public:
437 // (1) code buffer referring to pre-allocated instruction memory
438 CodeBuffer(address code_start, csize_t code_size) {
439 assert(code_start != NULL, "sanity");
440 initialize_misc("static buffer");
441 initialize(code_start, code_size);
442 verify_section_allocation();
443 }
444
445 // (2) CodeBuffer referring to pre-allocated CodeBlob.
446 CodeBuffer(CodeBlob* blob);
447
448 // (3) code buffer allocating codeBlob memory for code & relocation
449 // info but with lazy initialization. The name must be something
450 // informative.
451 CodeBuffer(const char* name) {
452 initialize_misc(name);
453 }
454
455 // (4) code buffer allocating codeBlob memory for code & relocation
456 // info. The name must be something informative and code_size must
457 // include both code and stubs sizes.
458 CodeBuffer(const char* name, csize_t code_size, csize_t locs_size) {
459 initialize_misc(name);
460 initialize(code_size, locs_size);
461 }
462
463 ~CodeBuffer();
464
465 // Initialize a CodeBuffer constructed using constructor 3. Using
466 // constructor 4 is equivalent to calling constructor 3 and then
467 // calling this method. It's been factored out for convenience of
468 // construction.
469 void initialize(csize_t code_size, csize_t locs_size);
470
471 CodeSection* consts() { return &_consts; }
472 CodeSection* insts() { return &_insts; }
473 CodeSection* stubs() { return &_stubs; }
474
535
536 // is a given address in the insts section? (2nd version is end-inclusive)
537 bool insts_contains(address pc) const { return _insts.contains(pc); }
538 bool insts_contains2(address pc) const { return _insts.contains2(pc); }
539
540 // Record any extra oops required to keep embedded metadata alive
541 void finalize_oop_references(methodHandle method);
542
543 // Allocated size in all sections, when aligned and concatenated
544 // (this is the eventual state of the content in its final
545 // CodeBlob).
546 csize_t total_content_size() const;
547
548 // Combined offset (relative to start of first section) of given
549 // section, as eventually found in the final CodeBlob.
550 csize_t total_offset_of(CodeSection* cs) const;
551
552 // allocated size of all relocation data, including index, rounded up
553 csize_t total_relocation_size() const;
554
555 csize_t copy_relocations_to(address buf, csize_t buf_limit, bool only_inst) const;
556
557 // allocated size of any and all recorded oops
558 csize_t total_oop_size() const {
559 OopRecorder* recorder = oop_recorder();
560 return (recorder == NULL)? 0: recorder->oop_size();
561 }
562
563 // allocated size of any and all recorded metadata
564 csize_t total_metadata_size() const {
565 OopRecorder* recorder = oop_recorder();
566 return (recorder == NULL)? 0: recorder->metadata_size();
567 }
568
569 // Configuration functions, called immediately after the CB is constructed.
570 // The section sizes are subtracted from the original insts section.
571 // Note: Call them in reverse section order, because each steals from insts.
572 void initialize_consts_size(csize_t size) { initialize_section_size(&_consts, size); }
573 void initialize_stubs_size(csize_t size) { initialize_section_size(&_stubs, size); }
574 // Override default oop recorder.
575 void initialize_oop_recorder(OopRecorder* r);
576
|