1590 } |
1590 } |
1591 } |
1591 } |
1592 } |
1592 } |
1593 } |
1593 } |
1594 |
1594 |
|
1595 // Attempt to enlarge the array for per thread counters. |
|
1596 jlong* resize_counters_array(jlong* old_counters, int current_size, int new_size) { |
|
1597 jlong* new_counters = NEW_C_HEAP_ARRAY(jlong, new_size, mtJVMCI); |
|
1598 if (new_counters == NULL) { |
|
1599 return NULL; |
|
1600 } |
|
1601 if (old_counters == NULL) { |
|
1602 old_counters = new_counters; |
|
1603 memset(old_counters, 0, sizeof(jlong) * new_size); |
|
1604 } else { |
|
1605 for (int i = 0; i < MIN2((int) current_size, new_size); i++) { |
|
1606 new_counters[i] = old_counters[i]; |
|
1607 } |
|
1608 if (new_size > current_size) { |
|
1609 memset(new_counters + current_size, 0, sizeof(jlong) * (new_size - current_size)); |
|
1610 } |
|
1611 FREE_C_HEAP_ARRAY(jlong, old_counters); |
|
1612 } |
|
1613 return new_counters; |
|
1614 } |
|
1615 |
|
1616 // Attempt to enlarge the array for per thread counters. |
|
1617 bool JavaThread::resize_counters(int current_size, int new_size) { |
|
1618 jlong* new_counters = resize_counters_array(_jvmci_counters, current_size, new_size); |
|
1619 if (new_counters == NULL) { |
|
1620 return false; |
|
1621 } else { |
|
1622 _jvmci_counters = new_counters; |
|
1623 return true; |
|
1624 } |
|
1625 } |
|
1626 |
|
1627 class VM_JVMCIResizeCounters : public VM_Operation { |
|
1628 private: |
|
1629 int _new_size; |
|
1630 bool _failed; |
|
1631 |
|
1632 public: |
|
1633 VM_JVMCIResizeCounters(int new_size) : _new_size(new_size), _failed(false) { } |
|
1634 VMOp_Type type() const { return VMOp_JVMCIResizeCounters; } |
|
1635 bool allow_nested_vm_operations() const { return true; } |
|
1636 void doit() { |
|
1637 // Resize the old thread counters array |
|
1638 jlong* new_counters = resize_counters_array(JavaThread::_jvmci_old_thread_counters, JVMCICounterSize, _new_size); |
|
1639 if (new_counters == NULL) { |
|
1640 _failed = true; |
|
1641 return; |
|
1642 } else { |
|
1643 JavaThread::_jvmci_old_thread_counters = new_counters; |
|
1644 } |
|
1645 |
|
1646 // Now resize each threads array |
|
1647 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *tp = jtiwh.next(); ) { |
|
1648 if (!tp->resize_counters(JVMCICounterSize, _new_size)) { |
|
1649 _failed = true; |
|
1650 break; |
|
1651 } |
|
1652 } |
|
1653 if (!_failed) { |
|
1654 JVMCICounterSize = _new_size; |
|
1655 } |
|
1656 } |
|
1657 |
|
1658 bool failed() { return _failed; } |
|
1659 }; |
|
1660 |
|
1661 bool JavaThread::resize_all_jvmci_counters(int new_size) { |
|
1662 VM_JVMCIResizeCounters op(new_size); |
|
1663 VMThread::execute(&op); |
|
1664 return !op.failed(); |
|
1665 } |
|
1666 |
1595 #endif // INCLUDE_JVMCI |
1667 #endif // INCLUDE_JVMCI |
1596 |
1668 |
1597 // A JavaThread is a normal Java thread |
1669 // A JavaThread is a normal Java thread |
1598 |
1670 |
1599 void JavaThread::initialize() { |
1671 void JavaThread::initialize() { |
1628 _pending_failed_speculation = 0; |
1700 _pending_failed_speculation = 0; |
1629 _pending_transfer_to_interpreter = false; |
1701 _pending_transfer_to_interpreter = false; |
1630 _in_retryable_allocation = false; |
1702 _in_retryable_allocation = false; |
1631 _jvmci._alternate_call_target = NULL; |
1703 _jvmci._alternate_call_target = NULL; |
1632 assert(_jvmci._implicit_exception_pc == NULL, "must be"); |
1704 assert(_jvmci._implicit_exception_pc == NULL, "must be"); |
|
1705 _jvmci_counters = NULL; |
1633 if (JVMCICounterSize > 0) { |
1706 if (JVMCICounterSize > 0) { |
1634 _jvmci_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtInternal); |
1707 resize_counters(0, (int) JVMCICounterSize); |
1635 memset(_jvmci_counters, 0, sizeof(jlong) * JVMCICounterSize); |
|
1636 } else { |
|
1637 _jvmci_counters = NULL; |
|
1638 } |
1708 } |
1639 #endif // INCLUDE_JVMCI |
1709 #endif // INCLUDE_JVMCI |
1640 _reserved_stack_activation = NULL; // stack base not known yet |
1710 _reserved_stack_activation = NULL; // stack base not known yet |
1641 (void)const_cast<oop&>(_exception_oop = oop(NULL)); |
1711 (void)const_cast<oop&>(_exception_oop = oop(NULL)); |
1642 _exception_pc = 0; |
1712 _exception_pc = 0; |
3771 // Initialize global data structures and create system classes in heap |
3841 // Initialize global data structures and create system classes in heap |
3772 vm_init_globals(); |
3842 vm_init_globals(); |
3773 |
3843 |
3774 #if INCLUDE_JVMCI |
3844 #if INCLUDE_JVMCI |
3775 if (JVMCICounterSize > 0) { |
3845 if (JVMCICounterSize > 0) { |
3776 JavaThread::_jvmci_old_thread_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtInternal); |
3846 JavaThread::_jvmci_old_thread_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtJVMCI); |
3777 memset(JavaThread::_jvmci_old_thread_counters, 0, sizeof(jlong) * JVMCICounterSize); |
3847 memset(JavaThread::_jvmci_old_thread_counters, 0, sizeof(jlong) * JVMCICounterSize); |
3778 } else { |
3848 } else { |
3779 JavaThread::_jvmci_old_thread_counters = NULL; |
3849 JavaThread::_jvmci_old_thread_counters = NULL; |
3780 } |
3850 } |
3781 #endif // INCLUDE_JVMCI |
3851 #endif // INCLUDE_JVMCI |