7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "asm/assembler.inline.hpp"
27 #include "code/debugInfo.hpp"
28 #include "code/debugInfoRec.hpp"
29 #include "compiler/compileBroker.hpp"
30 #include "compiler/oopMap.hpp"
31 #include "memory/allocation.inline.hpp"
32 #include "opto/callnode.hpp"
33 #include "opto/cfgnode.hpp"
34 #include "opto/locknode.hpp"
35 #include "opto/machnode.hpp"
36 #include "opto/output.hpp"
37 #include "opto/regalloc.hpp"
38 #include "opto/runtime.hpp"
39 #include "opto/subnode.hpp"
40 #include "opto/type.hpp"
41 #include "runtime/handles.inline.hpp"
42 #include "utilities/xmlstream.hpp"
43
44 extern uint size_java_to_interp();
45 extern uint reloc_java_to_interp();
46 extern uint size_exception_handler();
47 extern uint size_deopt_handler();
48
49 #ifndef PRODUCT
50 #define DEBUG_ARG(x) , x
51 #else
52 #define DEBUG_ARG(x)
53 #endif
54
55 extern int emit_exception_handler(CodeBuffer &cbuf);
56 extern int emit_deopt_handler(CodeBuffer &cbuf);
57
58 //------------------------------Output-----------------------------------------
59 // Convert Nodes to instruction bits and pass off to the VM
60 void Compile::Output() {
61 // RootNode goes
62 assert( _cfg->_broot->_nodes.size() == 0, "" );
63
64 // The number of new nodes (mostly MachNop) is proportional to
65 // the number of java calls and inner loops which are aligned.
372 // During short branch replacement, we store the relative (to blk_starts)
373 // offset of jump in jmp_offset, rather than the absolute offset of jump.
374 // This is so that we do not need to recompute sizes of all nodes when
375 // we compute correct blk_starts in our next sizing pass.
376 jmp_offset[i] = 0;
377 jmp_size[i] = 0;
378 jmp_nidx[i] = -1;
379 DEBUG_ONLY( jmp_target[i] = 0; )
380 DEBUG_ONLY( jmp_rule[i] = 0; )
381
382 // Sum all instruction sizes to compute block size
383 uint last_inst = b->_nodes.size();
384 uint blk_size = 0;
385 for (uint j = 0; j < last_inst; j++) {
386 Node* nj = b->_nodes[j];
387 // Handle machine instruction nodes
388 if (nj->is_Mach()) {
389 MachNode *mach = nj->as_Mach();
390 blk_size += (mach->alignment_required() - 1) * relocInfo::addr_unit(); // assume worst case padding
391 reloc_size += mach->reloc();
392 if( mach->is_MachCall() ) {
393 MachCallNode *mcall = mach->as_MachCall();
394 // This destination address is NOT PC-relative
395
396 mcall->method_set((intptr_t)mcall->entry_point());
397
398 if( mcall->is_MachCallJava() && mcall->as_MachCallJava()->_method ) {
399 stub_size += size_java_to_interp();
400 reloc_size += reloc_java_to_interp();
401 }
402 } else if (mach->is_MachSafePoint()) {
403 // If call/safepoint are adjacent, account for possible
404 // nop to disambiguate the two safepoints.
405 // ScheduleAndBundle() can rearrange nodes in a block,
406 // check for all offsets inside this block.
407 if (last_call_adr >= blk_starts[i]) {
408 blk_size += nop_size;
409 }
410 }
411 if (mach->avoid_back_to_back()) {
412 // Nop is inserted between "avoid back to back" instructions.
413 // ScheduleAndBundle() can rearrange nodes in a block,
414 // check for all offsets inside this block.
415 if (last_avoid_back_to_back_adr >= blk_starts[i]) {
416 blk_size += nop_size;
417 }
418 }
419 if (mach->may_be_short_branch()) {
420 if (!nj->is_MachBranch()) {
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "asm/assembler.inline.hpp"
27 #include "code/compiledIC.hpp"
28 #include "code/debugInfo.hpp"
29 #include "code/debugInfoRec.hpp"
30 #include "compiler/compileBroker.hpp"
31 #include "compiler/oopMap.hpp"
32 #include "memory/allocation.inline.hpp"
33 #include "opto/callnode.hpp"
34 #include "opto/cfgnode.hpp"
35 #include "opto/locknode.hpp"
36 #include "opto/machnode.hpp"
37 #include "opto/output.hpp"
38 #include "opto/regalloc.hpp"
39 #include "opto/runtime.hpp"
40 #include "opto/subnode.hpp"
41 #include "opto/type.hpp"
42 #include "runtime/handles.inline.hpp"
43 #include "utilities/xmlstream.hpp"
44
45 extern uint size_exception_handler();
46 extern uint size_deopt_handler();
47
48 #ifndef PRODUCT
49 #define DEBUG_ARG(x) , x
50 #else
51 #define DEBUG_ARG(x)
52 #endif
53
54 extern int emit_exception_handler(CodeBuffer &cbuf);
55 extern int emit_deopt_handler(CodeBuffer &cbuf);
56
57 //------------------------------Output-----------------------------------------
58 // Convert Nodes to instruction bits and pass off to the VM
59 void Compile::Output() {
60 // RootNode goes
61 assert( _cfg->_broot->_nodes.size() == 0, "" );
62
63 // The number of new nodes (mostly MachNop) is proportional to
64 // the number of java calls and inner loops which are aligned.
371 // During short branch replacement, we store the relative (to blk_starts)
372 // offset of jump in jmp_offset, rather than the absolute offset of jump.
373 // This is so that we do not need to recompute sizes of all nodes when
374 // we compute correct blk_starts in our next sizing pass.
375 jmp_offset[i] = 0;
376 jmp_size[i] = 0;
377 jmp_nidx[i] = -1;
378 DEBUG_ONLY( jmp_target[i] = 0; )
379 DEBUG_ONLY( jmp_rule[i] = 0; )
380
381 // Sum all instruction sizes to compute block size
382 uint last_inst = b->_nodes.size();
383 uint blk_size = 0;
384 for (uint j = 0; j < last_inst; j++) {
385 Node* nj = b->_nodes[j];
386 // Handle machine instruction nodes
387 if (nj->is_Mach()) {
388 MachNode *mach = nj->as_Mach();
389 blk_size += (mach->alignment_required() - 1) * relocInfo::addr_unit(); // assume worst case padding
390 reloc_size += mach->reloc();
391 if (mach->is_MachCall()) {
392 MachCallNode *mcall = mach->as_MachCall();
393 // This destination address is NOT PC-relative
394
395 mcall->method_set((intptr_t)mcall->entry_point());
396
397 if (mcall->is_MachCallJava() && mcall->as_MachCallJava()->_method) {
398 stub_size += CompiledStaticCall::to_interp_stub_size();
399 reloc_size += CompiledStaticCall::reloc_to_interp_stub();
400 }
401 } else if (mach->is_MachSafePoint()) {
402 // If call/safepoint are adjacent, account for possible
403 // nop to disambiguate the two safepoints.
404 // ScheduleAndBundle() can rearrange nodes in a block,
405 // check for all offsets inside this block.
406 if (last_call_adr >= blk_starts[i]) {
407 blk_size += nop_size;
408 }
409 }
410 if (mach->avoid_back_to_back()) {
411 // Nop is inserted between "avoid back to back" instructions.
412 // ScheduleAndBundle() can rearrange nodes in a block,
413 // check for all offsets inside this block.
414 if (last_avoid_back_to_back_adr >= blk_starts[i]) {
415 blk_size += nop_size;
416 }
417 }
418 if (mach->may_be_short_branch()) {
419 if (!nj->is_MachBranch()) {
|