NMethod.java revision 1695:dec57655571e
162587Sitojun/*
262587Sitojun * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
362587Sitojun * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4331722Seadler *
555009Sshin * This code is free software; you can redistribute it and/or modify it
655009Sshin * under the terms of the GNU General Public License version 2 only, as
755009Sshin * published by the Free Software Foundation.
855009Sshin *
955009Sshin * This code is distributed in the hope that it will be useful, but WITHOUT
1055009Sshin * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1155009Sshin * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1255009Sshin * version 2 for more details (a copy is included in the LICENSE file that
1355009Sshin * accompanied this code).
1455009Sshin *
1555009Sshin * You should have received a copy of the GNU General Public License version
1655009Sshin * 2 along with this work; if not, write to the Free Software Foundation,
1755009Sshin * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1855009Sshin *
1955009Sshin * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2055009Sshin * or visit www.oracle.com if you need additional information or have any
2155009Sshin * questions.
2255009Sshin *
2355009Sshin */
2455009Sshin
2555009Sshinpackage sun.hotspot.code;
2655009Sshin
2755009Sshinimport java.lang.reflect.Executable;
2855009Sshinimport sun.hotspot.WhiteBox;
2955009Sshin
3055009Sshinpublic class NMethod extends CodeBlob {
3155009Sshin  private static final WhiteBox wb = WhiteBox.getWhiteBox();
3255009Sshin  public static NMethod get(Executable method, boolean isOsr) {
3355009Sshin    Object[] obj = wb.getNMethod(method, isOsr);
3455009Sshin    return obj == null ? null : new NMethod(obj);
3555009Sshin  }
3655009Sshin  private NMethod(Object[] obj) {
3755009Sshin    super((Object[])obj[0]);
38300773Scem    assert obj.length == 5;
39300773Scem    comp_level = (Integer) obj[1];
4055009Sshin    insts = (byte[]) obj[2];
4155009Sshin    compile_id = (Integer) obj[3];
4255009Sshin    address = (Long) obj[4];
4355009Sshin  }
4455009Sshin  public final byte[] insts;
4555009Sshin  public final int comp_level;
4655009Sshin  public final int compile_id;
4755009Sshin  public final long address;
4855009Sshin
4955009Sshin  @Override
5055009Sshin  public String toString() {
5155009Sshin    return "NMethod{"
5255009Sshin        + super.toString()
5355009Sshin        + ", insts=" + insts
5455009Sshin        + ", comp_level=" + comp_level
5555009Sshin        + ", compile_id=" + compile_id
56292963Sallanjude        + ", address=" + address
5755009Sshin        + '}';
58300773Scem  }
59300773Scem}
6055206Speter