Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
416bc74
Add local variable records and function parameter definitions.
stooke Dec 16, 2022
6faffc6
Small cleanup to get rid of unused record types.
stooke Dec 16, 2022
f2f013a
CHanges for Github gate.
stooke Dec 16, 2022
569ab0d
Changes per @adinn review
stooke Jan 13, 2023
dbb6d61
Merge branch 'master' into pr-windows-varinfo
stooke May 1, 2023
82b891e
use real names for parameter variables
stooke May 5, 2023
1e92fe5
Merge branch 'master' of https://github.com/oracle/graal into pr-wind…
stooke Jun 22, 2023
f08f67a
Merge remote-tracking branch 'origin' into pr-windows-varinfo
stooke Aug 9, 2023
2826cf1
Merge branch 'master' into pr-windows-varinfo
stooke Aug 9, 2023
b9be5b9
Merge branch 'master' into pr-windows-varinfo
stooke Aug 25, 2023
0b010df
Define functions using S_GPROC32_ID records.
stooke Aug 25, 2023
e41cbf5
Define 'this' and parameters using debug local info.
stooke Aug 25, 2023
f94280c
Clean up unused functions.
stooke Aug 25, 2023
d481351
Fixes for GraalVM gate.
stooke Aug 25, 2023
278c9b7
Changes for Graal gate
stooke Aug 28, 2023
e8a2077
Changes for Graal gate.
stooke Aug 28, 2023
7c035bb
Changes for Graal gate.
stooke Aug 28, 2023
6e9fc17
Changes for Graal gate.
stooke Aug 28, 2023
e8fd943
Changes for Graal gate.
stooke Aug 28, 2023
b8143af
Changes and cleanup for Graal gate.
stooke Aug 25, 2023
a0f48b5
Corrected variable range calculation.
stooke Sep 6, 2023
77c95cb
Merge branch 'pr-windows-varinfo' of https://github.com/stooke/graal …
stooke Sep 6, 2023
53373d3
Changes for Github gate.
stooke Sep 6, 2023
5f917c7
Changes for Github gate
stooke Sep 7, 2023
d2e09e0
Merge branch 'master' into pr-windows-varinfo
stooke Nov 9, 2023
2f14f4f
Merge branch 'pr-windows-varinfo' of https://github.com/stooke/graal
stooke Sep 3, 2024
e61f73d
fix aob error in regester code
stooke Sep 3, 2024
71b9152
Merge branch 'master' of https://github.com/oracle/graal into pr-wind…
stooke Sep 3, 2024
0947272
changes for Graal style gate
stooke Sep 4, 2024
d91bd40
add CVRegisterUtil
stooke Oct 31, 2024
e0cde0e
Merge remote-tracking branch 'upstream/master' into pr-windows-varinfo
stooke Oct 31, 2024
49ed77c
Merge remote-tracking branch 'upstream/master' into pr-windows-varinfo
stooke Nov 1, 2024
6d00d34
CvRegusterUtil->CVReguiaterUtil
stooke Nov 7, 2024
005e14f
CvRegusterUtil->CVReguiaterUtil complete
stooke Nov 7, 2024
c9323b6
remve unused constants
stooke Nov 7, 2024
c53323b
style changes from Graal gate
stooke Nov 7, 2024
bdebea4
style changes from Eclipseformat
stooke Nov 7, 2024
d62db1d
update copyright
stooke Nov 7, 2024
c4de8ca
fix capitalization
stooke May 29, 2025
d8e22ba
Merge branch 'master' of https://github.com/oracle/graal
stooke May 29, 2025
bfc8eaf
Merge branch 'master' of https://github.com/oracle/graal into pr-wind…
stooke May 29, 2025
c79a9a8
mark some xmm register defs unused
stooke May 29, 2025
adacbf8
fix indentation
stooke May 29, 2025
431d0d7
Merge branch 'master' of https://github.com/oracle/graal
stooke Jun 2, 2025
be92289
Merge branch 'master' into pr-windows-varinfo
stooke Jun 2, 2025
8e93dd5
fix hub member in class objects
stooke Jun 4, 2025
0555d09
Merge branch 'master' of https://github.com/oracle/graal
stooke Jun 4, 2025
72efb93
fix hub member in class objects
stooke Jun 4, 2025
bdd27d5
add new register definitions
stooke Jun 4, 2025
1997e91
graal formatting fix
stooke Jun 4, 2025
34c0b7e
fix github formatting gate isue
stooke Jul 2, 2025
b08c76a
Merge branch 'master' into pr_update_codeview
stooke Jul 28, 2025
5502391
Merge branch 'master' into pr_update_codeview
stooke Jul 28, 2025
23e296e
changes for runtime debug option
stooke Jul 29, 2025
8636f8e
Merge branch 'master' into pr_update_codeview
stooke Jul 30, 2025
83fb68c
Merge branch 'pr_update_codeview' into pr-windows-varinfo-work
stooke Jul 30, 2025
6ac77fb
fix up varinfo pr
stooke Jul 31, 2025
37c1ea9
Merge branch 'master' into pr-windows-varinfo-work
stooke Aug 12, 2025
29e725a
fixes for new Method API
stooke Aug 12, 2025
33449e4
revert test files
stooke Aug 13, 2025
732c955
Merge branch 'master' into pr-windows-varinfo
stooke Aug 21, 2025
945f1cb
remove duplicate import
stooke Aug 21, 2025
3d06cb3
changes for graal gate
stooke Aug 21, 2025
03b2e1d
changes for graal checkstyle
stooke Aug 21, 2025
69894e3
changes from code review
stooke Sep 23, 2025
19328a7
fix for Graal style gate
stooke Sep 23, 2025
04d6db7
use different logger
stooke Sep 23, 2025
e4524ed
use different logger
stooke Sep 23, 2025
156645d
use MFuncId instead of FuncId record
stooke Sep 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024, Red Hat Inc. 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
Expand Down Expand Up @@ -35,13 +35,4 @@ public abstract class CVConstants {

/* CodeView section header signature */
static final int CV_SIGNATURE_C13 = 4;

static final int CV_AMD64_R8 = 336;
static final int CV_AMD64_R9 = 337;
static final int CV_AMD64_R10 = 338;
static final int CV_AMD64_R11 = 339;
static final int CV_AMD64_R12 = 340;
static final int CV_AMD64_R13 = 341;
static final int CV_AMD64_R14 = 342;
static final int CV_AMD64_R15 = 343;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024, Red Hat Inc. 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
Expand Down Expand Up @@ -37,11 +37,25 @@ public abstract class CVDebugConstants {
static final short S_END = 0x0006;
static final short S_FRAMEPROC = 0x1012;
static final short S_OBJNAME = 0x1101;
static final short S_UDT = 0x1108;
static final short S_BLOCK32 = 0x1103;
static final short S_REGISTER = 0x1106; /* Register variable. */
static final short S_CONSTANT = 0x1107; /* Constant. */
static final short S_UDT = 0x1108; /* User defined type. */
static final short S_LDATA32 = 0x110c; /* Local static. */
static final short S_GDATA32 = 0x110d; /* Global static. */
static final short S_GPROC32 = 0x1110; /* Global procedure. */
static final short S_REGREL32 = 0x1111;
static final short S_COMPILE3 = 0x113c;
static final short S_ENVBLOCK = 0x113d;
static final short S_LOCAL = 0x113e;
static final short S_DEFRANGE = 0x113f;
static final short S_DEFRANGE_SUBFIELD = 0x1140;
static final short S_DEFRANGE_REGISTER = 0x1141;
static final short S_DEFRANGE_FRAMEPOINTER_REL = 0x1142;
static final short S_DEFRANGE_SUBFIELD_REGISTER = 0x1143;
static final short S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE = 0x1144;
static final short S_DEFRANGE_REGISTER_REL = 0x1145;
static final short S_LPROC32_ID = 0x1146;
static final short S_GPROC32_ID = 0x1147;
static final short S_PROC_ID_END = 0x114f;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024, Red Hat Inc. 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024, Red Hat Inc. 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
Expand Down Expand Up @@ -100,7 +100,7 @@ private void processRange(Range range) {
lineRecord.addNewFile(fileId);
}

/* Add line record. */
/* Add line record. Address is relative to start of function. */
int lineLoAddr = (int) (range.getLo() - compiledEntry.primary().getLo());
int line = Math.max(range.getLine(), 1);
debug(" processRange: addNewLine: 0x%05x-0x%05x %s", lineLoAddr, range.getHi() - compiledEntry.primary().getLo(), line);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
/*
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2025, Red Hat Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package com.oracle.objectfile.pecoff.cv;

import com.oracle.objectfile.debugentry.PrimitiveTypeEntry;
import com.oracle.objectfile.debugentry.TypeEntry;
import jdk.vm.ci.amd64.AMD64;
import jdk.vm.ci.code.Register;

import java.util.Objects;

@SuppressWarnings("unused")
public class CVRegisterUtil {

private static final int MAX_JAVA_REGISTER_NUMBER = AMD64.xmm15.number;

/* Register definitions */

/* 8 bit registers. */
private static final short CV_AMD64_R8B = 344;
private static final short CV_AMD64_R9B = 345;
private static final short CV_AMD64_R10B = 346;
private static final short CV_AMD64_R11B = 347;
private static final short CV_AMD64_R12B = 348;
private static final short CV_AMD64_R13B = 349;
private static final short CV_AMD64_R14B = 350;
private static final short CV_AMD64_R15B = 351;

private static final short CV_AMD64_AL = 1;
private static final short CV_AMD64_CL = 2;
private static final short CV_AMD64_DL = 3;
private static final short CV_AMD64_BL = 4;

private static final short CV_AMD64_SIL = 324;
private static final short CV_AMD64_DIL = 325;
private static final short CV_AMD64_BPL = 326;
private static final short CV_AMD64_SPL = 327;

/* 16 bit registers. */
private static final short CV_AMD64_R8W = 352;
private static final short CV_AMD64_R9W = 353;
private static final short CV_AMD64_R10W = 354;
private static final short CV_AMD64_R11W = 355;
private static final short CV_AMD64_R12W = 356;
private static final short CV_AMD64_R13W = 357;
private static final short CV_AMD64_R14W = 358;
private static final short CV_AMD64_R15W = 359;

private static final short CV_AMD64_AX = 9;
private static final short CV_AMD64_CX = 10;
private static final short CV_AMD64_DX = 11;
private static final short CV_AMD64_BX = 12;
private static final short CV_AMD64_SP = 13;
private static final short CV_AMD64_BP = 14;
private static final short CV_AMD64_SI = 15;
private static final short CV_AMD64_DI = 16;

/* 32 bit registers. */
private static final short CV_AMD64_R8D = 360;
private static final short CV_AMD64_R9D = 361;
private static final short CV_AMD64_R10D = 362;
private static final short CV_AMD64_R11D = 363;
private static final short CV_AMD64_R12D = 364;
private static final short CV_AMD64_R13D = 365;
private static final short CV_AMD64_R14D = 366;
private static final short CV_AMD64_R15D = 367;

private static final short CV_AMD64_EAX = 17;
private static final short CV_AMD64_ECX = 18;
private static final short CV_AMD64_EDX = 19;
private static final short CV_AMD64_EBX = 20;
private static final short CV_AMD64_ESP = 21;
private static final short CV_AMD64_EBP = 22;
private static final short CV_AMD64_ESI = 23;
private static final short CV_AMD64_EDI = 24;

/* 64 bit registers. */
private static final short CV_AMD64_RAX = 328;
private static final short CV_AMD64_RBX = 329;
private static final short CV_AMD64_RCX = 330;
private static final short CV_AMD64_RDX = 331;
private static final short CV_AMD64_RSI = 332;
private static final short CV_AMD64_RDI = 333;
private static final short CV_AMD64_RBP = 334;
private static final short CV_AMD64_RSP = 335;

static final short CV_AMD64_R8 = 336;
private static final short CV_AMD64_R9 = 337;
private static final short CV_AMD64_R10 = 338;
private static final short CV_AMD64_R11 = 339;
private static final short CV_AMD64_R12 = 340;
private static final short CV_AMD64_R13 = 341;
private static final short CV_AMD64_R14 = 342;
private static final short CV_AMD64_R15 = 343;

/* FP registers. */
private static final short CV_AMD64_XMM0 = 154;
private static final short CV_AMD64_XMM1 = 155;
private static final short CV_AMD64_XMM2 = 156;
private static final short CV_AMD64_XMM3 = 157;
private static final short CV_AMD64_XMM4 = 158;
private static final short CV_AMD64_XMM5 = 159;
private static final short CV_AMD64_XMM6 = 160;
private static final short CV_AMD64_XMM7 = 161;

private static final short CV_AMD64_XMM8 = 252;
private static final short CV_AMD64_XMM9 = 253;
private static final short CV_AMD64_XMM10 = 254;
private static final short CV_AMD64_XMM11 = 255;
private static final short CV_AMD64_XMM12 = 256;
private static final short CV_AMD64_XMM13 = 257;
private static final short CV_AMD64_XMM14 = 258;
private static final short CV_AMD64_XMM15 = 259;

private static final short CV_AMD64_XMM0_0 = 162;
private static final short CV_AMD64_XMM1_0 = 166;
private static final short CV_AMD64_XMM2_0 = 170;
private static final short CV_AMD64_XMM3_0 = 174;
private static final short CV_AMD64_XMM4_0 = 178;
private static final short CV_AMD64_XMM5_0 = 182;
private static final short CV_AMD64_XMM6_0 = 186;
private static final short CV_AMD64_XMM7_0 = 190;

private static final short CV_AMD64_XMM8_0 = 260;
private static final short CV_AMD64_XMM9_0 = 264;
private static final short CV_AMD64_XMM10_0 = 268;
private static final short CV_AMD64_XMM11_0 = 272;
private static final short CV_AMD64_XMM12_0 = 276;
private static final short CV_AMD64_XMM13_0 = 280;
private static final short CV_AMD64_XMM14_0 = 284;
private static final short CV_AMD64_XMM15_0 = 288;

private static final short CV_AMD64_XMM0L = 194;
private static final short CV_AMD64_XMM1L = 195;
private static final short CV_AMD64_XMM2L = 196;
private static final short CV_AMD64_XMM3L = 197;
private static final short CV_AMD64_XMM4L = 198;
private static final short CV_AMD64_XMM5L = 199;
private static final short CV_AMD64_XMM6L = 200;
private static final short CV_AMD64_XMM7L = 201;

private static final short CV_AMD64_XMM8L = 292;
private static final short CV_AMD64_XMM9L = 293;
private static final short CV_AMD64_XMM10L = 294;
private static final short CV_AMD64_XMM11L = 295;
private static final short CV_AMD64_XMM12L = 296;
private static final short CV_AMD64_XMM13L = 297;
private static final short CV_AMD64_XMM14L = 298;
private static final short CV_AMD64_XMM15L = 299;

private static class CvRegDef {
final Register register;
final short cv1;
final short cv2;
final short cv4;
final short cv8;

CvRegDef(Register r, short cv1, short cv2, short cv4, short cv8) {
this.register = r;
this.cv1 = cv1;
this.cv2 = cv2;
this.cv4 = cv4;
this.cv8 = cv8;
}

CvRegDef(Register r, short cv4, short cv8) {
this.register = r;
this.cv1 = -1;
this.cv2 = -1;
this.cv4 = cv4;
this.cv8 = cv8;
}
}

private static final CvRegDef[] javaToCvRegisters = new CvRegDef[MAX_JAVA_REGISTER_NUMBER + 1];

static {
/* List of Graal assignable registers and CodeView register IDs. */
final CvRegDef[] compactRegDefs = {
/* 8, 16, 32, 64 bits */
new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX),
new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX),
new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX),
new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX),
new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP),
new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP),
new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI),
new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI),
new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8),
new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9),
new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10),
new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11),
new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12),
new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13),
new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14),
new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15),

