Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -229,26 +229,13 @@ public static RuntimeList execute(InterpretedCode code, RuntimeArray args, int c
case Opcodes.LOAD_STRING -> {
int rd = bytecode[pc++];
int strIndex = bytecode[pc++];
String s = code.stringPool[strIndex];
RuntimeBase existing = registers[rd];
if (!(existing instanceof RuntimeScalar rs
&& rs.type == RuntimeScalarType.STRING
&& s.equals(rs.value))) {
registers[rd] = new RuntimeScalar(s);
}
registers[rd] = new RuntimeScalar(code.stringPool[strIndex]);
}

case Opcodes.LOAD_BYTE_STRING -> {
int rd = bytecode[pc++];
int strIndex = bytecode[pc++];
String s = code.stringPool[strIndex];
RuntimeBase existing = registers[rd];
if (existing instanceof RuntimeScalar rs
&& rs.type == RuntimeScalarType.BYTE_STRING
&& s.equals(rs.value)) {
break;
}
RuntimeScalar bs = new RuntimeScalar(s);
RuntimeScalar bs = new RuntimeScalar(code.stringPool[strIndex]);
bs.type = RuntimeScalarType.BYTE_STRING;
registers[rd] = bs;
}
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/perlonjava/backend/bytecode/Opcodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -1803,8 +1803,11 @@ public class Opcodes {
public static final short SET_FROM_LIST = 371;

/**
* Load byte string: rd = new RuntimeScalar(stringPool[index]) with BYTE_STRING type.
* Used for string literals under `no utf8` (the default).
* Load a non-UTF-8 string constant into a register.
* Creates a RuntimeScalar with BYTE_STRING type (Perl's default string encoding,
* equivalent to Latin-1/ISO-8859-1). This is the most common opcode in typical
* Perl programs — it loads hash keys, string literals, and identifiers.
* Compare with LOAD_STRING which loads UTF-8 flagged strings (from `use utf8` scope).
* Format: LOAD_BYTE_STRING rd strIndex
*/
public static final short LOAD_BYTE_STRING = 372;
Expand Down