Skip to content

Commit

Permalink
Automatic merge of master into galahad
Browse files Browse the repository at this point in the history
  • Loading branch information
OracleLabsAutomation committed Jun 6, 2024
2 parents 665c3ab + 69baa16 commit f86a4c9
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021, Oracle and/or its affiliates.
* Copyright (c) 2017, 2024, Oracle and/or its affiliates.
*
* All rights reserved.
*
Expand Down Expand Up @@ -43,22 +43,23 @@

public abstract class LLVMStringHelper extends LLVMNode {

public abstract void execute(LLVMPointer dst, long bufLength, String src);
public abstract long execute(LLVMPointer dst, long bufLength, String src);

@Specialization
void doNative(LLVMNativePointer dst, long bufLength, String src) {
long doNative(LLVMNativePointer dst, long bufLength, String src) {
LLVMMemory memory = getLanguage().getLLVMMemory();
byte[] bytes = getBytes(src);
long ptr = dst.asNative();
for (int i = 0; i < bytes.length && i < bufLength - 1; i++) {
memory.putI8(this, ptr++, bytes[i]);
}
memory.putI8(this, ptr++, (byte) 0);
return ptr - dst.asNative();
}

@Specialization(limit = "3")
@GenerateAOT.Exclude
void doManaged(LLVMManagedPointer dst, long bufLength, String src,
long doManaged(LLVMManagedPointer dst, long bufLength, String src,
@Bind("dst.getObject()") Object obj,
@CachedLibrary("obj") LLVMManagedWriteLibrary write) {
byte[] bytes = getBytes(src);
Expand All @@ -67,6 +68,7 @@ void doManaged(LLVMManagedPointer dst, long bufLength, String src,
write.writeI8(obj, offset++, bytes[i]);
}
write.writeI8(obj, offset++, (byte) 0);
return offset - dst.getOffset();
}

@TruffleBoundary
Expand Down

0 comments on commit f86a4c9

Please sign in to comment.