/* 32, 64 bits */
new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */
new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L),
new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L),
new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L),
new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L),
new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L),
new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L),
new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L),
new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L),
new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L),
new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L),
new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L),
new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L),
new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L),
new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L),
new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L),
};

for (CvRegDef def : compactRegDefs) {
assert 0 <= def.register.number && def.register.number <= MAX_JAVA_REGISTER_NUMBER;
javaToCvRegisters[def.register.number] = def;
}
}

/*
* Convert a Java register number to a CodeView register code. In release mode, return -1 so
* caller can emit a warning and continue. In debug mode, throw an assert.
*
* This can (and has) happened when Graal is enhanced to use more registers but there is no test
* for that in the test suite.
*/
/* the CodeView code depends upon the register type and size */
static short getCVRegister(int javaReg, TypeEntry typeEntry) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contract of this method seems unclear. It should either (a) be defensive—use runtime checks and return -1 on any error; or (b) assume validated inputs—keep the asserts and drop runtime checks. The current mix is inconsistent; moreover, some conditions directly conflict (assert 0 <= javaReg <= MAX, then check javaReg > MAX; assert cvReg != null, then check cvReg == null).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. I have clarified the intent via reordering, comments, and a warning message.
The intent is that production code would continue with a warning (and no symbol emitted) while debug code would trigger an assert so the code could be fixed and not ignored.

