From f52363e01e5037e424cf2fe2ca7e478db533a56f Mon Sep 17 00:00:00 2001 From: lijincheng Date: Wed, 6 Aug 2025 20:27:19 +0800 Subject: [PATCH] Remove redundant etscall in Math.random 1. call native directly Issue:[Bug]: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICRNL8 Signed-off-by: lijincheng --- .../plugins/ets/runtime/ets_libbase_runtime.yaml | 10 ++++++++++ static_core/plugins/ets/stdlib/escompat/Math.ets | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml b/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml index e8b66b09cf..f71b5ed81d 100644 --- a/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml +++ b/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml @@ -1415,6 +1415,16 @@ intrinsics: impl: ark::intrinsics::MinF64 safe_intrinsic: true + - name: EscompatMathRandom + space: ets + class_name: escompat.Math + method_name: random + static: true + signature: + ret: f64 + args: [ ] + impl: ark::ets::intrinsics::StdMathRandom + ################# # escompat.JSON # ################# diff --git a/static_core/plugins/ets/stdlib/escompat/Math.ets b/static_core/plugins/ets/stdlib/escompat/Math.ets index d99f15a835..dc16a473cf 100644 --- a/static_core/plugins/ets/stdlib/escompat/Math.ets +++ b/static_core/plugins/ets/stdlib/escompat/Math.ets @@ -622,9 +622,7 @@ export class Math { * Initial seed to the random number generator algorithm can be given using {@link seedRandom()} function. * */ - public static random(): double { - return random(); - } + public static native random(): double /** * `v` rounded to nearest integer -- Gitee