Wed, 03 Jul 2019 20:42:37 +0800
Merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #ifndef SHARE_VM_CI_CIREPLAY_HPP |
aoqi@0 | 26 | #define SHARE_VM_CI_CIREPLAY_HPP |
aoqi@0 | 27 | |
aoqi@0 | 28 | #include "ci/ciMethod.hpp" |
aoqi@0 | 29 | |
aoqi@0 | 30 | // ciReplay |
aoqi@0 | 31 | |
aoqi@0 | 32 | // |
aoqi@0 | 33 | // Replay compilation of a java method by using an information in replay file. |
aoqi@0 | 34 | // Replay inlining decisions during compilation by using an information in inline file. |
aoqi@0 | 35 | // |
aoqi@0 | 36 | // NOTE: these replay functions only exist in debug version of VM. |
aoqi@0 | 37 | // |
aoqi@0 | 38 | // Replay compilation. |
aoqi@0 | 39 | // ------------------- |
aoqi@0 | 40 | // |
aoqi@0 | 41 | // Replay data file replay.txt can be created by Serviceability Agent |
aoqi@0 | 42 | // from a core file, see agent/doc/cireplay.html |
aoqi@0 | 43 | // |
aoqi@0 | 44 | // $ java -cp <jdk>/lib/sa-jdi.jar sun.jvm.hotspot.CLHSDB |
aoqi@0 | 45 | // hsdb> attach <jdk>/bin/java ./core |
aoqi@0 | 46 | // hsdb> threads |
aoqi@0 | 47 | // t@10 Service Thread |
aoqi@0 | 48 | // t@9 C2 CompilerThread0 |
aoqi@0 | 49 | // t@8 Signal Dispatcher |
aoqi@0 | 50 | // t@7 Finalizer |
aoqi@0 | 51 | // t@6 Reference Handler |
aoqi@0 | 52 | // t@2 main |
aoqi@0 | 53 | // hsdb> dumpreplaydata t@9 > replay.txt |
aoqi@0 | 54 | // hsdb> quit |
aoqi@0 | 55 | // |
aoqi@0 | 56 | // (Note: SA could be also used to extract app.jar and boot.jar files |
aoqi@0 | 57 | // from core file to replay compilation if only core file is available) |
aoqi@0 | 58 | // |
aoqi@0 | 59 | // Replay data file replay_pid%p.log is also created when VM crashes |
aoqi@0 | 60 | // in Compiler thread during compilation. It is controlled by |
aoqi@0 | 61 | // DumpReplayDataOnError flag which is ON by default. |
aoqi@0 | 62 | // |
aoqi@0 | 63 | // Replay file replay_pid%p_compid%d.log can be created |
aoqi@0 | 64 | // for the specified java method during normal execution using |
aoqi@0 | 65 | // CompileCommand option DumpReplay: |
aoqi@0 | 66 | // |
aoqi@0 | 67 | // -XX:CompileCommand=option,Benchmark::test,DumpReplay |
aoqi@0 | 68 | // |
aoqi@0 | 69 | // In this case the file name has additional compilation id "_compid%d" |
aoqi@0 | 70 | // because the method could be compiled several times. |
aoqi@0 | 71 | // |
aoqi@0 | 72 | // To replay compilation the replay file should be specified: |
aoqi@0 | 73 | // |
aoqi@0 | 74 | // -XX:+ReplayCompiles -XX:ReplayDataFile=replay_pid2133.log |
aoqi@0 | 75 | // |
aoqi@0 | 76 | // VM thread reads data from the file immediately after VM initialization |
aoqi@0 | 77 | // and puts the compilation task on compile queue. After that it goes into |
aoqi@0 | 78 | // wait state (BackgroundCompilation flag is set to false) since there is no |
aoqi@0 | 79 | // a program to execute. VM exits when the compilation is finished. |
aoqi@0 | 80 | // |
aoqi@0 | 81 | // |
aoqi@0 | 82 | // Replay inlining. |
aoqi@0 | 83 | // ---------------- |
aoqi@0 | 84 | // |
aoqi@0 | 85 | // Replay inlining file inline_pid%p_compid%d.log is created for |
aoqi@0 | 86 | // a specific java method during normal execution of a java program |
aoqi@0 | 87 | // using CompileCommand option DumpInline: |
aoqi@0 | 88 | // |
aoqi@0 | 89 | // -XX:CompileCommand=option,Benchmark::test,DumpInline |
aoqi@0 | 90 | // |
aoqi@0 | 91 | // To replay inlining the replay file and the method should be specified: |
aoqi@0 | 92 | // |
aoqi@0 | 93 | // -XX:CompileCommand=option,Benchmark::test,ReplayInline -XX:InlineDataFile=inline_pid3244_compid6.log |
aoqi@0 | 94 | // |
aoqi@0 | 95 | // The difference from replay compilation is that replay inlining |
aoqi@0 | 96 | // is performed during normal java program execution. |
aoqi@0 | 97 | // |
aoqi@0 | 98 | |
aoqi@0 | 99 | class ciReplay { |
aoqi@0 | 100 | CI_PACKAGE_ACCESS |
aoqi@0 | 101 | |
aoqi@0 | 102 | #ifndef PRODUCT |
aoqi@0 | 103 | private: |
aoqi@0 | 104 | static int replay_impl(TRAPS); |
aoqi@0 | 105 | |
aoqi@0 | 106 | public: |
aoqi@0 | 107 | // Replay specified compilation and exit VM. |
aoqi@0 | 108 | static void replay(TRAPS); |
aoqi@0 | 109 | // Load inlining decisions from file and use them |
aoqi@0 | 110 | // during compilation of specified method. |
aoqi@0 | 111 | static void* load_inline_data(ciMethod* method, int entry_bci, int comp_level); |
aoqi@0 | 112 | |
aoqi@0 | 113 | // These are used by the CI to fill in the cached data from the |
aoqi@0 | 114 | // replay file when replaying compiles. |
aoqi@0 | 115 | static void initialize(ciMethodData* method); |
aoqi@0 | 116 | static void initialize(ciMethod* method); |
aoqi@0 | 117 | |
aoqi@0 | 118 | static bool is_loaded(Method* method); |
aoqi@0 | 119 | static bool is_loaded(Klass* klass); |
aoqi@0 | 120 | |
aoqi@0 | 121 | static bool should_not_inline(ciMethod* method); |
aoqi@0 | 122 | static bool should_inline(void* data, ciMethod* method, int bci, int inline_depth); |
aoqi@0 | 123 | static bool should_not_inline(void* data, ciMethod* method, int bci, int inline_depth); |
aoqi@0 | 124 | |
aoqi@0 | 125 | #endif |
aoqi@0 | 126 | }; |
aoqi@0 | 127 | |
aoqi@0 | 128 | #endif // SHARE_VM_CI_CIREPLAY_HPP |