assert 0 <= javaReg && javaReg <= MAX_JAVA_REGISTER_NUMBER;
if (javaReg > MAX_JAVA_REGISTER_NUMBER) {
/* Register is unimplemented. */
return -1;
}
CvRegDef cvReg = javaToCvRegisters[javaReg];
assert cvReg != null;
if (cvReg == null) {
/* Register is unimplemented. */
return -1;
}
/* Sanity check */
assert cvReg.register.number == javaReg;

final short cvCode;
if (Objects.requireNonNull(typeEntry) instanceof PrimitiveTypeEntry) {
/* Find correct sub-register given the primitive type length. */
cvCode = switch (typeEntry.getSize()) {
case 1 -> cvReg.cv1;
case 2 -> cvReg.cv2;
case 4 -> cvReg.cv4;
case 8 -> cvReg.cv8;
default -> -1;
};
} else {
/* Objects are represented by 8 byte pointers. */
cvCode = cvReg.cv8;
}
/* Check for unimplemented size. */
assert cvCode != -1;
return cvCode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.oracle.objectfile.LayoutDecision;
import com.oracle.objectfile.LayoutDecisionMap;
import com.oracle.objectfile.ObjectFile;

import jdk.graal.compiler.debug.DebugContext;

import java.util.Map;
Expand Down Expand Up @@ -73,6 +74,12 @@ protected void enableLog(DebugContext debugContext) {
}
}

protected void warn(String format, Object... args) {
if (debug) {
getDebugContext().logv(DebugContext.BASIC_LEVEL, format, args);
}
}

protected void log(String format, Object... args) {
if (debug) {
getDebugContext().logv(DebugContext.INFO_LEVEL, format, args);
Expand Down
Loading
Loading