diff --git a/static_core/plugins/ets/irtoc_scripts/string.irt b/static_core/plugins/ets/irtoc_scripts/string.irt index 664527fc90ebc9693b1a179db97245fb0af20c87..232bd46b96f0dff4faf4ff02173bb1ad14d2c86c 100644 --- a/static_core/plugins/ets/irtoc_scripts/string.irt +++ b/static_core/plugins/ets/irtoc_scripts/string.irt @@ -33,6 +33,17 @@ module Constants WRONG_CHAR_FLAG_MASK = "0x10000UL" end +macro(:call_runtime_slowpath_for_nonline_string) { |e, str, *args| + + klass := load_class(str) + type := get_string_type(klass) + IfImm(Compare(type, Constants:LINE_STRIGN_TYPE).NE.Unlikely.b { + entry := LoadI(%tr).Imm(e).ptr + CallIndirect(entry, *args) + } +} + + # It is assumed that _begin_index and _end_index are safe and does not check/normalize them. # The range is [_begin_index, _end_index). # Note, a caller of this macro must provide a corresponding 'SlowPathEntrypoint' @@ -270,6 +281,8 @@ function(:StringTrimLeftBase, next end + call_runtime_slowpath_for_nonline_string("StringTrimLeftBase", str, unused1, unused2).void + length_packed := LoadI(str).Imm(Constants::STRING_LENGTH_OFFSET).u32 str_data := Add(Cast(str).SrcType(Constants::COMPILER_REFERENCE).ptr, Cast(Constants::STRING_DATA_OFFSET).word).ptr not_compressed := AndI(length_packed).Imm(1).i32