365
366 const char* _name;
367
368 CodeSection _consts; // constants, jump tables
369 CodeSection _insts; // instructions (the main section)
370 CodeSection _stubs; // stubs (call site support), deopt, exception handling
371
372 CodeBuffer* _before_expand; // dead buffer, from before the last expansion
373
374 BufferBlob* _blob; // optional buffer in CodeCache for generated code
375 address _total_start; // first address of combined memory buffer
376 csize_t _total_size; // size in bytes of combined memory buffer
377
378 OopRecorder* _oop_recorder;
379 CodeStrings _code_strings;
380 OopRecorder _default_oop_recorder; // override with initialize_oop_recorder
381 Arena* _overflow_arena;
382
383 address _last_membar; // used to merge consecutive memory barriers
384
385 address _decode_begin; // start address for decode
386 address decode_begin();
387
388 void initialize_misc(const char * name) {
389 // all pointers other than code_start/end and those inside the sections
390 assert(name != NULL, "must have a name");
391 _name = name;
392 _before_expand = NULL;
393 _blob = NULL;
394 _oop_recorder = NULL;
395 _decode_begin = NULL;
396 _overflow_arena = NULL;
397 _code_strings = CodeStrings();
398 _last_membar = NULL;
399 }
400
401 void initialize(address code_start, csize_t code_size) {
402 _consts.initialize_outer(this, SECT_CONSTS);
403 _insts.initialize_outer(this, SECT_INSTS);
404 _stubs.initialize_outer(this, SECT_STUBS);
405 _total_start = code_start;
406 _total_size = code_size;
407 // Initialize the main section:
408 _insts.initialize(code_start, code_size);
409 assert(!_stubs.is_allocated(), "no garbage here");
410 assert(!_consts.is_allocated(), "no garbage here");
411 _oop_recorder = &_default_oop_recorder;
412 }
413
414 void initialize_section_size(CodeSection* cs, csize_t size);
415
416 void freeze_section(CodeSection* cs);
417
418 // helper for CodeBuffer::expand()
573 // allocated size of any and all recorded metadata
574 csize_t total_metadata_size() const {
575 OopRecorder* recorder = oop_recorder();
576 return (recorder == NULL)? 0: recorder->metadata_size();
577 }
578
579 // Configuration functions, called immediately after the CB is constructed.
580 // The section sizes are subtracted from the original insts section.
581 // Note: Call them in reverse section order, because each steals from insts.
582 void initialize_consts_size(csize_t size) { initialize_section_size(&_consts, size); }
583 void initialize_stubs_size(csize_t size) { initialize_section_size(&_stubs, size); }
584 // Override default oop recorder.
585 void initialize_oop_recorder(OopRecorder* r);
586
587 OopRecorder* oop_recorder() const { return _oop_recorder; }
588 CodeStrings& strings() { return _code_strings; }
589
590 address last_membar() const { return _last_membar; }
591 void set_last_membar(address a) { _last_membar = a; }
592 void clear_last_membar() { set_last_membar(NULL); }
593
594 void free_strings() {
595 if (!_code_strings.is_null()) {
596 _code_strings.free(); // sets _strings Null as a side-effect.
597 }
598 }
599
600 // Code generation
601 void relocate(address at, RelocationHolder const& rspec, int format = 0) {
602 _insts.relocate(at, rspec, format);
603 }
604 void relocate(address at, relocInfo::relocType rtype, int format = 0) {
605 _insts.relocate(at, rtype, format);
606 }
607
608 // Management of overflow storage for binding of Labels.
609 GrowableArray<int>* create_patch_overflow();
610
611 // NMethod generation
612 void copy_code_and_locs_to(CodeBlob* blob) {
|
365
366 const char* _name;
367
368 CodeSection _consts; // constants, jump tables
369 CodeSection _insts; // instructions (the main section)
370 CodeSection _stubs; // stubs (call site support), deopt, exception handling
371
372 CodeBuffer* _before_expand; // dead buffer, from before the last expansion
373
374 BufferBlob* _blob; // optional buffer in CodeCache for generated code
375 address _total_start; // first address of combined memory buffer
376 csize_t _total_size; // size in bytes of combined memory buffer
377
378 OopRecorder* _oop_recorder;
379 CodeStrings _code_strings;
380 OopRecorder _default_oop_recorder; // override with initialize_oop_recorder
381 Arena* _overflow_arena;
382
383 address _last_membar; // used to merge consecutive memory barriers
384
385 address _last_ldst; // used to merge consecutive memory loads and stores;
386
387 address _decode_begin; // start address for decode
388 address decode_begin();
389
390 void initialize_misc(const char * name) {
391 // all pointers other than code_start/end and those inside the sections
392 assert(name != NULL, "must have a name");
393 _name = name;
394 _before_expand = NULL;
395 _blob = NULL;
396 _oop_recorder = NULL;
397 _decode_begin = NULL;
398 _overflow_arena = NULL;
399 _code_strings = CodeStrings();
400 _last_membar = NULL;
401 _last_ldst = NULL;
402 }
403
404 void initialize(address code_start, csize_t code_size) {
405 _consts.initialize_outer(this, SECT_CONSTS);
406 _insts.initialize_outer(this, SECT_INSTS);
407 _stubs.initialize_outer(this, SECT_STUBS);
408 _total_start = code_start;
409 _total_size = code_size;
410 // Initialize the main section:
411 _insts.initialize(code_start, code_size);
412 assert(!_stubs.is_allocated(), "no garbage here");
413 assert(!_consts.is_allocated(), "no garbage here");
414 _oop_recorder = &_default_oop_recorder;
415 }
416
417 void initialize_section_size(CodeSection* cs, csize_t size);
418
419 void freeze_section(CodeSection* cs);
420
421 // helper for CodeBuffer::expand()
576 // allocated size of any and all recorded metadata
577 csize_t total_metadata_size() const {
578 OopRecorder* recorder = oop_recorder();
579 return (recorder == NULL)? 0: recorder->metadata_size();
580 }
581
582 // Configuration functions, called immediately after the CB is constructed.
583 // The section sizes are subtracted from the original insts section.
584 // Note: Call them in reverse section order, because each steals from insts.
585 void initialize_consts_size(csize_t size) { initialize_section_size(&_consts, size); }
586 void initialize_stubs_size(csize_t size) { initialize_section_size(&_stubs, size); }
587 // Override default oop recorder.
588 void initialize_oop_recorder(OopRecorder* r);
589
590 OopRecorder* oop_recorder() const { return _oop_recorder; }
591 CodeStrings& strings() { return _code_strings; }
592
593 address last_membar() const { return _last_membar; }
594 void set_last_membar(address a) { _last_membar = a; }
595 void clear_last_membar() { set_last_membar(NULL); }
596
597 address last_ldst() const { return _last_ldst; }
598 void set_last_ldst(address a) { _last_ldst = a; }
599 void clear_last_ldst() { set_last_ldst(NULL); }
600
601 void free_strings() {
602 if (!_code_strings.is_null()) {
603 _code_strings.free(); // sets _strings Null as a side-effect.
604 }
605 }
606
607 // Code generation
608 void relocate(address at, RelocationHolder const& rspec, int format = 0) {
609 _insts.relocate(at, rspec, format);
610 }
611 void relocate(address at, relocInfo::relocType rtype, int format = 0) {
612 _insts.relocate(at, rtype, format);
613 }
614
615 // Management of overflow storage for binding of Labels.
616 GrowableArray<int>* create_patch_overflow();
617
618 // NMethod generation
619 void copy_code_and_locs_to(CodeBlob* blob) {
|