src/hotspot/share/opto/output.cpp
changeset 54960 e46fe26d7f77
parent 53975 b31780c0c4c9
child 55341 c63b9b87c28a
child 58678 9cf78a70fa4f
equal deleted inserted replaced
54959:00425a850a2f 54960:e46fe26d7f77
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
  1104   uint* jmp_size   = NEW_RESOURCE_ARRAY(uint,nblocks);
  1104   uint* jmp_size   = NEW_RESOURCE_ARRAY(uint,nblocks);
  1105   uint* jmp_rule   = NEW_RESOURCE_ARRAY(uint,nblocks);
  1105   uint* jmp_rule   = NEW_RESOURCE_ARRAY(uint,nblocks);
  1106 #endif
  1106 #endif
  1107 
  1107 
  1108   // Create an array of unused labels, one for each basic block, if printing is enabled
  1108   // Create an array of unused labels, one for each basic block, if printing is enabled
  1109 #ifndef PRODUCT
  1109 #if defined(SUPPORT_OPTO_ASSEMBLY)
  1110   int *node_offsets      = NULL;
  1110   int *node_offsets      = NULL;
  1111   uint node_offset_limit = unique();
  1111   uint node_offset_limit = unique();
  1112 
  1112 
  1113   if (print_assembly())
  1113   if (print_assembly()) {
  1114     node_offsets         = NEW_RESOURCE_ARRAY(int, node_offset_limit);
  1114     node_offsets = NEW_RESOURCE_ARRAY(int, node_offset_limit);
       
  1115   }
       
  1116   if (node_offsets != NULL) {
       
  1117     // We need to initialize. Unused array elements may contain garbage and mess up PrintOptoAssembly.
       
  1118     memset(node_offsets, 0, node_offset_limit*sizeof(int));
       
  1119   }
  1115 #endif
  1120 #endif
  1116 
  1121 
  1117   NonSafepointEmitter non_safepoints(this);  // emit non-safepoints lazily
  1122   NonSafepointEmitter non_safepoints(this);  // emit non-safepoints lazily
  1118 
  1123 
  1119   // Emit the constant table.
  1124   // Emit the constant table.
  1379         C->record_failure("CodeCache is full");
  1384         C->record_failure("CodeCache is full");
  1380         return;
  1385         return;
  1381       }
  1386       }
  1382 
  1387 
  1383       // Save the offset for the listing
  1388       // Save the offset for the listing
  1384 #ifndef PRODUCT
  1389 #if defined(SUPPORT_OPTO_ASSEMBLY)
  1385       if (node_offsets && n->_idx < node_offset_limit)
  1390       if ((node_offsets != NULL) && (n->_idx < node_offset_limit)) {
  1386         node_offsets[n->_idx] = cb->insts_size();
  1391         node_offsets[n->_idx] = cb->insts_size();
       
  1392       }
  1387 #endif
  1393 #endif
  1388 
  1394 
  1389       // "Normal" instruction case
  1395       // "Normal" instruction case
  1390       DEBUG_ONLY( uint instr_offset = cb->insts_size(); )
  1396       DEBUG_ONLY( uint instr_offset = cb->insts_size(); )
  1391       n->emit(*cb, _regalloc);
  1397       n->emit(*cb, _regalloc);
  1428 
  1434 
  1429         // Back up 1 instruction
  1435         // Back up 1 instruction
  1430         cb->set_insts_end(cb->insts_end() - Pipeline::instr_unit_size());
  1436         cb->set_insts_end(cb->insts_end() - Pipeline::instr_unit_size());
  1431 
  1437 
  1432         // Save the offset for the listing
  1438         // Save the offset for the listing
  1433 #ifndef PRODUCT
  1439 #if defined(SUPPORT_OPTO_ASSEMBLY)
  1434         if (node_offsets && delay_slot->_idx < node_offset_limit)
  1440         if ((node_offsets != NULL) && (delay_slot->_idx < node_offset_limit)) {
  1435           node_offsets[delay_slot->_idx] = cb->insts_size();
  1441           node_offsets[delay_slot->_idx] = cb->insts_size();
       
  1442         }
  1436 #endif
  1443 #endif
  1437 
  1444 
  1438         // Support a SafePoint in the delay slot
  1445         // Support a SafePoint in the delay slot
  1439         if (delay_slot->is_MachSafePoint()) {
  1446         if (delay_slot->is_MachSafePoint()) {
  1440           MachNode *mach = delay_slot->as_Mach();
  1447           MachNode *mach = delay_slot->as_Mach();
  1539   if ((cb->blob() == NULL) || (!CompileBroker::should_compile_new_jobs())) {
  1546   if ((cb->blob() == NULL) || (!CompileBroker::should_compile_new_jobs())) {
  1540     C->record_failure("CodeCache is full");
  1547     C->record_failure("CodeCache is full");
  1541     return;
  1548     return;
  1542   }
  1549   }
  1543 
  1550 
  1544 #ifndef PRODUCT
  1551 #if defined(SUPPORT_ABSTRACT_ASSEMBLY) || defined(SUPPORT_ASSEMBLY) || defined(SUPPORT_OPTO_ASSEMBLY)
       
  1552   if (print_assembly()) {
       
  1553     tty->cr();
       
  1554     tty->print_cr("============================= C2-compiled nmethod ==============================");
       
  1555   }
       
  1556 #endif
       
  1557 
       
  1558 #if defined(SUPPORT_OPTO_ASSEMBLY)
  1545   // Dump the assembly code, including basic-block numbers
  1559   // Dump the assembly code, including basic-block numbers
  1546   if (print_assembly()) {
  1560   if (print_assembly()) {
  1547     ttyLocker ttyl;  // keep the following output all in one block
  1561     ttyLocker ttyl;  // keep the following output all in one block
  1548     if (!VMThread::should_terminate()) {  // test this under the tty lock
  1562     if (!VMThread::should_terminate()) {  // test this under the tty lock
  1549       // This output goes directly to the tty, not the compiler log.
  1563       // This output goes directly to the tty, not the compiler log.
  1553         xtty->head("opto_assembly compile_id='%d'%s", compile_id(),
  1567         xtty->head("opto_assembly compile_id='%d'%s", compile_id(),
  1554                    is_osr_compilation()    ? " compile_kind='osr'" :
  1568                    is_osr_compilation()    ? " compile_kind='osr'" :
  1555                    "");
  1569                    "");
  1556       }
  1570       }
  1557       if (method() != NULL) {
  1571       if (method() != NULL) {
       
  1572         tty->print_cr("----------------------------------- MetaData -----------------------------------");
  1558         method()->print_metadata();
  1573         method()->print_metadata();
  1559       } else if (stub_name() != NULL) {
  1574       } else if (stub_name() != NULL) {
  1560         tty->print_cr("Generating RuntimeStub - %s", stub_name());
  1575         tty->print_cr("----------------------------- RuntimeStub %s -------------------------------", stub_name());
  1561       }
  1576       }
       
  1577       tty->cr();
       
  1578       tty->print_cr("--------------------------------- OptoAssembly ---------------------------------");
  1562       dump_asm(node_offsets, node_offset_limit);
  1579       dump_asm(node_offsets, node_offset_limit);
       
  1580       tty->print_cr("--------------------------------------------------------------------------------");
  1563       if (xtty != NULL) {
  1581       if (xtty != NULL) {
  1564         // print_metadata and dump_asm above may safepoint which makes us loose the ttylock.
  1582         // print_metadata and dump_asm above may safepoint which makes us loose the ttylock.
  1565         // Retake lock too make sure the end tag is coherent, and that xmlStream->pop_tag is done
  1583         // Retake lock too make sure the end tag is coherent, and that xmlStream->pop_tag is done
  1566         // thread safe
  1584         // thread safe
  1567         ttyLocker ttyl2;
  1585         ttyLocker ttyl2;
  1568         xtty->tail("opto_assembly");
  1586         xtty->tail("opto_assembly");
  1569       }
  1587       }
  1570     }
  1588     }
  1571   }
  1589   }
  1572 #endif
  1590 #endif
  1573 
       
  1574 }
  1591 }
  1575 
  1592 
  1576 void Compile::FillExceptionTables(uint cnt, uint *call_returns, uint *inct_starts, Label *blk_labels) {
  1593 void Compile::FillExceptionTables(uint cnt, uint *call_returns, uint *inct_starts, Label *blk_labels) {
  1577   _inc_table.set_size(cnt);
  1594   _inc_table.set_size(cnt);
  1578 
  1595