Mercurial > hg > graal-jvmci-8
comparison src/share/vm/asm/assembler.cpp @ 7198:6ab62ad83507
8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
Reviewed-by: twisti, kvn
Contributed-by: Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
author | twisti |
---|---|
date | Fri, 30 Nov 2012 11:44:05 -0800 |
parents | 1acccb7c0b01 |
children | cd3d6a6b95d9 |
comparison
equal
deleted
inserted
replaced
7197:1acccb7c0b01 | 7198:6ab62ad83507 |
---|---|
54 | 54 |
55 AbstractAssembler::AbstractAssembler(CodeBuffer* code) { | 55 AbstractAssembler::AbstractAssembler(CodeBuffer* code) { |
56 if (code == NULL) return; | 56 if (code == NULL) return; |
57 CodeSection* cs = code->insts(); | 57 CodeSection* cs = code->insts(); |
58 cs->clear_mark(); // new assembler kills old mark | 58 cs->clear_mark(); // new assembler kills old mark |
59 if (cs->start() == NULL) { | |
60 vm_exit_out_of_memory(0, err_msg("CodeCache: no room for %s", | |
61 code->name())); | |
62 } | |
59 _code_section = cs; | 63 _code_section = cs; |
60 _code_begin = cs->start(); | |
61 _code_limit = cs->limit(); | |
62 _code_pos = cs->end(); | |
63 _oop_recorder= code->oop_recorder(); | 64 _oop_recorder= code->oop_recorder(); |
64 DEBUG_ONLY( _short_branch_delta = 0; ) | 65 DEBUG_ONLY( _short_branch_delta = 0; ) |
65 if (_code_begin == NULL) { | |
66 vm_exit_out_of_memory(0, err_msg("CodeCache: no room for %s", | |
67 code->name())); | |
68 } | |
69 } | 66 } |
70 | 67 |
71 void AbstractAssembler::set_code_section(CodeSection* cs) { | 68 void AbstractAssembler::set_code_section(CodeSection* cs) { |
72 assert(cs->outer() == code_section()->outer(), "sanity"); | 69 assert(cs->outer() == code_section()->outer(), "sanity"); |
73 assert(cs->is_allocated(), "need to pre-allocate this section"); | 70 assert(cs->is_allocated(), "need to pre-allocate this section"); |
74 cs->clear_mark(); // new assembly into this section kills old mark | 71 cs->clear_mark(); // new assembly into this section kills old mark |
75 _code_section = cs; | 72 _code_section = cs; |
76 _code_begin = cs->start(); | |
77 _code_limit = cs->limit(); | |
78 _code_pos = cs->end(); | |
79 } | 73 } |
80 | 74 |
81 // Inform CodeBuffer that incoming code and relocation will be for stubs | 75 // Inform CodeBuffer that incoming code and relocation will be for stubs |
82 address AbstractAssembler::start_a_stub(int required_space) { | 76 address AbstractAssembler::start_a_stub(int required_space) { |
83 CodeBuffer* cb = code(); | 77 CodeBuffer* cb = code(); |
84 CodeSection* cs = cb->stubs(); | 78 CodeSection* cs = cb->stubs(); |
85 assert(_code_section == cb->insts(), "not in insts?"); | 79 assert(_code_section == cb->insts(), "not in insts?"); |
86 sync(); | |
87 if (cs->maybe_expand_to_ensure_remaining(required_space) | 80 if (cs->maybe_expand_to_ensure_remaining(required_space) |
88 && cb->blob() == NULL) { | 81 && cb->blob() == NULL) { |
89 return NULL; | 82 return NULL; |
90 } | 83 } |
91 set_code_section(cs); | 84 set_code_section(cs); |
94 | 87 |
95 // Inform CodeBuffer that incoming code and relocation will be code | 88 // Inform CodeBuffer that incoming code and relocation will be code |
96 // Should not be called if start_a_stub() returned NULL | 89 // Should not be called if start_a_stub() returned NULL |
97 void AbstractAssembler::end_a_stub() { | 90 void AbstractAssembler::end_a_stub() { |
98 assert(_code_section == code()->stubs(), "not in stubs?"); | 91 assert(_code_section == code()->stubs(), "not in stubs?"); |
99 sync(); | |
100 set_code_section(code()->insts()); | 92 set_code_section(code()->insts()); |
101 } | 93 } |
102 | 94 |
103 // Inform CodeBuffer that incoming code and relocation will be for stubs | 95 // Inform CodeBuffer that incoming code and relocation will be for stubs |
104 address AbstractAssembler::start_a_const(int required_space, int required_align) { | 96 address AbstractAssembler::start_a_const(int required_space, int required_align) { |
105 CodeBuffer* cb = code(); | 97 CodeBuffer* cb = code(); |
106 CodeSection* cs = cb->consts(); | 98 CodeSection* cs = cb->consts(); |
107 assert(_code_section == cb->insts() || _code_section == cb->stubs(), "not in insts/stubs?"); | 99 assert(_code_section == cb->insts() || _code_section == cb->stubs(), "not in insts/stubs?"); |
108 sync(); | |
109 address end = cs->end(); | 100 address end = cs->end(); |
110 int pad = -(intptr_t)end & (required_align-1); | 101 int pad = -(intptr_t)end & (required_align-1); |
111 if (cs->maybe_expand_to_ensure_remaining(pad + required_space)) { | 102 if (cs->maybe_expand_to_ensure_remaining(pad + required_space)) { |
112 if (cb->blob() == NULL) return NULL; | 103 if (cb->blob() == NULL) return NULL; |
113 end = cs->end(); // refresh pointer | 104 end = cs->end(); // refresh pointer |
122 | 113 |
123 // Inform CodeBuffer that incoming code and relocation will be code | 114 // Inform CodeBuffer that incoming code and relocation will be code |
124 // in section cs (insts or stubs). | 115 // in section cs (insts or stubs). |
125 void AbstractAssembler::end_a_const(CodeSection* cs) { | 116 void AbstractAssembler::end_a_const(CodeSection* cs) { |
126 assert(_code_section == code()->consts(), "not in consts?"); | 117 assert(_code_section == code()->consts(), "not in consts?"); |
127 sync(); | |
128 set_code_section(cs); | 118 set_code_section(cs); |
129 } | 119 } |
130 | 120 |
131 void AbstractAssembler::flush() { | 121 void AbstractAssembler::flush() { |
132 sync(); | |
133 ICache::invalidate_range(addr_at(0), offset()); | 122 ICache::invalidate_range(addr_at(0), offset()); |
134 } | 123 } |
135 | 124 |
136 | 125 |
137 void AbstractAssembler::a_byte(int x) { | 126 void AbstractAssembler::a_byte(int x) { |