From b45c61322ed078a62f95bb65f32d02f405ee906d Mon Sep 17 00:00:00 2001 From: Daniel Kofanov Date: Wed, 1 Feb 2023 20:19:41 +0300 Subject: [PATCH] Implement 'RuntimeTesting' builtins Change-Id: Ia71bd135aea5a3514beaea941560194452e4f2d1 Signed-off-by: Daniel Kofanov --- runtime/CMakeLists.txt | 1 + runtime/builtins.cpp | 80 +- runtime/builtins.h | 1 + runtime/builtins/builtins_runtime_testing.cpp | 392 ++++++++++ runtime/builtins/builtins_runtime_testing.h | 144 ++++ runtime/ecma_profiling.h | 33 +- runtime/interpreter/fast_runtime_stub-inl.h | 4 +- runtime/js_method.h | 2 +- runtime/runtime_call_id.h | 725 +++++++++--------- subproject_sources.gn | 1 + 10 files changed, 1024 insertions(+), 359 deletions(-) create mode 100644 runtime/builtins/builtins_runtime_testing.cpp create mode 100644 runtime/builtins/builtins_runtime_testing.h diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 3828b14ec..be90d0c3c 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -81,6 +81,7 @@ set(ECMASCRIPT_SOURCES ${ECMA_SRC_DIR}/builtins/builtins_proxy.cpp ${ECMA_SRC_DIR}/builtins/builtins_reflect.cpp ${ECMA_SRC_DIR}/builtins/builtins_regexp.cpp + ${ECMA_SRC_DIR}/builtins/builtins_runtime_testing.cpp ${ECMA_SRC_DIR}/builtins/builtins_set.cpp ${ECMA_SRC_DIR}/builtins/builtins_string.cpp ${ECMA_SRC_DIR}/builtins/builtins_string_iterator.cpp diff --git a/runtime/builtins.cpp b/runtime/builtins.cpp index 474dfffd6..a26b6b6e6 100644 --- a/runtime/builtins.cpp +++ b/runtime/builtins.cpp @@ -53,6 +53,7 @@ #include "plugins/ecmascript/runtime/builtins/builtins_reflect.h" #include "plugins/ecmascript/runtime/builtins/builtins_regexp.h" #include "plugins/ecmascript/runtime/builtins/builtins_relative_time_format.h" +#include "plugins/ecmascript/runtime/builtins/builtins_runtime_testing.h" #include "plugins/ecmascript/runtime/builtins/builtins_set.h" #include "plugins/ecmascript/runtime/builtins/builtins_string.h" #include "plugins/ecmascript/runtime/builtins/builtins_string_iterator.h" @@ -370,11 +371,15 @@ void Builtins::InitializeGlobalObject(const JSHandle &env, const JSHa JSHandle ark_tools(InitializeArkTools(env)); SetConstantObject(global_object, "ArkTools", ark_tools); } +#ifndef PANDA_PRODUCT_BUILD + JSHandle runtime_testing(InitializeRuntimeTesting(env)); + SetConstantObject(global_object, "RuntimeTesting", runtime_testing); +#endif // PANDA_PRODUCT_BUILD #if ECMASCRIPT_ENABLE_ARK_CONTAINER // Set ArkPrivate - JSHandle arkPrivate(InitializeArkPrivate(env)); - SetConstantObject(globalObject, "ArkPrivate", arkPrivate); + JSHandle ark_private(InitializeArkPrivate(env)); + SetConstantObject(global_object, "ArkPrivate", ark_private); #endif // Global object function @@ -3208,6 +3213,77 @@ JSHandle Builtins::InitializeArkPrivate(const JSHandle &env return ark_private; } +#ifndef PANDA_PRODUCT_BUILD +JSHandle Builtins::InitializeRuntimeTesting(const JSHandle &env) const +{ + JSHandle runtime_testing = factory_->NewEmptyJSObject(); + SetFunction(env, runtime_testing, "GetOptimizationStatus", builtins::BuiltinsRuntimeTesting::GetOptimizationStatus, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "PrepareFunctionForOptimization", + builtins::BuiltinsRuntimeTesting::PrepareFunctionForOptimization, FunctionLength::ONE); + SetFunction(env, runtime_testing, "OptimizeFunctionOnNextCall", + builtins::BuiltinsRuntimeTesting::OptimizeFunctionOnNextCall, FunctionLength::TWO); + SetFunction(env, runtime_testing, "Exit", builtins::BuiltinsRuntimeTesting::Exit, FunctionLength::ONE); + + // Not implemented: + SetFunction(env, runtime_testing, "IsBeingInterpreted", builtins::BuiltinsRuntimeTesting::IsBeingInterpreted, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "DeoptimizeFunction", builtins::BuiltinsRuntimeTesting::DeoptimizeFunction, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "NeverOptimizeFunction", builtins::BuiltinsRuntimeTesting::NeverOptimizeFunction, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "DeoptimizeNow", builtins::BuiltinsRuntimeTesting::DeoptimizeNow, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "_DeoptimizeNow", builtins::BuiltinsRuntimeTesting::_DeoptimizeNow, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "ClearFunctionFeedback", builtins::BuiltinsRuntimeTesting::ClearFunctionFeedback, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "OptimizeOsr", builtins::BuiltinsRuntimeTesting::OptimizeOsr, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "CompleteInobjectSlackTracking", + builtins::BuiltinsRuntimeTesting::CompleteInobjectSlackTracking, FunctionLength::ONE); + SetFunction(env, runtime_testing, "IsDictPropertyConstTrackingEnbled", + builtins::BuiltinsRuntimeTesting::IsDictPropertyConstTrackingEnbled, FunctionLength::ONE); + SetFunction(env, runtime_testing, "StringMaxLength", builtins::BuiltinsRuntimeTesting::StringMaxLength, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "TypedArrayMaxLength", builtins::BuiltinsRuntimeTesting::TypedArrayMaxLength, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "DisableOptimizationFinalization", + builtins::BuiltinsRuntimeTesting::DisableOptimizationFinalization, FunctionLength::ONE); + SetFunction(env, runtime_testing, "WaitForBackgroundOptimization", + builtins::BuiltinsRuntimeTesting::WaitForBackgroundOptimization, FunctionLength::ONE); + SetFunction(env, runtime_testing, "FinalizeOptimization", builtins::BuiltinsRuntimeTesting::FinalizeOptimization, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "ArrayBufferDetach", builtins::BuiltinsRuntimeTesting::ArrayBufferDetach, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "EnsureFeedbackVectorForFunction", + builtins::BuiltinsRuntimeTesting::EnsureFeedbackVectorForFunction, FunctionLength::ONE); + SetFunction(env, runtime_testing, "SimulateNewspaceFull", builtins::BuiltinsRuntimeTesting::SimulateNewspaceFull, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "VerifyType", builtins::BuiltinsRuntimeTesting::VerifyType, FunctionLength::ONE); + SetFunction(env, runtime_testing, "ToFastProperties", builtins::BuiltinsRuntimeTesting::ToFastProperties, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "IsConcurrentRecompilationSupported", + builtins::BuiltinsRuntimeTesting::IsConcurrentRecompilationSupported, FunctionLength::ONE); + SetFunction(env, runtime_testing, "GetUndetectable", builtins::BuiltinsRuntimeTesting::GetUndetectable, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "ToLength", builtins::BuiltinsRuntimeTesting::ToLength, FunctionLength::ONE); + SetFunction(env, runtime_testing, "RunningInSimulator", builtins::BuiltinsRuntimeTesting::RunningInSimulator, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "AllocateHeapNumber", builtins::BuiltinsRuntimeTesting::AllocateHeapNumber, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "PretenureAllocationSite", + builtins::BuiltinsRuntimeTesting::PretenureAllocationSite, FunctionLength::ONE); + SetFunction(env, runtime_testing, "MaxSmi", builtins::BuiltinsRuntimeTesting::MaxSmi, FunctionLength::ONE); + SetFunction(env, runtime_testing, "CreatePrivateSymbol", builtins::BuiltinsRuntimeTesting::CreatePrivateSymbol, + FunctionLength::ONE); + SetFunction(env, runtime_testing, "CreatePrivateNameSymbol", + builtins::BuiltinsRuntimeTesting::CreatePrivateNameSymbol, FunctionLength::ONE); + SetFunction(env, runtime_testing, "Is64Bit", builtins::BuiltinsRuntimeTesting::Is64Bit, FunctionLength::ONE); + return runtime_testing; +} +#endif // PANDA_PRODUCT_BUILD + #ifdef FUZZING_FUZZILLI_BUILTIN void Builtins::InitializeFuzzilli(const JSHandle &env, const JSHandle &objFuncDynclass) { diff --git a/runtime/builtins.h b/runtime/builtins.h index 53a108aeb..ff28cb962 100644 --- a/runtime/builtins.h +++ b/runtime/builtins.h @@ -238,6 +238,7 @@ private: void InitializeGcMarker(const JSHandle &env) const; JSHandle InitializeArkTools(const JSHandle &env) const; JSHandle InitializeArkPrivate(const JSHandle &env) const; + JSHandle InitializeRuntimeTesting(const JSHandle &env) const; void SetConstantObject(const JSHandle &obj, const char *key, JSHandle &value) const; void SetFrozenFunction(const JSHandle &env, const JSHandle &obj, const char *key, EcmaEntrypoint func, int length) const; diff --git a/runtime/builtins/builtins_runtime_testing.cpp b/runtime/builtins/builtins_runtime_testing.cpp new file mode 100644 index 000000000..52add75ff --- /dev/null +++ b/runtime/builtins/builtins_runtime_testing.cpp @@ -0,0 +1,392 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PANDA_PRODUCT_BUILD + +#include "builtins_runtime_testing.h" + +namespace panda::ecmascript::builtins { + +JSTaggedValue BuiltinsRuntimeTesting::GetOptimizationStatus(EcmaRuntimeCallInfo *argv) +{ + ASSERT(argv != nullptr); + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, GetOptimizationStatus); + JSHandle arg_tagged = GetCallArg(argv, 0); + + uint32_t status = 0; + + const auto &opts = Runtime::GetCurrent()->GetOptions(); + bool no_async_jit = Runtime::GetCurrent()->GetPandaVM()->GetCompiler()->IsNoAsyncJit(); + + if (!opts.IsCompilerEnableJit()) { + status |= static_cast(OptimizationStatus::LITE_MODE); + status |= static_cast(OptimizationStatus::NEVER_OPTIMIZE); + } else if ((opts.GetCompilerHotnessThreshold() == 0) && no_async_jit) { + status |= static_cast(OptimizationStatus::ALWAYS_OPTIMIZE); + } + if (arg_tagged->IsCallable()) { + return JSTaggedValue(status); + } + + ASSERT(arg_tagged->IsCallable()); + const auto *method = JSHandle::Cast(arg_tagged)->GetCallTarget(); + status |= static_cast(OptimizationStatus::IS_FUNCTION); + + switch (method->GetCompilationStatus()) { + case Method::NOT_COMPILED: { + if (method->IsDestroyed()) { + status |= static_cast(OptimizationStatus::MARKED_FOR_DEOPTIMIZATION); + } + status |= static_cast(OptimizationStatus::INTERPRETED); + break; + } + case Method::WAITING: { + if (no_async_jit) { + status |= static_cast(OptimizationStatus::MARKED_FOR_OPTIMIZATION); + } else { + status |= static_cast(OptimizationStatus::MARKED_FOR_CONCURRENT_OPTIMIZATION); + } + break; + } + case Method::COMPILATION: { + status |= static_cast(OptimizationStatus::OPTIMIZING_CONCURRENTLY); + break; + } + case Method::COMPILED: { + status |= static_cast(OptimizationStatus::OPTIMIZING_CONCURRENTLY); + break; + } + case Method::FAILED: { + LOG(FATAL, RUNTIME) << "Compilation failure"; + } + } + auto stack = StackWalker::Create(thread); + for (; stack.HasFrame(); stack.NextFrame()) { + if (stack.GetMethod() == method) { + status |= static_cast(OptimizationStatus::IS_EXECUTING); + if (stack.IsCFrame()) { + status |= static_cast(OptimizationStatus::TOPMOST_FRAME_IS_COMPILED); + } else { + status |= static_cast(OptimizationStatus::TOPMOST_FRAME_IS_INTERPRETED); + } + break; + } + } + + // TODO(dkofanov): implement --compiler-deopt-every-n-times + ASSERT((status & static_cast(OptimizationStatus::MAYBE_DEOPTED)) == 0); + + return JSTaggedValue(status); +} + +JSTaggedValue BuiltinsRuntimeTesting::PrepareFunctionForOptimization(EcmaRuntimeCallInfo *argv) +{ + ASSERT(argv != nullptr); + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, PrepareFunctionForOptimization); + JSHandle arg_tagged = GetCallArg(argv, 0); + + ASSERT(arg_tagged->IsCallable()); + auto *js_method = JSHandle::Cast(arg_tagged)->GetCallTarget(); + ASSERT(!js_method->IsNative()); + if (js_method->GetProfilingVector() == nullptr) { + js_method->InitProfileVector(); + ASSERT(js_method->GetProfilingVector() != nullptr); + } + return JSTaggedValue::Undefined(); +} + +JSTaggedValue BuiltinsRuntimeTesting::OptimizeFunctionOnNextCall(EcmaRuntimeCallInfo *argv) +{ + ASSERT(argv != nullptr); + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, OptimizeFunctionOnNextCall); + JSHandle arg_tagged_0 = GetCallArg(argv, 0); + JSHandle arg_tagged_1 = GetCallArg(argv, 1); + + ASSERT(arg_tagged_0->IsCallable()); + auto *js_method = JSHandle::Cast(arg_tagged_0)->GetCallTarget(); + ASSERT(js_method->GetProfilingVector() != nullptr); + + bool is_async = false; + if (!arg_tagged_1->IsUndefined()) { + ASSERT(arg_tagged_1->IsString()); + constexpr size_t STR_LEN = 10; + std::array mode_concurrent = {'c', 'o', 'n', 'c', 'u', 'r', 'r', 'e', 'n', 't', '\0'}; + if (EcmaString::StringsAreEqualUtf8(EcmaString::ConstCast(arg_tagged_1->GetTaggedObject()), + mode_concurrent.data(), STR_LEN, true)) { + is_async = true; + } else { + THROW_TYPE_ERROR_AND_RETURN(thread, "mode is expected to be 'concurrent' or undefined", + JSTaggedValue::Exception()); + } + } + auto *compiler = Runtime::GetCurrent()->GetPandaVM()->GetCompiler(); + ASSERT(!js_method->HasCompiledCode()); + bool saved_async_flag = compiler->IsNoAsyncJit(); + compiler->SetNoAsyncJit(!is_async); + compiler->CompileMethod(js_method, 0, false, arg_tagged_0.GetTaggedValue()); + ASSERT(is_async || js_method->HasCompiledCode()); + compiler->SetNoAsyncJit(saved_async_flag); + return JSTaggedValue::Undefined(); +} + +JSTaggedValue BuiltinsRuntimeTesting::Exit(EcmaRuntimeCallInfo *argv) +{ + ASSERT(argv != nullptr); + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, Exit); + JSHandle arg_tagged = GetCallArg(argv, 0); + + ASSERT(arg_tagged->IsInt()); + Runtime::Halt(arg_tagged->GetInt()); + UNREACHABLE(); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::IsBeingInterpreted([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, IsBeingInterpreted); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::DeoptimizeFunction([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, DeoptimizeFunction); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::NeverOptimizeFunction([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, NeverOptimizeFunction); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::DeoptimizeNow([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, DeoptimizeNow); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::_DeoptimizeNow([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, _DeoptimizeNow); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::ClearFunctionFeedback([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, ClearFunctionFeedback); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::OptimizeOsr([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, OptimizeOsr); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::CompleteInobjectSlackTracking([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, CompleteInobjectSlackTracking); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::IsDictPropertyConstTrackingEnbled([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, IsDictPropertyConstTrackingEnbled); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::StringMaxLength([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, StringMaxLength); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::TypedArrayMaxLength([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, TypedArrayMaxLength); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::DisableOptimizationFinalization([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, DisableOptimizationFinalization); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::WaitForBackgroundOptimization([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, WaitForBackgroundOptimization); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::FinalizeOptimization([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, FinalizeOptimization); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::ArrayBufferDetach([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, ArrayBufferDetach); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::EnsureFeedbackVectorForFunction([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, EnsureFeedbackVectorForFunction); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::SimulateNewspaceFull([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, SimulateNewspaceFull); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::VerifyType([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, VerifyType); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::ToFastProperties([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, ToFastProperties); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::IsConcurrentRecompilationSupported([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, IsConcurrentRecompilationSupported); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::GetUndetectable([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, GetUndetectable); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::ToLength([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, ToLength); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::RunningInSimulator([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, RunningInSimulator); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::AllocateHeapNumber([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, AllocateHeapNumber); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::PretenureAllocationSite([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, PretenureAllocationSite); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::MaxSmi([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, MaxSmi); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::CreatePrivateSymbol([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, CreatePrivateSymbol); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::CreatePrivateNameSymbol([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, CreatePrivateNameSymbol); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} + +// Not implemented +JSTaggedValue BuiltinsRuntimeTesting::Is64Bit([[maybe_unused]] EcmaRuntimeCallInfo *argv) +{ + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, RuntimeTesting, Is64Bit); + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "Builtin is not implemented", JSTaggedValue::Exception()); +} +} // namespace panda::ecmascript::builtins + +#endif // PANDA_PRODUCT_BUILD diff --git a/runtime/builtins/builtins_runtime_testing.h b/runtime/builtins/builtins_runtime_testing.h new file mode 100644 index 000000000..74ce39c0b --- /dev/null +++ b/runtime/builtins/builtins_runtime_testing.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ECMASCRIPT_BUILTINS_BUILTINS_RUNTIME_TESTING_H +#define ECMASCRIPT_BUILTINS_BUILTINS_RUNTIME_TESTING_H +#ifndef PANDA_PRODUCT_BUILD + +#include "plugins/ecmascript/runtime/base/builtins_base.h" +#include "plugins/ecmascript/runtime/ecma_runtime_call_info.h" + +namespace panda::ecmascript::builtins { + +class BuiltinsRuntimeTesting : public base::BuiltinsBase { +public: + // A set of bits returned by GetOptimizationStatus. + enum class OptimizationStatus { + IS_FUNCTION = 1U << 0U, // NOLINT(readability-magic-numbers) + NEVER_OPTIMIZE = 1U << 1U, // NOLINT(readability-magic-numbers) + ALWAYS_OPTIMIZE = 1U << 2U, // NOLINT(readability-magic-numbers) + MAYBE_DEOPTED = 1U << 3U, // NOLINT(readability-magic-numbers) + OPTIMIZED = 1U << 4U, // NOLINT(readability-magic-numbers) + + INTERPRETED = 1U << 7U, // NOLINT(readability-magic-numbers) + MARKED_FOR_OPTIMIZATION = 1U << 8U, // NOLINT(readability-magic-numbers) + MARKED_FOR_CONCURRENT_OPTIMIZATION = 1U << 9U, // NOLINT(readability-magic-numbers) + OPTIMIZING_CONCURRENTLY = 1U << 10U, // NOLINT(readability-magic-numbers) + IS_EXECUTING = 1U << 11U, // NOLINT(readability-magic-numbers) + TOPMOST_FRAME_IS_COMPILED = 1U << 12U, // NOLINT(readability-magic-numbers) + LITE_MODE = 1U << 13U, // NOLINT(readability-magic-numbers) + MARKED_FOR_DEOPTIMIZATION = 1U << 14U, // NOLINT(readability-magic-numbers) + + TOPMOST_FRAME_IS_INTERPRETED = 1U << 16U, // NOLINT(readability-magic-numbers) + + IS_LAZY = 1U << 18U, // NOLINT(readability-magic-numbers) + }; + + static JSTaggedValue GetOptimizationStatus(EcmaRuntimeCallInfo *argv); + static JSTaggedValue PrepareFunctionForOptimization(EcmaRuntimeCallInfo *argv); + static JSTaggedValue OptimizeFunctionOnNextCall(EcmaRuntimeCallInfo *argv); + static JSTaggedValue Exit(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue IsBeingInterpreted(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue DeoptimizeFunction(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue NeverOptimizeFunction(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue DeoptimizeNow(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue _DeoptimizeNow(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue ClearFunctionFeedback(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue OptimizeOsr(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue CompleteInobjectSlackTracking(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue IsDictPropertyConstTrackingEnbled(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue StringMaxLength(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue TypedArrayMaxLength(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue DisableOptimizationFinalization(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue WaitForBackgroundOptimization(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue FinalizeOptimization(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue ArrayBufferDetach(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue EnsureFeedbackVectorForFunction(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue SimulateNewspaceFull(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue VerifyType(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue ToFastProperties(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue IsConcurrentRecompilationSupported(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue GetUndetectable(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue ToLength(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue RunningInSimulator(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue AllocateHeapNumber(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue PretenureAllocationSite(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue MaxSmi(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue CreatePrivateSymbol(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue CreatePrivateNameSymbol(EcmaRuntimeCallInfo *argv); + + // Not implemented + static JSTaggedValue Is64Bit(EcmaRuntimeCallInfo *argv); +}; +} // namespace panda::ecmascript::builtins + +#endif // PANDA_PRODUCT_BUILD +#endif // ECMASCRIPT_BUILTINS_BUILTINS_RUNTIME_TESTING_H \ No newline at end of file diff --git a/runtime/ecma_profiling.h b/runtime/ecma_profiling.h index 1124d174d..ee8c095aa 100644 --- a/runtime/ecma_profiling.h +++ b/runtime/ecma_profiling.h @@ -189,7 +189,10 @@ public: ValueProfileBase() = default; explicit ValueProfileBase(void *prof_data) - : value_(prof_data != nullptr ? *reinterpret_cast(prof_data) : 0) + // Atomic with acquire order reason: profile data may be updated while the compiler thread loads it + : value_(prof_data != nullptr + ? reinterpret_cast *>(prof_data)->load(std::memory_order_acquire) + : 0) { } @@ -244,9 +247,12 @@ public: return ProfilingIndexedAccess(GetOperandType()); } + // NOLINTNEXTLINE(readability-non-const-parameter) static void Update(void *data, ProfilingIndexedAccessBits::Type access_type) { - *(reinterpret_cast(data)) |= OperandType::Encode(access_type); + // Atomic with release order reason: profile data may be updated while the compiler thread loads it + reinterpret_cast *>(data)->store( + *(reinterpret_cast(data)) | OperandType::Encode(access_type), std::memory_order_release); } protected: @@ -271,9 +277,12 @@ public: return ProfilingType(GetOperandType()); } + // NOLINTNEXTLINE(readability-non-const-parameter) static void Update(Base::ValueType *data, JSTaggedValue value) { - *data |= OperandType::Encode(GetTypeFromValue(value)); + // Atomic with release order reason: profile data may be updated while the compiler thread loads it + reinterpret_cast *>(reinterpret_cast(data)) + ->store(*data | OperandType::Encode(GetTypeFromValue(value)), std::memory_order_release); } protected: @@ -303,11 +312,15 @@ public: return ProfilingType(GetField()); } + // NOLINTNEXTLINE(readability-non-const-parameter) static void Update(Base::ValueType *data, JSTaggedValue lhs, JSTaggedValue rhs) { auto ltype = GetTypeFromValue(lhs); auto rtype = GetTypeFromValue(rhs); - *data |= LeftOperandType::Encode(ltype) | RightOperandType::Encode(rtype); + // Atomic with release order reason: profile data may be updated while the compiler thread loads it + reinterpret_cast *>(reinterpret_cast(data)) + ->store(*data | LeftOperandType::Encode(ltype) | RightOperandType::Encode(rtype), + std::memory_order_release); } protected: @@ -333,10 +346,12 @@ public: panda::profiling::CallKind GetCallKind() const { - if (callee_idx_ == MEGAMORPHIC) { + // Atomic with acquire order reason: profile data may be updated while the compiler thread loads it + auto callee_idx = reinterpret_cast *>(&callee_idx_)->load(std::memory_order_acquire); + if (callee_idx == MEGAMORPHIC) { return panda::profiling::CallKind::MEGAMORPHIC; } - if (callee_idx_ == UNKNOWN) { + if (callee_idx == UNKNOWN) { return panda::profiling::CallKind::UNKNOWN; } return panda::profiling::CallKind::MONOMORPHIC; @@ -363,14 +378,16 @@ public: if (callee_idx_ == UNKNOWN) { auto idx = table->InsertNewObject(js_func); if (idx) { - callee_idx_ = idx.value(); + // Atomic with release order reason: profile data may be updated while the compiler thread loads it + reinterpret_cast *>(&callee_idx_)->store(idx.value(), std::memory_order_release); } return; } ASSERT(callee_idx_ > 0 && callee_idx_ <= std::numeric_limits::max() - 1U); if (table->GetObject(callee_idx_) != js_func) { table->ClearObject(callee_idx_); - callee_idx_ = MEGAMORPHIC; + // Atomic with release order reason: profile data may be updated while the compiler thread loads it + reinterpret_cast *>(&callee_idx_)->store(MEGAMORPHIC, std::memory_order_release); } } diff --git a/runtime/interpreter/fast_runtime_stub-inl.h b/runtime/interpreter/fast_runtime_stub-inl.h index 191a58a89..d4b761b39 100644 --- a/runtime/interpreter/fast_runtime_stub-inl.h +++ b/runtime/interpreter/fast_runtime_stub-inl.h @@ -1078,7 +1078,7 @@ void FastRuntimeStub::SetOwnPropertyByName(JSThread *thread, JSTaggedValue recei INTERPRETER_TRACE(thread, SetOwnPropertyByName); TaggedArray *properties = TaggedArray::Cast(JSObject::Cast(receiver)->GetProperties().GetHeapObject()); PropertyAttributes attr; - uint32_t index_or_entry; + uint32_t index_or_entry = 0; JSTaggedValue val = FindOwnProperty(thread, JSObject::Cast(receiver), properties, key, &attr, &index_or_entry); if (!val.IsHole()) { ASSERT(!attr.IsAccessor() && attr.IsWritable()); @@ -1113,7 +1113,7 @@ bool FastRuntimeStub::SetOwnElement(JSThread *thread, JSTaggedValue receiver, ui INTERPRETER_TRACE(thread, SetOwnElement); [[maybe_unused]] EcmaHandleScope handle_scope(thread); PropertyAttributes attr; - uint32_t index_or_entry; + uint32_t index_or_entry = 0; TaggedArray *elements = TaggedArray::Cast(JSObject::Cast(receiver)->GetElements().GetHeapObject()); bool is_dict = elements->IsDictionaryMode(); [[maybe_unused]] JSTaggedValue val = FindOwnElement(elements, index, is_dict, &attr, &index_or_entry); diff --git a/runtime/js_method.h b/runtime/js_method.h index f13f65fd9..b16507aaa 100644 --- a/runtime/js_method.h +++ b/runtime/js_method.h @@ -128,7 +128,7 @@ public: JSTaggedValue GetLength() const; - uint8_t *GetProfilingVector() + uint8_t *GetProfilingVector() const { return profiling_data_.get(); } diff --git a/runtime/runtime_call_id.h b/runtime/runtime_call_id.h index 42e11503d..0906412a1 100644 --- a/runtime/runtime_call_id.h +++ b/runtime/runtime_call_id.h @@ -243,352 +243,385 @@ namespace panda::ecmascript { V(GreaterEqDynWithIC) \ V(SetPropertyByName) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define BUITINS_API_LIST(V) \ - V(Array, Constructor) \ - V(Array, From) \ - V(Array, Of) \ - V(Array, IsArray) \ - V(Array, Entries) \ - V(Array, Species) \ - V(Array, Concat) \ - V(Array, CopyWithin) \ - V(Array, FlatMap) \ - V(Array, Flat) \ - V(Array, Fill) \ - V(Array, Filter) \ - V(Array, Find) \ - V(Array, FindIndex) \ - V(Array, Includes) \ - V(Array, IndexOf) \ - V(Array, Join) \ - V(Array, Keys) \ - V(Array, LastIndexOf) \ - V(Array, Map) \ - V(Array, Pop) \ - V(Array, Push) \ - V(Array, Reduce) \ - V(Array, ReduceRight) \ - V(Array, Reverse) \ - V(Array, Shift) \ - V(Array, Slice) \ - V(Array, Some) \ - V(Array, Sort) \ - V(Array, Splice) \ - V(Array, ToLocaleString) \ - V(Array, ToString) \ - V(Array, Unshift) \ - V(Array, Values) \ - V(ArrayBuffer, Constructor) \ - V(ArrayBuffer, Slice) \ - V(ArrayBuffer, GetValueFromBuffer) \ - V(ArrayBuffer, SetValueInBuffer) \ - V(ArrayBuffer, CloneArrayBuffer) \ - V(ArrayBuffer, AllocateArrayBuffer) \ - V(AsyncFunction, Constructor) \ - V(Boolean, Constructor) \ - V(Boolean, ThisBooleanValue) \ - V(DataView, Constructor) \ - V(DataView, GetBuffer) \ - V(DataView, GetByteLength) \ - V(DataView, GetOffset) \ - V(DataView, GetViewValue) \ - V(DataView, SetViewValue) \ - V(Date, Constructor) \ - V(Date, Now) \ - V(Date, UTC) \ - V(Date, Parse) \ - V(Date, GetDateField) \ - V(Date, GetTime) \ - V(Date, SetTime) \ - V(Date, ToJSON) \ - V(Date, ValueOf) \ - V(Date, ToPrimitive) \ - V(Function, Constructor) \ - V(Function, PrototypeApply) \ - V(Function, PrototypeBind) \ - V(Function, PrototypeCall) \ - V(Function, PrototypeToString) \ - V(Function, PrototypeHasInstance) \ - V(Generator, Constructor) \ - V(GeneratorPrototype, Next) \ - V(GeneratorPrototype, Return) \ - V(GeneratorPrototype, Throw) \ - V(AsyncGenerator, Constructor) \ - V(AsyncGeneratorPrototype, Next) \ - V(AsyncGeneratorPrototype, Return) \ - V(AsyncGeneratorPrototype, Throw) \ - V(AsyncFromSyncIteratorPrototype, Next) \ - V(AsyncFromSyncIteratorPrototype, Return) \ - V(AsyncFromSyncIteratorPrototype, Throw) \ - V(Global, IsFinite) \ - V(Global, IsNaN) \ - V(Global, Escape) \ - V(Global, Unescape) \ - V(Global, PrintEntryPoint) \ - V(Global, GCEntrypoint) \ - V(Global, SpecifiedGCEntrypoint) \ - V(Global, WaitForFinishGC) \ - V(Global, ScheduleGCAfterNthAlloc) \ - V(Global, IsScheduledGCTriggered) \ - V(Global, MarkObject) \ - V(Global, GetMarkQueue) \ - V(Global, ClearMarkQueue) \ - V(Global, PinObject) \ - V(Global, UnpinObject) \ - V(Global, GetObjectAddress) \ - V(Global, MarkObjectRecursively) \ - V(Global, AllocateArrayObject) \ - V(Global, GCObjectSpaceType) \ - V(Global, NewobjDynrange) \ - V(Global, CallJsBoundFunction) \ - V(Global, CallJsProxy) \ - V(Global, DecodeURI) \ - V(Global, EncodeURI) \ - V(Global, DecodeURIComponent) \ - V(Global, EncodeURIComponent) \ - V(Iterator, Constructor) \ - V(Iterator, Next) \ - V(Iterator, Throw) \ - V(Iterator, Return) \ - V(Iterator, GetObj) \ - V(Json, Parse) \ - V(Json, Stringify) \ - V(Map, Constructor) \ - V(Map, Species) \ - V(Map, Clear) \ - V(Map, Delete) \ - V(Map, Entries) \ - V(Map, Get) \ - V(Map, Has) \ - V(Map, Keys) \ - V(Map, Set) \ - V(Map, GetSize) \ - V(Map, Values) \ - V(Math, Abs) \ - V(Math, Acos) \ - V(Math, Acosh) \ - V(Math, Asin) \ - V(Math, Asinh) \ - V(Math, Atan) \ - V(Math, Atanh) \ - V(Math, Atan2) \ - V(Math, Cbrt) \ - V(Math, Ceil) \ - V(Math, Clz32) \ - V(Math, Cos) \ - V(Math, Cosh) \ - V(Math, Exp) \ - V(Math, Expm1) \ - V(Math, Floor) \ - V(Math, Fround) \ - V(Math, Hypot) \ - V(Math, Imul) \ - V(Math, Log) \ - V(Math, Log1p) \ - V(Math, Log10) \ - V(Math, Log2) \ - V(Math, Max) \ - V(Math, Min) \ - V(Math, Pow) \ - V(Math, Random) \ - V(Math, Round) \ - V(Math, Sign) \ - V(Math, Sin) \ - V(Math, Sinh) \ - V(Math, Sqrt) \ - V(Math, Tan) \ - V(Math, Tanh) \ - V(Math, Trunc) \ - V(Number, Constructor) \ - V(Number, IsFinite) \ - V(Number, IsInteger) \ - V(Number, IsNaN) \ - V(Number, IsSafeInteger) \ - V(Number, ParseFloat) \ - V(Number, ParseInt) \ - V(Number, ToExponential) \ - V(Number, ToFixed) \ - V(Number, ToLocaleString) \ - V(Number, ToPrecision) \ - V(Number, ToString) \ - V(Number, ValueOf) \ - V(Number, ThisNumberValue) \ - V(BigInt, Constructor) \ - V(BigInt, AsUintN) \ - V(BigInt, AsIntN) \ - V(BigInt, ToLocaleString) \ - V(BigInt, ToString) \ - V(BigInt, ValueOf) \ - V(BigInt, ThisBigIntValue) \ - V(Object, Constructor) \ - V(Object, Assign) \ - V(Object, Create) \ - V(Object, DefineProperties) \ - V(Object, DefineProperty) \ - V(Object, Freeze) \ - V(Object, FromEntries) \ - V(Object, GetOwnPropertyDesciptor) \ - V(Object, GetOwnPropertyDesciptors) \ - V(Object, GetOwnPropertyKeys) \ - V(Object, GetOwnPropertyNames) \ - V(Object, GetOwnPropertySymbols) \ - V(Object, GetPrototypeOf) \ - V(Object, Is) \ - V(Object, Keys) \ - V(Object, PreventExtensions) \ - V(Object, Seal) \ - V(Object, SetPrototypeOf) \ - V(Object, HasOwnProperty) \ - V(Object, IsPrototypeOf) \ - V(Object, ToLocaleString) \ - V(Object, GetBuiltinTag) \ - V(Object, ToString) \ - V(Object, ValueOf) \ - V(Object, ProtoGetter) \ - V(Object, ProtoSetter) \ - V(Object, Values) \ - V(Object, DefineGetter) \ - V(Object, DefineSetter) \ - V(Object, LookupGetter) \ - V(Object, LookupSetter) \ - V(PromiseHandler, Resolve) \ - V(PromiseHandler, Reject) \ - V(PromiseHandler, Executor) \ - V(PromiseHandler, ResolveElementFunction) \ - V(PromiseHandler, AsyncAwaitFulfilled) \ - V(PromiseHandler, AsyncAwaitRejected) \ - V(PromiseJob, Reaction) \ - V(PromiseJob, ResolveThenableJob) \ - V(Promise, Constructor) \ - V(Promise, All) \ - V(Promise, Race) \ - V(Promise, Reject) \ - V(Promise, Resolve) \ - V(Promise, GetSpecies) \ - V(Promise, Catch) \ - V(Promise, Then) \ - V(Promise, PerformPromiseThen) \ - V(Proxy, Constructor) \ - V(Proxy, Revocable) \ - V(Proxy, InvalidateProxyFunction) \ - V(Reflect, Apply) \ - V(Reflect, Constructor) \ - V(Reflect, DefineProperty) \ - V(Reflect, DeleteProperty) \ - V(Reflect, Get) \ - V(Reflect, GetOwnPropertyDescriptor) \ - V(Reflect, GetPrototypeOf) \ - V(Reflect, Has) \ - V(Reflect, OwnKeys) \ - V(Reflect, PreventExtensions) \ - V(Reflect, Set) \ - V(Reflect, SetPrototypeOf) \ - V(RegExp, Constructor) \ - V(RegExp, Exec) \ - V(RegExp, Test) \ - V(RegExp, ToString) \ - V(RegExp, GetFlags) \ - V(RegExp, GetSpecies) \ - V(RegExp, Match) \ - V(RegExp, MatchAll) \ - V(RegExp, Replace) \ - V(RegExp, Search) \ - V(RegExp, Split) \ - V(RegExp, Create) \ - V(Set, Constructor) \ - V(Set, Species) \ - V(Set, Add) \ - V(Set, Clear) \ - V(Set, Delete) \ - V(Set, Entries) \ - V(Set, Has) \ - V(Set, GetSize) \ - V(Set, Values) \ - V(StringIterator, Next) \ - V(String, Constructor) \ - V(String, FromCharCode) \ - V(String, FromCodePoint) \ - V(String, Raw) \ - V(String, GetSubstitution) \ - V(String, CharAt) \ - V(String, CharCodeAt) \ - V(String, CodePointAt) \ - V(String, Concat) \ - V(String, EndsWith) \ - V(String, Includes) \ - V(String, IndexOf) \ - V(String, LastIndexOf) \ - V(String, LocaleCompare) \ - V(String, Match) \ - V(String, MatchAll) \ - V(String, Normalize) \ - V(String, PadEnd) \ - V(String, PadStart) \ - V(String, Repeat) \ - V(String, Replace) \ - V(String, ReplaceAll) \ - V(String, Search) \ - V(String, Slice) \ - V(String, Split) \ - V(String, StartsWith) \ - V(String, Substring) \ - V(String, ToLocaleLowerCase) \ - V(String, ToLocaleUpperCase) \ - V(String, ToLowerCase) \ - V(String, ToString) \ - V(String, ToUpperCase) \ - V(String, Trim) \ - V(String, TrimEnd) \ - V(String, TrimStart) \ - V(String, GetStringIterator) \ - V(String, SubStr) \ - V(Symbol, Constructor) \ - V(Symbol, ToString) \ - V(Symbol, ValueOf) \ - V(Symbol, For) \ - V(Symbol, KeyFor) \ - V(Symbol, DescriptionGetter) \ - V(Symbol, ThisSymbolValue) \ - V(Symbol, ToPrimitive) \ - V(Symbol, SymbolDescriptiveString) \ - V(TypedArray, BaseConstructor) \ - V(TypedArray, From) \ - V(TypedArray, Of) \ - V(TypedArray, Species) \ - V(TypedArray, GetBuffer) \ - V(TypedArray, GetByteLength) \ - V(TypedArray, GetByteOffset) \ - V(TypedArray, CopyWithin) \ - V(TypedArray, Entries) \ - V(TypedArray, Every) \ - V(TypedArray, Filter) \ - V(TypedArray, ForEach) \ - V(TypedArray, Includes) \ - V(TypedArray, Keys) \ - V(TypedArray, GetLength) \ - V(TypedArray, Map) \ - V(TypedArray, Set) \ - V(TypedArray, Slice) \ - V(TypedArray, Sort) \ - V(TypedArray, Subarray) \ - V(TypedArray, Values) \ - V(TypedArray, ToStringTag) \ - V(WeakRef, Constructor) \ - V(WeakRef, Deref) \ - V(WeakMap, Constructor) \ - V(WeakMap, Delete) \ - V(WeakMap, Get) \ - V(WeakMap, Has) \ - V(WeakMap, Set) \ - V(WeakSet, Constructor) \ - V(WeakSet, Delete) \ - V(WeakSet, Add) \ - V(WeakSet, Has) \ - V(ArrayList, Constructor) \ - V(ArrayList, Add) \ - V(ArrayList, Iterator) \ - V(FinalizationRegistry, Constructor) \ - V(FinalizationRegistry, Register) \ +#define BUITINS_API_LIST(V) \ + V(Array, Constructor) \ + V(Array, From) \ + V(Array, Of) \ + V(Array, IsArray) \ + V(Array, Entries) \ + V(Array, Species) \ + V(Array, Concat) \ + V(Array, CopyWithin) \ + V(Array, FlatMap) \ + V(Array, Flat) \ + V(Array, Fill) \ + V(Array, Filter) \ + V(Array, Find) \ + V(Array, FindIndex) \ + V(Array, Includes) \ + V(Array, IndexOf) \ + V(Array, Join) \ + V(Array, Keys) \ + V(Array, LastIndexOf) \ + V(Array, Map) \ + V(Array, Pop) \ + V(Array, Push) \ + V(Array, Reduce) \ + V(Array, ReduceRight) \ + V(Array, Reverse) \ + V(Array, Shift) \ + V(Array, Slice) \ + V(Array, Some) \ + V(Array, Sort) \ + V(Array, Splice) \ + V(Array, ToLocaleString) \ + V(Array, ToString) \ + V(Array, Unshift) \ + V(Array, Values) \ + V(ArrayBuffer, Constructor) \ + V(ArrayBuffer, Slice) \ + V(ArrayBuffer, GetValueFromBuffer) \ + V(ArrayBuffer, SetValueInBuffer) \ + V(ArrayBuffer, CloneArrayBuffer) \ + V(ArrayBuffer, AllocateArrayBuffer) \ + V(AsyncFunction, Constructor) \ + V(Boolean, Constructor) \ + V(Boolean, ThisBooleanValue) \ + V(DataView, Constructor) \ + V(DataView, GetBuffer) \ + V(DataView, GetByteLength) \ + V(DataView, GetOffset) \ + V(DataView, GetViewValue) \ + V(DataView, SetViewValue) \ + V(Date, Constructor) \ + V(Date, Now) \ + V(Date, UTC) \ + V(Date, Parse) \ + V(Date, GetDateField) \ + V(Date, GetTime) \ + V(Date, SetTime) \ + V(Date, ToJSON) \ + V(Date, ValueOf) \ + V(Date, ToPrimitive) \ + V(Function, Constructor) \ + V(Function, PrototypeApply) \ + V(Function, PrototypeBind) \ + V(Function, PrototypeCall) \ + V(Function, PrototypeToString) \ + V(Function, PrototypeHasInstance) \ + V(Generator, Constructor) \ + V(GeneratorPrototype, Next) \ + V(GeneratorPrototype, Return) \ + V(GeneratorPrototype, Throw) \ + V(AsyncGenerator, Constructor) \ + V(AsyncGeneratorPrototype, Next) \ + V(AsyncGeneratorPrototype, Return) \ + V(AsyncGeneratorPrototype, Throw) \ + V(AsyncFromSyncIteratorPrototype, Next) \ + V(AsyncFromSyncIteratorPrototype, Return) \ + V(AsyncFromSyncIteratorPrototype, Throw) \ + V(Global, IsFinite) \ + V(Global, IsNaN) \ + V(Global, Escape) \ + V(Global, Unescape) \ + V(Global, PrintEntryPoint) \ + V(Global, GCEntrypoint) \ + V(Global, SpecifiedGCEntrypoint) \ + V(Global, WaitForFinishGC) \ + V(Global, ScheduleGCAfterNthAlloc) \ + V(Global, IsScheduledGCTriggered) \ + V(Global, MarkObject) \ + V(Global, GetMarkQueue) \ + V(Global, ClearMarkQueue) \ + V(Global, PinObject) \ + V(Global, UnpinObject) \ + V(Global, GetObjectAddress) \ + V(Global, MarkObjectRecursively) \ + V(Global, AllocateArrayObject) \ + V(Global, GCObjectSpaceType) \ + V(Global, NewobjDynrange) \ + V(Global, CallJsBoundFunction) \ + V(Global, CallJsProxy) \ + V(Global, DecodeURI) \ + V(Global, EncodeURI) \ + V(Global, DecodeURIComponent) \ + V(Global, EncodeURIComponent) \ + V(Iterator, Constructor) \ + V(Iterator, Next) \ + V(Iterator, Throw) \ + V(Iterator, Return) \ + V(Iterator, GetObj) \ + V(Json, Parse) \ + V(Json, Stringify) \ + V(Map, Constructor) \ + V(Map, Species) \ + V(Map, Clear) \ + V(Map, Delete) \ + V(Map, Entries) \ + V(Map, Get) \ + V(Map, Has) \ + V(Map, Keys) \ + V(Map, Set) \ + V(Map, GetSize) \ + V(Map, Values) \ + V(Math, Abs) \ + V(Math, Acos) \ + V(Math, Acosh) \ + V(Math, Asin) \ + V(Math, Asinh) \ + V(Math, Atan) \ + V(Math, Atanh) \ + V(Math, Atan2) \ + V(Math, Cbrt) \ + V(Math, Ceil) \ + V(Math, Clz32) \ + V(Math, Cos) \ + V(Math, Cosh) \ + V(Math, Exp) \ + V(Math, Expm1) \ + V(Math, Floor) \ + V(Math, Fround) \ + V(Math, Hypot) \ + V(Math, Imul) \ + V(Math, Log) \ + V(Math, Log1p) \ + V(Math, Log10) \ + V(Math, Log2) \ + V(Math, Max) \ + V(Math, Min) \ + V(Math, Pow) \ + V(Math, Random) \ + V(Math, Round) \ + V(Math, Sign) \ + V(Math, Sin) \ + V(Math, Sinh) \ + V(Math, Sqrt) \ + V(Math, Tan) \ + V(Math, Tanh) \ + V(Math, Trunc) \ + V(Number, Constructor) \ + V(Number, IsFinite) \ + V(Number, IsInteger) \ + V(Number, IsNaN) \ + V(Number, IsSafeInteger) \ + V(Number, ParseFloat) \ + V(Number, ParseInt) \ + V(Number, ToExponential) \ + V(Number, ToFixed) \ + V(Number, ToLocaleString) \ + V(Number, ToPrecision) \ + V(Number, ToString) \ + V(Number, ValueOf) \ + V(Number, ThisNumberValue) \ + V(BigInt, Constructor) \ + V(BigInt, AsUintN) \ + V(BigInt, AsIntN) \ + V(BigInt, ToLocaleString) \ + V(BigInt, ToString) \ + V(BigInt, ValueOf) \ + V(BigInt, ThisBigIntValue) \ + V(Object, Constructor) \ + V(Object, Assign) \ + V(Object, Create) \ + V(Object, DefineProperties) \ + V(Object, DefineProperty) \ + V(Object, Freeze) \ + V(Object, FromEntries) \ + V(Object, GetOwnPropertyDesciptor) \ + V(Object, GetOwnPropertyDesciptors) \ + V(Object, GetOwnPropertyKeys) \ + V(Object, GetOwnPropertyNames) \ + V(Object, GetOwnPropertySymbols) \ + V(Object, GetPrototypeOf) \ + V(Object, Is) \ + V(Object, Keys) \ + V(Object, PreventExtensions) \ + V(Object, Seal) \ + V(Object, SetPrototypeOf) \ + V(Object, HasOwnProperty) \ + V(Object, IsPrototypeOf) \ + V(Object, ToLocaleString) \ + V(Object, GetBuiltinTag) \ + V(Object, ToString) \ + V(Object, ValueOf) \ + V(Object, ProtoGetter) \ + V(Object, ProtoSetter) \ + V(Object, Values) \ + V(Object, DefineGetter) \ + V(Object, DefineSetter) \ + V(Object, LookupGetter) \ + V(Object, LookupSetter) \ + V(PromiseHandler, Resolve) \ + V(PromiseHandler, Reject) \ + V(PromiseHandler, Executor) \ + V(PromiseHandler, ResolveElementFunction) \ + V(PromiseHandler, AsyncAwaitFulfilled) \ + V(PromiseHandler, AsyncAwaitRejected) \ + V(PromiseJob, Reaction) \ + V(PromiseJob, ResolveThenableJob) \ + V(Promise, Constructor) \ + V(Promise, All) \ + V(Promise, Race) \ + V(Promise, Reject) \ + V(Promise, Resolve) \ + V(Promise, GetSpecies) \ + V(Promise, Catch) \ + V(Promise, Then) \ + V(Promise, PerformPromiseThen) \ + V(Proxy, Constructor) \ + V(Proxy, Revocable) \ + V(Proxy, InvalidateProxyFunction) \ + V(Reflect, Apply) \ + V(Reflect, Constructor) \ + V(Reflect, DefineProperty) \ + V(Reflect, DeleteProperty) \ + V(Reflect, Get) \ + V(Reflect, GetOwnPropertyDescriptor) \ + V(Reflect, GetPrototypeOf) \ + V(Reflect, Has) \ + V(Reflect, OwnKeys) \ + V(Reflect, PreventExtensions) \ + V(Reflect, Set) \ + V(Reflect, SetPrototypeOf) \ + V(RegExp, Constructor) \ + V(RegExp, Exec) \ + V(RegExp, Test) \ + V(RegExp, ToString) \ + V(RegExp, GetFlags) \ + V(RegExp, GetSpecies) \ + V(RegExp, Match) \ + V(RegExp, MatchAll) \ + V(RegExp, Replace) \ + V(RegExp, Search) \ + V(RegExp, Split) \ + V(RegExp, Create) \ + V(RuntimeTesting, GetOptimizationStatus) \ + V(RuntimeTesting, PrepareFunctionForOptimization) \ + V(RuntimeTesting, OptimizeFunctionOnNextCall) \ + V(RuntimeTesting, Exit) \ + V(RuntimeTesting, IsBeingInterpreted) \ + V(RuntimeTesting, DeoptimizeFunction) \ + V(RuntimeTesting, NeverOptimizeFunction) \ + V(RuntimeTesting, DeoptimizeNow) \ + V(RuntimeTesting, _DeoptimizeNow) \ + V(RuntimeTesting, ClearFunctionFeedback) \ + V(RuntimeTesting, OptimizeOsr) \ + V(RuntimeTesting, CompleteInobjectSlackTracking) \ + V(RuntimeTesting, IsDictPropertyConstTrackingEnbled) \ + V(RuntimeTesting, StringMaxLength) \ + V(RuntimeTesting, TypedArrayMaxLength) \ + V(RuntimeTesting, DisableOptimizationFinalization) \ + V(RuntimeTesting, WaitForBackgroundOptimization) \ + V(RuntimeTesting, FinalizeOptimization) \ + V(RuntimeTesting, ArrayBufferDetach) \ + V(RuntimeTesting, EnsureFeedbackVectorForFunction) \ + V(RuntimeTesting, SimulateNewspaceFull) \ + V(RuntimeTesting, VerifyType) \ + V(RuntimeTesting, ToFastProperties) \ + V(RuntimeTesting, IsConcurrentRecompilationSupported) \ + V(RuntimeTesting, GetUndetectable) \ + V(RuntimeTesting, ToLength) \ + V(RuntimeTesting, RunningInSimulator) \ + V(RuntimeTesting, AllocateHeapNumber) \ + V(RuntimeTesting, PretenureAllocationSite) \ + V(RuntimeTesting, MaxSmi) \ + V(RuntimeTesting, CreatePrivateSymbol) \ + V(RuntimeTesting, CreatePrivateNameSymbol) \ + V(RuntimeTesting, Is64Bit) \ + V(Set, Constructor) \ + V(Set, Species) \ + V(Set, Add) \ + V(Set, Clear) \ + V(Set, Delete) \ + V(Set, Entries) \ + V(Set, Has) \ + V(Set, GetSize) \ + V(Set, Values) \ + V(StringIterator, Next) \ + V(String, Constructor) \ + V(String, FromCharCode) \ + V(String, FromCodePoint) \ + V(String, Raw) \ + V(String, GetSubstitution) \ + V(String, CharAt) \ + V(String, CharCodeAt) \ + V(String, CodePointAt) \ + V(String, Concat) \ + V(String, EndsWith) \ + V(String, Includes) \ + V(String, IndexOf) \ + V(String, LastIndexOf) \ + V(String, LocaleCompare) \ + V(String, Match) \ + V(String, MatchAll) \ + V(String, Normalize) \ + V(String, PadEnd) \ + V(String, PadStart) \ + V(String, Repeat) \ + V(String, Replace) \ + V(String, ReplaceAll) \ + V(String, Search) \ + V(String, Slice) \ + V(String, Split) \ + V(String, StartsWith) \ + V(String, Substring) \ + V(String, ToLocaleLowerCase) \ + V(String, ToLocaleUpperCase) \ + V(String, ToLowerCase) \ + V(String, ToString) \ + V(String, ToUpperCase) \ + V(String, Trim) \ + V(String, TrimEnd) \ + V(String, TrimStart) \ + V(String, GetStringIterator) \ + V(String, SubStr) \ + V(Symbol, Constructor) \ + V(Symbol, ToString) \ + V(Symbol, ValueOf) \ + V(Symbol, For) \ + V(Symbol, KeyFor) \ + V(Symbol, DescriptionGetter) \ + V(Symbol, ThisSymbolValue) \ + V(Symbol, ToPrimitive) \ + V(Symbol, SymbolDescriptiveString) \ + V(TypedArray, BaseConstructor) \ + V(TypedArray, From) \ + V(TypedArray, Of) \ + V(TypedArray, Species) \ + V(TypedArray, GetBuffer) \ + V(TypedArray, GetByteLength) \ + V(TypedArray, GetByteOffset) \ + V(TypedArray, CopyWithin) \ + V(TypedArray, Entries) \ + V(TypedArray, Every) \ + V(TypedArray, Filter) \ + V(TypedArray, ForEach) \ + V(TypedArray, Includes) \ + V(TypedArray, Keys) \ + V(TypedArray, GetLength) \ + V(TypedArray, Map) \ + V(TypedArray, Set) \ + V(TypedArray, Slice) \ + V(TypedArray, Sort) \ + V(TypedArray, Subarray) \ + V(TypedArray, Values) \ + V(TypedArray, ToStringTag) \ + V(WeakRef, Constructor) \ + V(WeakRef, Deref) \ + V(WeakMap, Constructor) \ + V(WeakMap, Delete) \ + V(WeakMap, Get) \ + V(WeakMap, Has) \ + V(WeakMap, Set) \ + V(WeakSet, Constructor) \ + V(WeakSet, Delete) \ + V(WeakSet, Add) \ + V(WeakSet, Has) \ + V(ArrayList, Constructor) \ + V(ArrayList, Add) \ + V(ArrayList, Iterator) \ + V(FinalizationRegistry, Constructor) \ + V(FinalizationRegistry, Register) \ V(FinalizationRegistry, Unregister) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) diff --git a/subproject_sources.gn b/subproject_sources.gn index 96121b6ff..28616162e 100644 --- a/subproject_sources.gn +++ b/subproject_sources.gn @@ -110,6 +110,7 @@ srcs_runtime = [ "runtime/builtins/builtins_proxy.cpp", "runtime/builtins/builtins_reflect.cpp", "runtime/builtins/builtins_regexp.cpp", + "runtime/builtins/builtins_runtime_testing.cpp", "runtime/builtins/builtins_set.cpp", "runtime/builtins/builtins_string.cpp", "runtime/builtins/builtins_string_iterator.cpp", -- Gitee