comparison src/cpu/x86/vm/templateTable_x86_64.cpp @ 10105:aeaca88565e6

8010862: The Method counter fields used for profiling can be allocated lazily. Summary: Allocate the method's profiling related metadata until they are needed. Reviewed-by: coleenp, roland
author jiangli
date Tue, 09 Apr 2013 17:17:41 -0400
parents db9981fd3124
children 9500809ceead
comparison
equal deleted inserted replaced
9055:dcdeb150988c 10105:aeaca88565e6
1 /* 1 /*
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2003, 2013, 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.
1562 void TemplateTable::branch(bool is_jsr, bool is_wide) { 1562 void TemplateTable::branch(bool is_jsr, bool is_wide) {
1563 __ get_method(rcx); // rcx holds method 1563 __ get_method(rcx); // rcx holds method
1564 __ profile_taken_branch(rax, rbx); // rax holds updated MDP, rbx 1564 __ profile_taken_branch(rax, rbx); // rax holds updated MDP, rbx
1565 // holds bumped taken count 1565 // holds bumped taken count
1566 1566
1567 const ByteSize be_offset = Method::backedge_counter_offset() + 1567 const ByteSize be_offset = MethodCounters::backedge_counter_offset() +
1568 InvocationCounter::counter_offset(); 1568 InvocationCounter::counter_offset();
1569 const ByteSize inv_offset = Method::invocation_counter_offset() + 1569 const ByteSize inv_offset = MethodCounters::invocation_counter_offset() +
1570 InvocationCounter::counter_offset(); 1570 InvocationCounter::counter_offset();
1571 const int method_offset = frame::interpreter_frame_method_offset * wordSize;
1572 1571
1573 // Load up edx with the branch displacement 1572 // Load up edx with the branch displacement
1574 __ movl(rdx, at_bcp(1)); 1573 __ movl(rdx, at_bcp(1));
1575 __ bswapl(rdx); 1574 __ bswapl(rdx);
1576 1575
1616 // rdx: target offset 1615 // rdx: target offset
1617 // r13: target bcp 1616 // r13: target bcp
1618 // r14: locals pointer 1617 // r14: locals pointer
1619 __ testl(rdx, rdx); // check if forward or backward branch 1618 __ testl(rdx, rdx); // check if forward or backward branch
1620 __ jcc(Assembler::positive, dispatch); // count only if backward branch 1619 __ jcc(Assembler::positive, dispatch); // count only if backward branch
1620
1621 // check if MethodCounters exists
1622 Label has_counters;
1623 __ movptr(rax, Address(rcx, Method::method_counters_offset()));
1624 __ testptr(rax, rax);
1625 __ jcc(Assembler::notZero, has_counters);
1626 __ push(rdx);
1627 __ push(rcx);
1628 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::build_method_counters),
1629 rcx);
1630 __ pop(rcx);
1631 __ pop(rdx);
1632 __ movptr(rax, Address(rcx, Method::method_counters_offset()));
1633 __ jcc(Assembler::zero, dispatch);
1634 __ bind(has_counters);
1635
1621 if (TieredCompilation) { 1636 if (TieredCompilation) {
1622 Label no_mdo; 1637 Label no_mdo;
1623 int increment = InvocationCounter::count_increment; 1638 int increment = InvocationCounter::count_increment;
1624 int mask = ((1 << Tier0BackedgeNotifyFreqLog) - 1) << InvocationCounter::count_shift; 1639 int mask = ((1 << Tier0BackedgeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
1625 if (ProfileInterpreter) { 1640 if (ProfileInterpreter) {
1633 __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, 1648 __ increment_mask_and_jump(mdo_backedge_counter, increment, mask,
1634 rax, false, Assembler::zero, &backedge_counter_overflow); 1649 rax, false, Assembler::zero, &backedge_counter_overflow);
1635 __ jmp(dispatch); 1650 __ jmp(dispatch);
1636 } 1651 }
1637 __ bind(no_mdo); 1652 __ bind(no_mdo);
1638 // Increment backedge counter in Method* 1653 // Increment backedge counter in MethodCounters*
1654 __ movptr(rcx, Address(rcx, Method::method_counters_offset()));
1639 __ increment_mask_and_jump(Address(rcx, be_offset), increment, mask, 1655 __ increment_mask_and_jump(Address(rcx, be_offset), increment, mask,
1640 rax, false, Assembler::zero, &backedge_counter_overflow); 1656 rax, false, Assembler::zero, &backedge_counter_overflow);
1641 } else { 1657 } else {
1642 // increment counter 1658 // increment counter
1659 __ movptr(rcx, Address(rcx, Method::method_counters_offset()));
1643 __ movl(rax, Address(rcx, be_offset)); // load backedge counter 1660 __ movl(rax, Address(rcx, be_offset)); // load backedge counter
1644 __ incrementl(rax, InvocationCounter::count_increment); // increment counter 1661 __ incrementl(rax, InvocationCounter::count_increment); // increment counter
1645 __ movl(Address(rcx, be_offset), rax); // store counter 1662 __ movl(Address(rcx, be_offset), rax); // store counter
1646 1663
1647 __ movl(rax, Address(rcx, inv_offset)); // load invocation counter 1664 __ movl(rax, Address(rcx, inv_offset)); // load invocation counter
1665
1648 __ andl(rax, InvocationCounter::count_mask_value); // and the status bits 1666 __ andl(rax, InvocationCounter::count_mask_value); // and the status bits
1649 __ addl(rax, Address(rcx, be_offset)); // add both counters 1667 __ addl(rax, Address(rcx, be_offset)); // add both counters
1650 1668
1651 if (ProfileInterpreter) { 1669 if (ProfileInterpreter) {
1652 // Test to see if we should create a method data oop 1670 // Test to see if we should create a method data oop