From 92b1c17c8ea24ae4e250ac4d13ce6bd98cde71cd Mon Sep 17 00:00:00 2001 From: never Date: Fri, 21 Jan 2011 13:01:02 -0800 Subject: [PATCH] 6809483: hotspot:::method_entry are not correctly generated for "method()V" Reviewed-by: iveresov, twisti --- src/share/vm/c1/c1_Canonicalizer.cpp | 4 +-- src/share/vm/c1/c1_Canonicalizer.hpp | 3 +- src/share/vm/c1/c1_GraphBuilder.cpp | 21 ++++++++++++- src/share/vm/c1/c1_Instruction.hpp | 36 ++++++++++++++++++++++- src/share/vm/c1/c1_InstructionPrinter.cpp | 11 ++++++- src/share/vm/c1/c1_InstructionPrinter.hpp | 3 +- src/share/vm/c1/c1_LIRGenerator.cpp | 27 ++++++++++++++++- src/share/vm/c1/c1_LIRGenerator.hpp | 3 +- src/share/vm/c1/c1_Optimizer.cpp | 4 ++- src/share/vm/c1/c1_ValueMap.hpp | 5 ++-- 10 files changed, 105 insertions(+), 12 deletions(-) diff --git a/src/share/vm/c1/c1_Canonicalizer.cpp b/src/share/vm/c1/c1_Canonicalizer.cpp index 56a254c77..a2d400940 100644 --- a/src/share/vm/c1/c1_Canonicalizer.cpp +++ b/src/share/vm/c1/c1_Canonicalizer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -898,4 +898,4 @@ void Canonicalizer::do_UnsafePrefetchRead (UnsafePrefetchRead* x) {} void Canonicalizer::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {} void Canonicalizer::do_ProfileCall(ProfileCall* x) {} void Canonicalizer::do_ProfileInvoke(ProfileInvoke* x) {} - +void Canonicalizer::do_RuntimeCall(RuntimeCall* x) {} diff --git a/src/share/vm/c1/c1_Canonicalizer.hpp b/src/share/vm/c1/c1_Canonicalizer.hpp index e784fc953..c5048c7b4 100644 --- a/src/share/vm/c1/c1_Canonicalizer.hpp +++ b/src/share/vm/c1/c1_Canonicalizer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,6 +102,7 @@ class Canonicalizer: InstructionVisitor { virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); virtual void do_ProfileCall (ProfileCall* x); virtual void do_ProfileInvoke (ProfileInvoke* x); + virtual void do_RuntimeCall (RuntimeCall* x); }; #endif // SHARE_VM_C1_C1_CANONICALIZER_HPP diff --git a/src/share/vm/c1/c1_GraphBuilder.cpp b/src/share/vm/c1/c1_GraphBuilder.cpp index 1aa2cc00a..07435b7fa 100644 --- a/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/src/share/vm/c1/c1_GraphBuilder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1396,6 +1396,13 @@ void GraphBuilder::method_return(Value x) { if (continuation() != NULL) { assert(!method()->is_synchronized() || InlineSynchronizedMethods, "can not inline synchronized methods yet"); + if (compilation()->env()->dtrace_method_probes()) { + // Report exit from inline methods + Values* args = new Values(1); + args->push(append(new Constant(new ObjectConstant(method())))); + append(new RuntimeCall(voidType, "dtrace_method_exit", CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), args)); + } + // If the inlined method is synchronized, the monitor must be // released before we jump to the continuation block. if (method()->is_synchronized()) { @@ -3301,6 +3308,13 @@ void GraphBuilder::fill_sync_handler(Value lock, BlockBegin* sync_handler, bool Value exception = append_with_bci(new ExceptionObject(), SynchronizationEntryBCI); assert(exception->is_pinned(), "must be"); + if (compilation()->env()->dtrace_method_probes()) { + // Report exit from inline methods + Values* args = new Values(1); + args->push(append(new Constant(new ObjectConstant(method())))); + append(new RuntimeCall(voidType, "dtrace_method_exit", CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), args)); + } + int bci = SynchronizationEntryBCI; if (lock) { assert(state()->locks_size() > 0 && state()->lock_at(state()->locks_size() - 1) == lock, "lock is missing"); @@ -3486,6 +3500,11 @@ bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known) { inline_sync_entry(lock, sync_handler); } + if (compilation()->env()->dtrace_method_probes()) { + Values* args = new Values(1); + args->push(append(new Constant(new ObjectConstant(method())))); + append(new RuntimeCall(voidType, "dtrace_method_entry", CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), args)); + } BlockBegin* callee_start_block = block_at(0); if (callee_start_block != NULL) { diff --git a/src/share/vm/c1/c1_Instruction.hpp b/src/share/vm/c1/c1_Instruction.hpp index 63b30819c..1f37449db 100644 --- a/src/share/vm/c1/c1_Instruction.hpp +++ b/src/share/vm/c1/c1_Instruction.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -106,6 +106,7 @@ class UnsafePrefetchRead; class UnsafePrefetchWrite; class ProfileCall; class ProfileInvoke; +class RuntimeCall; // A Value is a reference to the instruction creating the value typedef Instruction* Value; @@ -202,6 +203,7 @@ class InstructionVisitor: public StackObj { virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) = 0; virtual void do_ProfileCall (ProfileCall* x) = 0; virtual void do_ProfileInvoke (ProfileInvoke* x) = 0; + virtual void do_RuntimeCall (RuntimeCall* x) = 0; }; @@ -2267,6 +2269,38 @@ LEAF(ProfileCall, Instruction) virtual void input_values_do(ValueVisitor* f) { if (_recv != NULL) f->visit(&_recv); } }; + +// Call some C runtime function that doesn't safepoint, +// optionally passing the current thread as the first argument. +LEAF(RuntimeCall, Instruction) + private: + const char* _entry_name; + address _entry; + Values* _args; + bool _pass_thread; // Pass the JavaThread* as an implicit first argument + + public: + RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true) + : Instruction(type) + , _entry(entry) + , _args(args) + , _entry_name(entry_name) + , _pass_thread(pass_thread) { + ASSERT_VALUES + pin(); + } + + const char* entry_name() const { return _entry_name; } + address entry() const { return _entry; } + int number_of_arguments() const { return _args->length(); } + Value argument_at(int i) const { return _args->at(i); } + bool pass_thread() const { return _pass_thread; } + + virtual void input_values_do(ValueVisitor* f) { + for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i)); + } +}; + // Use to trip invocation counter of an inlined method LEAF(ProfileInvoke, Instruction) diff --git a/src/share/vm/c1/c1_InstructionPrinter.cpp b/src/share/vm/c1/c1_InstructionPrinter.cpp index 1b9930cb2..e27ce064d 100644 --- a/src/share/vm/c1/c1_InstructionPrinter.cpp +++ b/src/share/vm/c1/c1_InstructionPrinter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -841,4 +841,13 @@ void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) { } +void InstructionPrinter::do_RuntimeCall(RuntimeCall* x) { + output()->print("call_rt %s(", x->entry_name()); + for (int i = 0; i < x->number_of_arguments(); i++) { + if (i > 0) output()->print(", "); + print_value(x->argument_at(i)); + } + output()->put(')'); +} + #endif // PRODUCT diff --git a/src/share/vm/c1/c1_InstructionPrinter.hpp b/src/share/vm/c1/c1_InstructionPrinter.hpp index 3f3921e31..944797042 100644 --- a/src/share/vm/c1/c1_InstructionPrinter.hpp +++ b/src/share/vm/c1/c1_InstructionPrinter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -131,6 +131,7 @@ class InstructionPrinter: public InstructionVisitor { virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); virtual void do_ProfileCall (ProfileCall* x); virtual void do_ProfileInvoke (ProfileInvoke* x); + virtual void do_RuntimeCall (RuntimeCall* x); }; #endif // PRODUCT diff --git a/src/share/vm/c1/c1_LIRGenerator.cpp b/src/share/vm/c1/c1_LIRGenerator.cpp index 8dc579d0d..c912db6b5 100644 --- a/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/src/share/vm/c1/c1_LIRGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2741,6 +2741,31 @@ void LIRGenerator::increment_event_counter_impl(CodeEmitInfo* info, } } +void LIRGenerator::do_RuntimeCall(RuntimeCall* x) { + LIR_OprList* args = new LIR_OprList(x->number_of_arguments()); + BasicTypeList* signature = new BasicTypeList(x->number_of_arguments()); + + if (x->pass_thread()) { + signature->append(T_ADDRESS); + args->append(getThreadPointer()); + } + + for (int i = 0; i < x->number_of_arguments(); i++) { + Value a = x->argument_at(i); + LIRItem* item = new LIRItem(a, this); + item->load_item(); + args->append(item->result()); + signature->append(as_BasicType(a->type())); + } + + LIR_Opr result = call_runtime(signature, args, x->entry(), x->type(), NULL); + if (x->type() == voidType) { + set_no_result(x); + } else { + __ move(result, rlock_result(x)); + } +} + LIR_Opr LIRGenerator::call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info) { LIRItemList args(1); LIRItem value(arg1, this); diff --git a/src/share/vm/c1/c1_LIRGenerator.hpp b/src/share/vm/c1/c1_LIRGenerator.hpp index 96b6b1c19..4b9c4aeca 100644 --- a/src/share/vm/c1/c1_LIRGenerator.hpp +++ b/src/share/vm/c1/c1_LIRGenerator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -522,6 +522,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); virtual void do_ProfileCall (ProfileCall* x); virtual void do_ProfileInvoke (ProfileInvoke* x); + virtual void do_RuntimeCall (RuntimeCall* x); }; diff --git a/src/share/vm/c1/c1_Optimizer.cpp b/src/share/vm/c1/c1_Optimizer.cpp index b4da85cc4..93d610e62 100644 --- a/src/share/vm/c1/c1_Optimizer.cpp +++ b/src/share/vm/c1/c1_Optimizer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -496,6 +496,7 @@ public: void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); void do_ProfileCall (ProfileCall* x); void do_ProfileInvoke (ProfileInvoke* x); + void do_RuntimeCall (RuntimeCall* x); }; @@ -664,6 +665,7 @@ void NullCheckVisitor::do_UnsafePrefetchRead (UnsafePrefetchRead* x) {} void NullCheckVisitor::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {} void NullCheckVisitor::do_ProfileCall (ProfileCall* x) { nce()->clear_last_explicit_null_check(); } void NullCheckVisitor::do_ProfileInvoke (ProfileInvoke* x) {} +void NullCheckVisitor::do_RuntimeCall (RuntimeCall* x) {} void NullCheckEliminator::visit(Value* p) { diff --git a/src/share/vm/c1/c1_ValueMap.hpp b/src/share/vm/c1/c1_ValueMap.hpp index 9359abda1..7dcae91f3 100644 --- a/src/share/vm/c1/c1_ValueMap.hpp +++ b/src/share/vm/c1/c1_ValueMap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -192,11 +192,12 @@ class ValueNumberingVisitor: public InstructionVisitor { void do_ExceptionObject(ExceptionObject* x) { /* nothing to do */ } void do_RoundFP (RoundFP* x) { /* nothing to do */ } void do_UnsafeGetRaw (UnsafeGetRaw* x) { /* nothing to do */ } - void do_ProfileInvoke (ProfileInvoke* x) { /* nothing to do */ }; void do_UnsafeGetObject(UnsafeGetObject* x) { /* nothing to do */ } void do_UnsafePrefetchRead (UnsafePrefetchRead* x) { /* nothing to do */ } void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { /* nothing to do */ } void do_ProfileCall (ProfileCall* x) { /* nothing to do */ } + void do_ProfileInvoke (ProfileInvoke* x) { /* nothing to do */ }; + void do_RuntimeCall (RuntimeCall* x) { /* nothing to do */ }; }; -- GitLab