From 9ac3ee4aa02a8986fb326ba218b7eaef8a77b667 Mon Sep 17 00:00:00 2001 From: Aaron Simkin Date: Thu, 11 Sep 2025 20:52:18 +0800 Subject: [PATCH] UnsafeString intrinsics should not use metadata The unsafe memory string intrinsics (read and write) should just write and read the byte payload of the string. No metadata should be present in the serialization stream. Issue: #ICXM0F Change-Id: Ibc8609380a4378e83038cf665be12f4acfc81ef9 Signed-off-by: Aaron Simkin --- .../ets/compiler/codegen_intrinsics_ets.cpp | 23 ++--- .../compiler/intrinsics_ir_build_ets.inl.h | 1 - .../intrinsics_ir_build_static_call_ets.inl | 5 +- .../ets/compiler/ir_build_intrinsics_ets.cpp | 26 ------ .../plugins/ets/irtoc_scripts/string.irt | 92 ------------------- .../ets_llvm_ir_constructor_gen.inl | 22 ----- .../ets_llvm_ir_constructor_h_gen.inl | 3 - .../plugins/ets/runtime/ets_entrypoints.cpp | 29 ++++++ .../plugins/ets/runtime/ets_entrypoints.yaml | 49 ++-------- .../ets/runtime/ets_libbase_runtime.yaml | 5 +- .../ets/runtime/intrinsics/unsafe_memory.cpp | 55 +++-------- .../compiler/inst_generator_test_ext.inc | 5 +- 12 files changed, 68 insertions(+), 247 deletions(-) diff --git a/static_core/plugins/ets/compiler/codegen_intrinsics_ets.cpp b/static_core/plugins/ets/compiler/codegen_intrinsics_ets.cpp index d95297205a..a5f1863532 100644 --- a/static_core/plugins/ets/compiler/codegen_intrinsics_ets.cpp +++ b/static_core/plugins/ets/compiler/codegen_intrinsics_ets.cpp @@ -709,26 +709,21 @@ void Codegen::CreateWriteString(IntrinsicInst *inst, Reg dst, SRCREGS src) { ASSERT(IsCompressedStringsEnabled()); auto entrypointId = EntrypointId::WRITE_STRING_TO_MEM; - CallFastPath(inst, entrypointId, dst, {}, src[FIRST_OPERAND], src[SECOND_OPERAND]); + CallRuntime(inst, entrypointId, dst, {}, src[FIRST_OPERAND], src[SECOND_OPERAND]); } void Codegen::CreateReadString(IntrinsicInst *inst, Reg dst, SRCREGS src) { ASSERT(IsCompressedStringsEnabled()); auto entrypointId = EntrypointId::CREATE_STRING_FROM_MEM; - auto buf = src[FIRST_OPERAND]; - auto len = src[SECOND_OPERAND]; - if (GetGraph()->IsAotMode()) { - auto *enc = GetEncoder(); - auto offset = GetRuntime()->GetStringClassPointerTlsOffset(GetArch()); - ScopedTmpReg klass(enc); - enc->EncodeLdr(klass, false, MemRef(ThreadReg(), offset)); - CallFastPath(inst, entrypointId, dst, {}, buf, len, klass); - } else { - auto klass = GetRuntime()->GetLineStringClass(GetGraph()->GetMethod(), nullptr); - auto klassImm = TypedImm(reinterpret_cast(klass)); - CallFastPath(inst, entrypointId, dst, {}, buf, len, klassImm); - } + CallRuntime(inst, entrypointId, dst, {}, src[FIRST_OPERAND], src[SECOND_OPERAND]); +} + +void Codegen::CreateGetSizeInBytes(IntrinsicInst *inst, Reg dst, SRCREGS src) +{ + ASSERT(IsCompressedStringsEnabled()); + auto entrypointId = EntrypointId::GET_STRING_SIZE_IN_BYTES; + CallRuntime(inst, entrypointId, dst, {}, src[FIRST_OPERAND]); } void Codegen::CreateMapGet([[maybe_unused]] IntrinsicInst *inst, Reg dst, SRCREGS src) diff --git a/static_core/plugins/ets/compiler/intrinsics_ir_build_ets.inl.h b/static_core/plugins/ets/compiler/intrinsics_ir_build_ets.inl.h index 0d18a6649f..cd59df4d57 100644 --- a/static_core/plugins/ets/compiler/intrinsics_ir_build_ets.inl.h +++ b/static_core/plugins/ets/compiler/intrinsics_ir_build_ets.inl.h @@ -50,7 +50,6 @@ template void BuildUnsafeIntrinsic(const BytecodeInstruction *bcInst, bool accRead); void BuildUnsafeLoadIntrinsic(const BytecodeInstruction *bcInst, bool accRead); void BuildUnsafeStoreIntrinsic(const BytecodeInstruction *bcInst, bool accRead); -void BuildStringSizeInBytes(const BytecodeInstruction *bcInst, bool accRead); // CC-OFFNXT(G.NAM.01,G.NAM.03) false positive std::tuple BuildTypedArrayLoadDataAndOffset( const BytecodeInstruction *bcInst, ark::compiler::DataType::Type type, bool accRead, bool needBoundCheck); diff --git a/static_core/plugins/ets/compiler/intrinsics_ir_build_static_call_ets.inl b/static_core/plugins/ets/compiler/intrinsics_ir_build_static_call_ets.inl index 30cf804477..b9b929789f 100644 --- a/static_core/plugins/ets/compiler/intrinsics_ir_build_static_call_ets.inl +++ b/static_core/plugins/ets/compiler/intrinsics_ir_build_static_call_ets.inl @@ -113,10 +113,7 @@ case RuntimeInterface::IntrinsicId::INTRINSIC_UNSAFE_MEMORY_READ_NUMBER: { Builder()->BuildUnsafeLoadIntrinsic(bcInst_, ACC_READ); break; } -case RuntimeInterface::IntrinsicId::INTRINSIC_UNSAFE_MEMORY_GET_STRING_SIZE_IN_BYTES: { - Builder()->BuildStringSizeInBytes(bcInst_, ACC_READ); - break; -} +case RuntimeInterface::IntrinsicId::INTRINSIC_UNSAFE_MEMORY_GET_STRING_SIZE_IN_BYTES: case RuntimeInterface::IntrinsicId::INTRINSIC_UNSAFE_MEMORY_READ_STRING: case RuntimeInterface::IntrinsicId::INTRINSIC_UNSAFE_MEMORY_WRITE_STRING: { if (Builder()->IsInBootContext()) { diff --git a/static_core/plugins/ets/compiler/ir_build_intrinsics_ets.cpp b/static_core/plugins/ets/compiler/ir_build_intrinsics_ets.cpp index eb74a26dd8..9f1d4ef29c 100644 --- a/static_core/plugins/ets/compiler/ir_build_intrinsics_ets.cpp +++ b/static_core/plugins/ets/compiler/ir_build_intrinsics_ets.cpp @@ -509,30 +509,4 @@ void InstBuilder::BuildUnsafeStoreIntrinsic(const BytecodeInstruction *bcInst, b BuildUnsafeIntrinsic(bcInst, accRead); } -void InstBuilder::BuildStringSizeInBytes(const BytecodeInstruction *bcInst, bool accRead) -{ - /* ensure the boot context of the caller */ - if (!IsInBootContext()) { - failed_ = true; - return; - } - - auto bcAddr = GetPc(bcInst->GetAddress()); - auto str = GetArgDefinition(bcInst, 0, accRead); - auto runtime = GetRuntime(); - auto graph = GetGraph(); - auto offset = FindOrCreateConstant(runtime->GetStringLengthOffset(graph->GetArch())); - auto one = FindOrCreateConstant(1U); - auto two = FindOrCreateConstant(ark::coretypes::String::STRING_LENGTH_SHIFT); - - auto len = graph->CreateInstLoadNative(DataType::INT32, bcAddr, str, offset); - auto size = graph->CreateInstShr(DataType::INT32, bcAddr, len, two); - auto shift = graph->CreateInstAnd(DataType::INT32, bcAddr, len, one); - auto add = graph->CreateInstAdd(DataType::INT32, bcAddr, size, shift); - auto result = graph->CreateInstShl(DataType::INT32, bcAddr, add, shift); - - AddInstruction(len, size, shift, add, result); - UpdateDefinitionAcc(result); -} - } // namespace ark::compiler diff --git a/static_core/plugins/ets/irtoc_scripts/string.irt b/static_core/plugins/ets/irtoc_scripts/string.irt index 1b6e316c52..f6da6223ea 100644 --- a/static_core/plugins/ets/irtoc_scripts/string.irt +++ b/static_core/plugins/ets/irtoc_scripts/string.irt @@ -1881,95 +1881,3 @@ Label(:SlowPathEntrypoint) Intrinsic(:SLOW_PATH_ENTRY, str, count).AddImm(entrypoint).MethodAsImm("StringRepeatUsualBridge").Terminator.ptr Intrinsic(:UNREACHABLE).Terminator.void if defines.DEBUG } - -function(:WriteStringToMem, - params: {mem: 'i64', str: 'ref'}, - regmap: $full_regmap, - regalloc_set: $panda_mask, - mode: [:FastPath]) { - - if Options.arch == :arm32 - Intrinsic(:UNREACHABLE).Terminator.void - next - end - - check_string_type(str) - - buf := Bitcast(mem).ptr - len := LoadI(str).Imm(Constants::STRING_LENGTH_OFFSET).u32 - utf16 := AndI(len).Imm(1).u32 - len_0 := ShrI(len).Imm(Constants::STRING_LENGTH_SHIFT).u32 - len := len_0 - - If(len, 0).EQ.Unlikely.b { - Goto(:End) - } - - If(utf16, 1).EQ.Unlikely.b { - mark := 0xfeff - StoreI(buf, mark).Imm(0).u16 - len_1 := ShlI(len).Imm(1).u32 - buf_1 := AddI(buf).Imm(2).ptr - } - buf := Phi(buf, buf_1).ptr - len := Phi(len, len_1).u32 - - str_data := AddI(str).Imm(Constants::STRING_DATA_OFFSET).ptr - copy_u8_chars(str_data, buf, len); - - If(utf16, 1).EQ.Unlikely.b { - len_1 := AddI(len).Imm(2).u32 - } - -Label(:End) - len := Phi(len_0, len, len_1).u32 - Return(len).u32 -Label(:SlowPathEntrypoint) - entrypoint = get_entrypoint_offset("WRITE_STRING_TO_MEM_SLOW_PATH") - Intrinsic(:SLOW_PATH_ENTRY, mem, str).AddImm(entrypoint).MethodAsImm("WriteStringToMemUsualBridge").Terminator.u32 - Intrinsic(:UNREACHABLE).Terminator.void if defines.DEBUG -} - -function(:CreateStringFromMem, - params: {buf: 'i64', len: 'i32', klass: 'ref'}, - regmap: $full_regmap, - regalloc_set: $panda_mask, - mode: [:FastPath]) { - - if Options.arch == :arm32 - Intrinsic(:UNREACHABLE).Terminator.void - next - end - - addr := Bitcast(buf).ptr - mark := LoadI(addr).Imm(0).u16 - - If(mark, Cast(0xFEFF).u16).EQ.Unlikely.b { # UTF-16 string - size_1 := SubI(len).Imm(2).i32 - addr_1 := AddI(addr).Imm(2).ptr - } - - size := Phi(len, size_1).i32 - addr := Phi(addr, addr_1).ptr - - str := allocate_string_tlab_no_debug(klass, size) - str_data := AddI(str).Imm(Constants::STRING_DATA_OFFSET).ptr - copy_u8_chars(addr, str_data, size); - size_0 := ShlI(size).Imm(Constants::STRING_LENGTH_SHIFT).u32 - - If(mark, Cast(0xFEFF).u16).EQ.Unlikely.b { # UTF-16 string - size_1 := OrI(ShrI(size_0).Imm(1).u32).Imm(1).u32 - } - - size := Phi(size_0, size_1).u32 - str_len := AddI(str).Imm(Constants::STRING_LENGTH_OFFSET).ptr - StoreI(str_len, size).Imm(0).u32 - - Intrinsic(:DATA_MEMORY_BARRIER_FULL).void - Return(str).ptr - - Label(:SlowPathEntrypoint) - eid = get_entrypoint_offset("CREATE_STRING_FROM_MEM_SLOW_PATH") - Intrinsic(:SLOW_PATH_ENTRY, buf, len).AddImm(eid).MethodAsImm("CreateStringFromMem3ArgBridge").Terminator.ptr - Intrinsic(:UNREACHABLE).Terminator.void if defines.DEBUG -} diff --git a/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_gen.inl b/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_gen.inl index 3a5f514848..11ed7a167a 100644 --- a/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_gen.inl +++ b/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_gen.inl @@ -465,27 +465,6 @@ bool LLVMIrConstructor::EmitFloatArrayFillInternal(Inst *inst, RuntimeInterface: return true; } -bool LLVMIrConstructor::EmitReadString(Inst *inst) -{ - auto entryId = RuntimeInterface::EntrypointId::CREATE_STRING_FROM_MEM; - auto buf = GetInputValue(inst, 0); - auto len = GetInputValue(inst, 1); - auto klassOffset = GetGraph()->GetRuntime()->GetStringClassPointerTlsOffset(GetGraph()->GetArch()); - auto klass = llvmbackend::runtime_calls::LoadTLSValue(&builder_, arkInterface_, klassOffset, builder_.getPtrTy()); - - auto result = CreateFastPathCall(inst, entryId, {buf, len, klass}); - - MarkAsAllocation(result); - ValueMapAdd(inst, result); - - return true; -} - -bool LLVMIrConstructor::EmitWriteString(Inst *inst) -{ - return EmitFastPath(inst, RuntimeInterface::EntrypointId::WRITE_STRING_TO_MEM, 2U); -} - static RuntimeInterface::EntrypointId GetArrayFastCopyToRefEntrypointId(mem::BarrierType barrierType) { using EntrypointId = RuntimeInterface::EntrypointId; @@ -500,7 +479,6 @@ static RuntimeInterface::EntrypointId GetArrayFastCopyToRefEntrypointId(mem::Bar return EntrypointId::ARRAY_FAST_COPY_TO_REF_SYNC; } } - bool LLVMIrConstructor::EmitArrayFastCopyToRef(Inst *inst) { if (GetGraph()->GetArch() == Arch::AARCH32) { diff --git a/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_h_gen.inl b/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_h_gen.inl index 14305452c3..feb09a7438 100644 --- a/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_h_gen.inl +++ b/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_h_gen.inl @@ -87,9 +87,6 @@ bool EmitBigUInt64ArrayFillInternal(Inst *inst) return EmitFastPath(inst, RuntimeInterface::EntrypointId::BIG_U_INT64_ARRAY_FILL_INTERNAL_FAST_PATH, 4U); } -bool EmitReadString(Inst *inst); -bool EmitWriteString(Inst *inst); - bool EmitInt8ArraySetValuesFromArray(Inst *inst) { return EmitFastPath(inst, RuntimeInterface::EntrypointId::INT8_ARRAY_SET_VALUES_FROM_ARRAY, 2U); diff --git a/static_core/plugins/ets/runtime/ets_entrypoints.cpp b/static_core/plugins/ets/runtime/ets_entrypoints.cpp index 118750e145..96f773bb71 100644 --- a/static_core/plugins/ets/runtime/ets_entrypoints.cpp +++ b/static_core/plugins/ets/runtime/ets_entrypoints.cpp @@ -491,4 +491,33 @@ extern "C" coretypes::String *CreateStringFromCharCodeSingleEntrypoint(uint64_t return EtsString::CreateNewStringFromCharCode(bit_cast(charCode))->GetCoreType(); } +extern "C" int32_t WriteStringToMem(int64_t buf, ObjectHeader *s) +{ + auto str = reinterpret_cast(s); + auto addr = reinterpret_cast(buf); + auto size = static_cast(str->GetUtf8Length()); + + if (str->IsUtf16()) { + if (size != str->CopyDataRegionUtf8(addr, 0, size, size)) { + return -1; + } + } else { + if (memcpy_s(addr, size, str->GetDataMUtf8(), size) != 0) { + return -1; + } + } + return size; +} + +extern "C" ObjectHeader *CreateStringFromMem(int64_t buf, int32_t len) +{ + auto str = EtsString::CreateFromUtf8(reinterpret_cast(buf), static_cast(len)); + return reinterpret_cast(str); +} + +extern "C" int32_t GetStringSizeInBytes(ObjectHeader *str) +{ + return reinterpret_cast(str)->GetUtf8Length(); +} + } // namespace ark::ets diff --git a/static_core/plugins/ets/runtime/ets_entrypoints.yaml b/static_core/plugins/ets/runtime/ets_entrypoints.yaml index 5c7b448605..4cf352ec52 100644 --- a/static_core/plugins/ets/runtime/ets_entrypoints.yaml +++ b/static_core/plugins/ets/runtime/ets_entrypoints.yaml @@ -1223,58 +1223,29 @@ - name: WriteStringToMem entrypoint: WriteStringToMem - bridge: none - properties: [irtoc] + bridge: entrypoint + properties: [] signature: - int32_t # bytes written - int64_t # serialization buffer - ark::ObjectHeader* # string to serialize -- name: WriteStringToMemSlowPath - entrypoint: UnsafeMemoryWriteString - bridge: slow_path - properties: [intrinsic] - signature: - - int32_t # bytes written - - int64_t # serialization buffer - - ark::ObjectHeader* # string to serialize - -- name: WriteStringToMemUsual - entrypoint: UnsafeMemoryWriteString - bridge: entrypoint - properties: [intrinsic] - signature: - - int32_t # bytes written - - int64_t # serialization buffer - - ark::ObjectHeader* # string to serialize - - name: CreateStringFromMem entrypoint: CreateStringFromMem - bridge: none - properties: [irtoc] + bridge: entrypoint + properties: [] signature: - ark::ObjectHeader* # deserialized string - int64_t # serialization buffer - int32_t # buffer length - - void* # String class object - -- name: CreateStringFromMemSlowPath - entrypoint: UnsafeMemoryReadString - bridge: slow_path - properties: [intrinsic] - signature: - - ark::ObjectHeader* # deserialized string - - void* # serialization buffer - - int32_t # buffer length -- name: CreateStringFromMem3Arg - entrypoint: UnsafeMemoryReadString - bridge: odd_saved3 - properties: [intrinsic] +- name: GetStringSizeInBytes + entrypoint: GetStringSizeInBytes + bridge: entrypoint + properties: [] signature: - - ark::ObjectHeader* # deserialized string - - void* # serialization buffer - - int32_t # buffer length + - int32_t # utf8 size + - ark::ObjectHeader* # String class object - name: Int8ArraySetValuesFromArray entrypoint: Int8ArraySetValuesFromArray diff --git a/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml b/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml index 4a281a2a66..b4a08ffea1 100644 --- a/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml +++ b/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml @@ -4902,9 +4902,7 @@ intrinsics: - i64 - std.core.String impl: ark::ets::intrinsics::UnsafeMemoryWriteString - codegen_arch: [arm64, amd64] codegen_func: CreateWriteString - llvm_codegen_func: EmitWriteString need_param_locations: true clear_flags: [ runtime_call, require_state, can_throw, heap_inv ] @@ -5015,9 +5013,7 @@ intrinsics: - i64 - i32 impl: ark::ets::intrinsics::UnsafeMemoryReadString - codegen_arch: [arm64, amd64] codegen_func: CreateReadString - llvm_codegen_func: EmitReadString need_param_locations: true - name: UnsafeMemoryGetStringSizeInBytes @@ -5029,6 +5025,7 @@ intrinsics: ret: i32 args: - std.core.String + codegen_func: CreateGetSizeInBytes impl: ark::ets::intrinsics::UnsafeMemoryStringGetSizeInBytes clear_flags: [ runtime_call, require_state, can_throw, heap_inv ] diff --git a/static_core/plugins/ets/runtime/intrinsics/unsafe_memory.cpp b/static_core/plugins/ets/runtime/intrinsics/unsafe_memory.cpp index cdbdf88be2..ef8e1ea9e3 100644 --- a/static_core/plugins/ets/runtime/intrinsics/unsafe_memory.cpp +++ b/static_core/plugins/ets/runtime/intrinsics/unsafe_memory.cpp @@ -29,7 +29,14 @@ namespace { /* make sure the class the intrinsic being called from belongs to the boot context */ bool EnsureBootContext() { - auto *coro = EtsCoroutine::GetCurrent(); + [[maybe_unused]] auto *coro = EtsCoroutine::GetCurrent(); + /* if we get here via the compiled code the check has already been done */ +#ifndef NDEBUG + if (!coro->IsRuntimeCallEnabled()) { + return true; + } +#endif +#if 1 auto ctx = StackWalker::Create(coro).GetMethod()->GetClass()->GetLoadContext(); if (!ctx->IsBootContext()) { auto e = panda_file_items::class_descriptors::ILLEGAL_STATE_ERROR; @@ -37,6 +44,7 @@ bool EnsureBootContext() ThrowEtsException(coro, e, msg); return false; } +#endif return true; } @@ -187,9 +195,6 @@ extern "C" void UnsafeMemoryWriteNumber(EtsLong addr, EtsDouble val) UnsafeMemoryWrite(addr, val); } -/* get the size of the buffer to hold the string content add additional - 2 bytes for the leading byte-order mark which is used in the UTF-16 - case */ extern "C" int UnsafeMemoryStringGetSizeInBytes(EtsString *str) { auto coroutine = EtsCoroutine::GetCurrent(); @@ -200,44 +205,22 @@ extern "C" int UnsafeMemoryStringGetSizeInBytes(EtsString *str) return -1; } - str = handle.GetPtr(); - - uint32_t shift = str->IsUtf16() ? 1 : 0; - uint32_t addend = str->IsUtf16() ? 2 : 0; - auto length = static_cast(str->GetLength()); - int size = (length << shift) + addend; - return size; + return handle.GetPtr()->GetUtf8Length(); } -static constexpr uint16_t UTF16_BOM = 0xFEFF; - extern "C" EtsString *UnsafeMemoryReadString(EtsLong buf, int len) { if (!EnsureBootContext()) { return nullptr; } - ObjectHeader *res = nullptr; - auto vm = ManagedThread::GetCurrent()->GetVM(); - auto ctx = Runtime::GetCurrent()->GetLanguageContext(panda_file::SourceLang::ETS); - auto mark = reinterpret_cast(buf); - auto size = static_cast(len); - - if (*mark == UTF16_BOM) { - auto addr = ++mark; - /* size is in bytes but CreateFromUtf16 takes it as chars, so, - we divide it by half and subtract the length of the BOM */ - res = coretypes::String::CreateFromUtf16(addr, (size / 2U) - 1, false, ctx, vm); - } else { - auto addr = reinterpret_cast(buf); - res = coretypes::String::CreateFromMUtf8(addr, size, size, true, ctx, vm); - } - - return reinterpret_cast(res); + return EtsString::CreateFromUtf8(reinterpret_cast(buf), static_cast(len)); } +extern "C" int32_t WriteStringToMem(int64_t buf, ObjectHeader *s); extern "C" int UnsafeMemoryWriteString(EtsLong addrEts, EtsString *str) { + /* we need the scope because EnsureBootContext() will most likely trigger GC */ auto coroutine = EtsCoroutine::GetCurrent(); [[maybe_unused]] HandleScope scope(coroutine); EtsHandle handle(coroutine, str); @@ -247,17 +230,7 @@ extern "C" int UnsafeMemoryWriteString(EtsLong addrEts, EtsString *str) } str = handle.GetPtr(); - - auto addr = reinterpret_cast(addrEts); - auto size = static_cast(str->GetLength()); - if (str->IsUtf16()) { - *reinterpret_cast(addr) = UTF16_BOM; - // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - addr = reinterpret_cast(addr) + 2U; - size <<= 1U; - return memcpy_s(addr, size, str->GetDataUtf16(), size) == 0 ? size + 2U : -1; - } - return memcpy_s(addr, size, str->GetDataMUtf8(), size) == 0 ? size : -1; + return WriteStringToMem(addrEts, reinterpret_cast(str)); } } // namespace ark::ets::intrinsics diff --git a/static_core/plugins/ets/tests/compiler/inst_generator_test_ext.inc b/static_core/plugins/ets/tests/compiler/inst_generator_test_ext.inc index b5fb3ff0bd..146f48ad82 100644 --- a/static_core/plugins/ets/tests/compiler/inst_generator_test_ext.inc +++ b/static_core/plugins/ets/tests/compiler/inst_generator_test_ext.inc @@ -13,7 +13,10 @@ * limitations under the License. */ -if (id == RuntimeInterface::IntrinsicId::INTRINSIC_STD_CORE_SB_APPEND_STRING) { +if (id == RuntimeInterface::IntrinsicId::INTRINSIC_STD_CORE_SB_APPEND_STRING || + id == RuntimeInterface::IntrinsicId::INTRINSIC_UNSAFE_MEMORY_GET_STRING_SIZE_IN_BYTES || + id == RuntimeInterface::IntrinsicId::INTRINSIC_UNSAFE_MEMORY_READ_STRING || + id == RuntimeInterface::IntrinsicId::INTRINSIC_UNSAFE_MEMORY_WRITE_STRING) { // Skip it as this intrinsic requires LocationBuilder to be run successfully. graph->~Graph(); graphCreator_.GetAllocator()->Resize(0U); -- Gitee