diff --git a/BUILD.gn b/BUILD.gn index e68d3d57c16ccf4158b8ac61fef71b6e81bcdf63..028602e91f2fcda1104887f523f0e094f4b54a51 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -138,13 +138,26 @@ ark_isa_gen("isa_gen_ecma_compiler") { ark_gen("ecma_builtins_gen") { data = "$ark_root/plugins/ecmascript/runtime/builtins/templates/builtins.yaml" template_files = [ - "builtins_initializers_gen.h.erb", "builtins_declaration_gen.h.erb", + "builtins_ids_gen.inl.erb", + "builtins_initializers_gen.h.erb", + "builtins_resolve_inlinable_gen.inl.erb", + "builtins_inline_intrinsics_decls_gen.inl.erb", + "builtins_inline_intrinsics_gen.inl.erb" ] sources = "$ark_root/plugins/ecmascript/runtime/builtins/templates" destination = "$target_gen_dir/runtime/builtins/generated" requires = [ "$ark_root/templates/common.rb", + "$ark_root/compiler/optimizer/templates/instructions.rb", + "$ark_root/runtime/templates/intrinsics.rb", "$ark_root/plugins/ecmascript/runtime/builtins/templates/builtins.rb", ] + extra_dependencies = [ + "$ark_root/runtime:arkruntime_gen_intrinsics_yaml" + ] + extra_argv = [ + rebase_path("$target_gen_dir/../../runtime/intrinsics.yaml", root_build_dir), + rebase_path("$ark_root/compiler/optimizer/ir/instructions.yaml", root_build_dir) + ] } diff --git a/compiler/ecma_compiler.yaml b/compiler/ecma_compiler.yaml index 8e91aa4232c7a3e72b8a7156e763e523ff1f7b6a..0ffc9f44bf7cbb1507519ad0b5c6624d9b71edb6 100644 --- a/compiler/ecma_compiler.yaml +++ b/compiler/ecma_compiler.yaml @@ -25,6 +25,12 @@ options: description: Expand intrinsics into several IR instructions including dynamic call when applicable tags: [perf] +- name: compiler-ecma-inline-builtins + type: bool + default: true + description: Replace dynamic calls of builtins with intrinsics + tags: [perf] + - name: compiler-ecma-newobj-profiling type: bool default: true diff --git a/compiler/inline_intrinsics_ecmascript.cpp b/compiler/inline_intrinsics_ecmascript.cpp index 2a895cf3a41767558477c4f1e5971347db0bf843..5b13747d8be9df40985a0f83b80dbeaf34c7b897 100644 --- a/compiler/inline_intrinsics_ecmascript.cpp +++ b/compiler/inline_intrinsics_ecmascript.cpp @@ -18,6 +18,7 @@ #include "compiler/optimizer/ir/analysis.h" #include "runtime/include/coretypes/tagged_value.h" #include "irtoc_ir_inline.h" +#include "plugins/ecmascript/runtime/runtime_call_id.h" namespace panda::compiler { template @@ -1160,3 +1161,5 @@ void InlineIntrinsics::InlineTryLdGlobalField(IntrinsicInst *inst, uintptr_t add } } // namespace panda::compiler + +#include "plugins/ecmascript/runtime/builtins/generated/builtins_inline_intrinsics_gen.inl" diff --git a/compiler/intrinsics_inline_ecmascript.inl.h b/compiler/intrinsics_inline_ecmascript.inl.h index b7f40549b91040ad8dba32f72c8a4a784c15b2c6..e9e42f53b43fc40692e45bc0a566764ebaa0baca 100644 --- a/compiler/intrinsics_inline_ecmascript.inl.h +++ b/compiler/intrinsics_inline_ecmascript.inl.h @@ -36,6 +36,9 @@ bool InlineLdObjByValue(IntrinsicInst *intrinsic); bool InlineStObjByValue(IntrinsicInst *intrinsic); bool InlineResolveAllocResult(IntrinsicInst *intrinsic); bool InlineTypeOf(IntrinsicInst *intrinsic); + +#include "plugins/ecmascript/runtime/builtins/generated/builtins_inline_intrinsics_decls_gen.inl" + template bool InlineObjByName(IntrinsicInst *intrinsic); template diff --git a/compiler/optimizer/optimizations/ecma_inlining.cpp b/compiler/optimizer/optimizations/ecma_inlining.cpp index 206525615ceee210d9855595175befbe3121fe26..eec5465492aace5e37bc43d47fac36bc0448de38 100644 --- a/compiler/optimizer/optimizations/ecma_inlining.cpp +++ b/compiler/optimizer/optimizations/ecma_inlining.cpp @@ -151,14 +151,15 @@ Graph *EcmaInlining::BuildGraph(InlineContext *ctx, CallInst *call_inst, CallIns void EcmaInlining::BuildGuard(CallInst *call_inst, RuntimeInterface::MethodPtr method_ptr) { - auto method_cnst = GetGraph()->CreateInstLoadImmediate(DataType::POINTER, call_inst->GetPc(), method_ptr, - LoadImmediateInst::ObjectType::METHOD); - auto load_method = GetGraph()->CreateInstLoadObject(DataType::POINTER, call_inst->GetPc()); + auto graph = call_inst->GetBasicBlock()->GetGraph(); + auto method_cnst = graph->CreateInstLoadImmediate(DataType::POINTER, call_inst->GetPc(), method_ptr, + LoadImmediateInst::ObjectType::METHOD); + auto load_method = graph->CreateInstLoadObject(DataType::POINTER, call_inst->GetPc()); load_method->SetObjectType(ObjectType::MEM_DYN_METHOD); load_method->SetTypeId(TypeIdMixin::MEM_DYN_METHOD_ID); load_method->SetInput(0, call_inst->GetInput(0).GetInst()); - auto cmp_inst = GetGraph()->CreateInstCompare(DataType::BOOL, call_inst->GetPc()); - auto deopt_inst = GetGraph()->CreateInstDeoptimizeIf(DataType::BOOL, call_inst->GetPc()); + auto cmp_inst = graph->CreateInstCompare(DataType::BOOL, call_inst->GetPc()); + auto deopt_inst = graph->CreateInstDeoptimizeIf(DataType::BOOL, call_inst->GetPc()); cmp_inst->SetCc(ConditionCode::CC_NE); cmp_inst->SetInput(0, load_method); cmp_inst->SetInput(1, method_cnst); @@ -209,6 +210,11 @@ bool EcmaInlining::DoEcmaMonomorphicInilning(CallInst *call_inst, InlineContext LOG_INLINING(DEBUG) << " instruction: " << *call_inst; LOG_INLINING(DEBUG) << "Method: " << GetGraph()->GetRuntime()->GetMethodFullName(ctx.method, true); + if (OPTIONS.IsCompilerEcmaInlineBuiltins() && CheckInlinableBuiltin(call_inst, ctx.method)) { + // Actual inlining will happen during InlineIntrinsics: + return false; + } + if (!CheckMethod(call_inst, &ctx)) { LOG_INLINING(DEBUG) << "Unsuitable bytecode"; return false; @@ -389,4 +395,14 @@ bool EcmaInlining::TryInline(CallInst *call_inst) return DoEcmaPolymorphicInilning(call_inst); } +bool EcmaInlining::CheckInlinableBuiltin(CallInst *call_inst, RuntimeInterface::MethodPtr method) +{ + if (GetGraph()->GetRuntime()->IsInlinableNativeMethod(method)) { + call_inst->SetCallMethod(method); + ASSERT(!js_functions_.empty()); + return true; + } + return false; +} + } // namespace panda::compiler::ecmascript diff --git a/compiler/optimizer/optimizations/ecma_inlining.h b/compiler/optimizer/optimizations/ecma_inlining.h index 67579f4c33a80ef73b9105147ed0d79b0fe04d0b..a2e1a34bb27525b05cbf76f493df5715bca3cbe5 100644 --- a/compiler/optimizer/optimizations/ecma_inlining.h +++ b/compiler/optimizer/optimizations/ecma_inlining.h @@ -31,6 +31,7 @@ public: NO_MOVE_SEMANTIC(EcmaInlining); NO_COPY_SEMANTIC(EcmaInlining); ~EcmaInlining() override = default; + static void BuildGuard(CallInst *call_inst, RuntimeInterface::MethodPtr method_ptr); private: void RunOptimizations() const override; @@ -47,12 +48,12 @@ private: bool CheckMethod(CallInst *call_inst, InlineContext *ctx); Graph *BuildGraph(InlineContext *ctx, CallInst *call_inst, CallInst *new_call_inst = nullptr); void CreateCompareFunctions(CallInst *call_inst, RuntimeInterface::MethodPtr method_ptr, BasicBlock *call_bb); - void BuildGuard(CallInst *call_inst, RuntimeInterface::MethodPtr method_ptr); void InsertGraph(CallInst *call_inst, const InlineContext &ctx, Graph *graph_inl); bool IsStaticInlining() const { return js_functions_.empty(); } + bool CheckInlinableBuiltin(CallInst *call_inst, RuntimeInterface::MethodPtr native_method); bool IsMonomorphicInlining() const { diff --git a/ecmascript_plugin_options.yaml b/ecmascript_plugin_options.yaml index ea781fe6c89e9431ceb7f8b285e5d408b8415e12..9561815014ea8f088396112ddd1dc593e56b31ca 100644 --- a/ecmascript_plugin_options.yaml +++ b/ecmascript_plugin_options.yaml @@ -75,6 +75,7 @@ Intrinsics: intrinsics_inline_inl_h: plugins/ecmascript/compiler/intrinsics_inline_ecmascript.inl.h intrinsics_graph_checker_inl: plugins/ecmascript/compiler/intrinsics_graph_checker.h + inlinable_native: true Metadatas: - RecordMetadata: new_class_name: panda::pandasm::extensions::ecmascript::RecordMetadata diff --git a/runtime/builtins/CMakeLists.txt b/runtime/builtins/CMakeLists.txt index 4499b9dff9758c1cf4135d8996d5337e2159100d..5ac1673185e242b02d973833ca7d869a781408c3 100644 --- a/runtime/builtins/CMakeLists.txt +++ b/runtime/builtins/CMakeLists.txt @@ -1,16 +1,25 @@ set(BUILTIN_TEMPLATES - builtins_initializers_gen.h.erb builtins_declaration_gen.h.erb + builtins_ids_gen.inl.erb + builtins_initializers_gen.h.erb + builtins_resolve_inlinable_gen.inl.erb + builtins_inline_intrinsics_decls_gen.inl.erb + builtins_inline_intrinsics_gen.inl.erb ) +set(INTRINSICS_YAML_PATH ${PANDA_BINARY_ROOT}/runtime/intrinsics.yaml) +set(INSTRUCTIONS_YAML_PATH ${PANDA_ROOT}/compiler/optimizer/ir/instructions.yaml) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated) panda_gen( DATA ${CMAKE_CURRENT_SOURCE_DIR}/templates/builtins.yaml TARGET_NAME ecma_builtins_gen TEMPLATES ${BUILTIN_TEMPLATES} - REQUIRES ${PANDA_ROOT}/templates/common.rb ${CMAKE_CURRENT_SOURCE_DIR}/templates/builtins.rb + REQUIRES ${PANDA_ROOT}/templates/common.rb ${PANDA_ROOT}/compiler/optimizer/templates/instructions.rb ${PANDA_ROOT}/runtime/templates/intrinsics.rb ${CMAKE_CURRENT_SOURCE_DIR}/templates/builtins.rb SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/templates DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/generated + EXTRA_ARGV ${INTRINSICS_YAML_PATH} ${INSTRUCTIONS_YAML_PATH} + EXTRA_DEPENDENCIES arkruntime_gen_intrinsics_yaml ) add_dependencies(intrinsics_gen_arkruntime ecma_builtins_gen) diff --git a/runtime/builtins/builtins_array.cpp b/runtime/builtins/builtins_array.cpp index 579ce0c896ba903c700bba5f432747d229e333a3..bae552acabc3fe7c581dd0c459dbcc8ad329806a 100644 --- a/runtime/builtins/builtins_array.cpp +++ b/runtime/builtins/builtins_array.cpp @@ -44,7 +44,7 @@ constexpr uint8_t INDEX_TWO = 2; JSTaggedValue builtins::array::ArrayConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), Array, ArrayConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -392,7 +392,7 @@ JSTaggedValue builtins::array::GetSpecies([[maybe_unused]] EcmaRuntimeCallInfo * JSTaggedValue builtins::array::proto::Concat(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Concat); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Concat); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); uint32_t argc = argv->GetArgsNumber(); @@ -523,7 +523,7 @@ JSTaggedValue builtins::array::proto::Concat(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::CopyWithin(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, CopyWithin); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, CopyWithin); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -647,7 +647,7 @@ JSTaggedValue builtins::array::proto::CopyWithin(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Entries(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Entries); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Entries); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -809,7 +809,7 @@ static JSTaggedValue FlattenIntoArray(JSThread *thread, const JSHandle JSTaggedValue builtins::array::proto::Flat(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Flat); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Flat); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -850,7 +850,7 @@ JSTaggedValue builtins::array::proto::Flat(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::FlatMap(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, FlatMap); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, FlatMap); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); uint32_t argc = argv->GetArgsNumber(); @@ -890,7 +890,7 @@ JSTaggedValue builtins::array::proto::FlatMap(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Fill(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Fill); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Fill); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1053,7 +1053,7 @@ JSTaggedValue builtins::array::proto::Filter(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Find(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Find); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Find); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1113,7 +1113,7 @@ JSTaggedValue builtins::array::proto::Find(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::FindIndex(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, FindIndex); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, FindIndex); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1234,7 +1234,7 @@ JSTaggedValue builtins::array::proto::ForEach(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Includes(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Includes); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Includes); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1310,7 +1310,7 @@ JSTaggedValue builtins::array::proto::Includes(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::IndexOf(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, IndexOf); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, IndexOf); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1389,7 +1389,7 @@ JSTaggedValue builtins::array::proto::IndexOf(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Join(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Join); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Join); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle this_handle = builtins_common::GetThis(argv); @@ -1492,7 +1492,7 @@ JSTaggedValue builtins::array::proto::Join(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Keys(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Keys); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Keys); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -1509,7 +1509,7 @@ JSTaggedValue builtins::array::proto::Keys(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::LastIndexOf(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, LastIndexOf); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, LastIndexOf); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1581,7 +1581,7 @@ JSTaggedValue builtins::array::proto::LastIndexOf(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Map(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Map); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Map); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1658,7 +1658,7 @@ JSTaggedValue builtins::array::proto::Map(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Pop(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Pop); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Pop); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1714,7 +1714,7 @@ JSTaggedValue builtins::array::proto::Pop(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Push(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Push); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Push); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle this_handle = builtins_common::GetThis(argv); @@ -1770,7 +1770,7 @@ JSTaggedValue builtins::array::proto::Push(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Reduce(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Reduce); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Reduce); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); const GlobalEnvConstants *global_const = thread->GlobalConstants(); @@ -1871,7 +1871,7 @@ JSTaggedValue builtins::array::proto::Reduce(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::ReduceRight(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, ReduceRight); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, ReduceRight); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); const GlobalEnvConstants *global_const = thread->GlobalConstants(); @@ -1973,7 +1973,7 @@ JSTaggedValue builtins::array::proto::ReduceRight(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Reverse(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Reverse); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Reverse); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -2075,7 +2075,7 @@ JSTaggedValue builtins::array::proto::Reverse(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Shift(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Shift); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Shift); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -2162,7 +2162,7 @@ JSTaggedValue builtins::array::proto::Shift(EcmaRuntimeCallInfo *argv) // 22.1.3.22 Array.prototype.slice (start, end) JSTaggedValue builtins::array::proto::Slice(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Array, Slice); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Slice); ASSERT(argv); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -2281,7 +2281,7 @@ JSTaggedValue builtins::array::proto::Slice(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Some(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Some); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Some); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -2348,7 +2348,7 @@ JSTaggedValue builtins::array::proto::Some(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Sort(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Sort); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Sort); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -2413,7 +2413,7 @@ JSTaggedValue builtins::array::proto::Sort(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Splice(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Splice); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Splice); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); uint32_t argc = argv->GetArgsNumber(); @@ -2618,7 +2618,7 @@ JSTaggedValue builtins::array::proto::Splice(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::ToLocaleString(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, ToLocaleString); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, ToLocaleString); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); auto ecma_vm = thread->GetEcmaVM(); @@ -2713,7 +2713,7 @@ JSTaggedValue builtins::array::proto::ToLocaleString(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::ToString(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, ToString); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, ToString); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); auto ecma_vm = thread->GetEcmaVM(); @@ -2755,7 +2755,7 @@ JSTaggedValue builtins::array::proto::ToString(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Unshift(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Unshift); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Unshift); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -2848,7 +2848,7 @@ JSTaggedValue builtins::array::proto::Unshift(EcmaRuntimeCallInfo *argv) JSTaggedValue builtins::array::proto::Values(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Array, Values); + BUILTINS_API_TRACE(argv->GetThread(), ArrayPrototype, Values); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); diff --git a/runtime/builtins/builtins_arraybuffer.cpp b/runtime/builtins/builtins_arraybuffer.cpp index 1fd5525c27305d12e285014fdfce524e3fd6915b..9a728008bd802eeb2a84c169272aff7198c2ca1c 100644 --- a/runtime/builtins/builtins_arraybuffer.cpp +++ b/runtime/builtins/builtins_arraybuffer.cpp @@ -53,7 +53,7 @@ union UnionType64 { JSTaggedValue builtins::array_buffer::ArrayBufferConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), ArrayBuffer, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), ArrayBuffer, ArrayBufferConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle new_target = builtins_common::GetNewTarget(argv); @@ -124,7 +124,7 @@ JSTaggedValue builtins::array_buffer::proto::GetByteLength(EcmaRuntimeCallInfo * JSTaggedValue builtins::array_buffer::proto::Slice(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), ArrayBuffer, Slice); + BUILTINS_API_TRACE(argv->GetThread(), ArrayBufferPrototype, Slice); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); diff --git a/runtime/builtins/builtins_bigint.cpp b/runtime/builtins/builtins_bigint.cpp index ede5baf9c8b3b4592c6346848cf1fd5b8f3ee2ef..8380073b8d29b6e6fec027c3a9c76240323e4f86 100644 --- a/runtime/builtins/builtins_bigint.cpp +++ b/runtime/builtins/builtins_bigint.cpp @@ -50,7 +50,7 @@ JSTaggedValue big_int::BigIntConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); JSThread *thread = argv->GetThread(); - BUILTINS_API_TRACE(thread, BigInt, Constructor); + BUILTINS_API_TRACE(thread, BigInt, BigIntConstructor); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle new_target = builtins_common::GetNewTarget(argv); // 1. If NewTarget is not undefined, throw a TypeError exception. @@ -109,7 +109,7 @@ JSTaggedValue big_int::proto::ToLocaleString(EcmaRuntimeCallInfo *argv) { ASSERT(argv); JSThread *thread = argv->GetThread(); - BUILTINS_API_TRACE(thread, BigInt, ToLocaleString); + BUILTINS_API_TRACE(thread, BigIntPrototype, ToLocaleString); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let x be ? ThisBigIntValue(this value). JSTaggedValue value = ThisBigIntValue(argv); @@ -136,7 +136,7 @@ JSTaggedValue big_int::proto::ToString(EcmaRuntimeCallInfo *argv) { ASSERT(argv); JSThread *thread = argv->GetThread(); - BUILTINS_API_TRACE(thread, BigInt, ToString); + BUILTINS_API_TRACE(thread, BigIntPrototype, ToString); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let x be ? thisBigIntValue(this value). @@ -169,7 +169,7 @@ JSTaggedValue big_int::proto::ValueOf(EcmaRuntimeCallInfo *argv) { ASSERT(argv); JSThread *thread = argv->GetThread(); - BUILTINS_API_TRACE(thread, BigInt, ValueOf); + BUILTINS_API_TRACE(thread, BigIntPrototype, ValueOf); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let x be ? thisBigIntValue(this value). return ThisBigIntValue(argv); diff --git a/runtime/builtins/builtins_boolean.cpp b/runtime/builtins/builtins_boolean.cpp index 1d54f4b15e05d8c294d6725c0076fc64e7c1b00b..91273bd3008dc1ac29cd1c9d4a1508c0407fddcc 100644 --- a/runtime/builtins/builtins_boolean.cpp +++ b/runtime/builtins/builtins_boolean.cpp @@ -24,7 +24,7 @@ namespace panda::ecmascript::builtins { JSTaggedValue boolean::BooleanConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Boolean, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), Boolean, BooleanConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let b be ToBoolean(value). diff --git a/runtime/builtins/builtins_dataview.cpp b/runtime/builtins/builtins_dataview.cpp index 879fd4855ff25930b37888c0b853d8b0e9254c51..3853cdc43bae29e52976d395fe461966dd4a1070 100644 --- a/runtime/builtins/builtins_dataview.cpp +++ b/runtime/builtins/builtins_dataview.cpp @@ -27,7 +27,7 @@ namespace panda::ecmascript::builtins { JSTaggedValue data_view::DataViewConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), DataView, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), DataView, DataViewConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle ctor = builtins_common::GetConstructor(argv); @@ -106,7 +106,7 @@ JSTaggedValue data_view::DataViewConstructor(EcmaRuntimeCallInfo *argv) JSTaggedValue data_view::proto::GetBuffer(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), DataView, GetBuffer); + BUILTINS_API_TRACE(argv->GetThread(), DataViewPrototype, GetBuffer); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -130,7 +130,7 @@ JSTaggedValue data_view::proto::GetBuffer(EcmaRuntimeCallInfo *argv) JSTaggedValue data_view::proto::GetByteLength(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), DataView, GetByteLength); + BUILTINS_API_TRACE(argv->GetThread(), DataViewPrototype, GetByteLength); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -160,7 +160,7 @@ JSTaggedValue data_view::proto::GetByteLength(EcmaRuntimeCallInfo *argv) JSTaggedValue data_view::proto::GetByteOffset(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), DataView, GetOffset); + BUILTINS_API_TRACE(argv->GetThread(), DataViewPrototype, GetByteOffset); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. diff --git a/runtime/builtins/builtins_date.cpp b/runtime/builtins/builtins_date.cpp index 86ea474be01bc58e0e61b1b353a83facbfcbaf2d..ac4b8c0552b0755ed92016cab33fe264182a558f 100644 --- a/runtime/builtins/builtins_date.cpp +++ b/runtime/builtins/builtins_date.cpp @@ -39,7 +39,7 @@ static constexpr uint8_t CONSTRUCTOR_MAX_LENGTH = 7; // constructor JSTaggedValue date::DateConstructor(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Date, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), Date, DateConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle new_target = builtins_common::GetNewTarget(argv); @@ -137,7 +137,7 @@ JSTaggedValue date::proto::GetYear(EcmaRuntimeCallInfo *argv) JSTaggedValue date::proto::GetTime(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Date, GetTime); + BUILTINS_API_TRACE(argv->GetThread(), DatePrototype, GetTime); JSThread *thread = argv->GetThread(); JSHandle msg = builtins_common::GetThis(argv); if (!msg->IsDate()) { @@ -149,7 +149,7 @@ JSTaggedValue date::proto::GetTime(EcmaRuntimeCallInfo *argv) JSTaggedValue date::proto::SetTime(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Date, SetTime); + BUILTINS_API_TRACE(argv->GetThread(), DatePrototype, SetTime); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -170,7 +170,7 @@ JSTaggedValue date::proto::SetTime(EcmaRuntimeCallInfo *argv) JSTaggedValue date::proto::ToJSON(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Date, ToJSON); + BUILTINS_API_TRACE(argv->GetThread(), DatePrototype, ToJSON); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -199,7 +199,7 @@ JSTaggedValue date::proto::ToJSON(EcmaRuntimeCallInfo *argv) JSTaggedValue date::proto::ValueOf(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Date, ValueOf); + BUILTINS_API_TRACE(argv->GetThread(), DatePrototype, ValueOf); JSThread *thread = argv->GetThread(); JSHandle msg = builtins_common::GetThis(argv); if (!msg->IsDate()) { @@ -213,7 +213,7 @@ JSTaggedValue date::proto::ValueOf(EcmaRuntimeCallInfo *argv) JSTaggedValue date::proto::ToPrimitive(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Date, ToPrimitive); + BUILTINS_API_TRACE(argv->GetThread(), DatePrototype, ToPrimitive); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); diff --git a/runtime/builtins/builtins_finalization_registry.cpp b/runtime/builtins/builtins_finalization_registry.cpp index dcfe0323f96b89975be77029ac3522943c4b76c2..9aa725de0e867c1497703fec1753af6d9cf04ae7 100644 --- a/runtime/builtins/builtins_finalization_registry.cpp +++ b/runtime/builtins/builtins_finalization_registry.cpp @@ -64,7 +64,7 @@ JSTaggedValue finalization_registry::Constructor(EcmaRuntimeCallInfo *argv) JSTaggedValue finalization_registry::proto::Register(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), FinalizationRegistry, Register); + BUILTINS_API_TRACE(argv->GetThread(), FinalizationRegistryPrototype, Register); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self(builtins_common::GetThis(argv)); @@ -109,7 +109,7 @@ JSTaggedValue finalization_registry::proto::Register(EcmaRuntimeCallInfo *argv) JSTaggedValue finalization_registry::proto::Unregister(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), FinalizationRegistry, Unregister); + BUILTINS_API_TRACE(argv->GetThread(), FinalizationRegistryPrototype, Unregister); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self(builtins_common::GetThis(argv)); diff --git a/runtime/builtins/builtins_function.cpp b/runtime/builtins/builtins_function.cpp index 4ba9201a7a9f17b98b947e183ceb19df21c24e7a..f5bcd288c3202d05cc3ee7b1594595400edaecdc 100644 --- a/runtime/builtins/builtins_function.cpp +++ b/runtime/builtins/builtins_function.cpp @@ -88,7 +88,7 @@ std::pair BuildArgumentsListFast(JSThread *thread, const JSTaggedValue function::proto::Apply(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Function, PrototypeApply); + BUILTINS_API_TRACE(argv->GetThread(), FunctionPrototype, Apply); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -132,7 +132,7 @@ JSTaggedValue function::proto::Apply(EcmaRuntimeCallInfo *argv) JSTaggedValue function::proto::Bind(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Function, PrototypeBind); + BUILTINS_API_TRACE(argv->GetThread(), FunctionPrototype, Bind); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -225,7 +225,7 @@ JSTaggedValue function::proto::Bind(EcmaRuntimeCallInfo *argv) JSTaggedValue function::proto::Call(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Function, PrototypeCall); + BUILTINS_API_TRACE(argv->GetThread(), FunctionPrototype, Call); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -257,7 +257,7 @@ JSTaggedValue function::proto::Call(EcmaRuntimeCallInfo *argv) // ecma 19.2.3.5 Function.prototype.toString () JSTaggedValue function::proto::ToString(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Function, PrototypeToString); + BUILTINS_API_TRACE(argv->GetThread(), FunctionPrototype, ToString); // not implement due to that runtime can not get JS Source Code now. JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -272,7 +272,7 @@ JSTaggedValue function::proto::ToString(EcmaRuntimeCallInfo *argv) // ecma 19.2.3.6 Function.prototype[@@hasInstance] (V) JSTaggedValue function::proto::HasInstance(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Function, PrototypeHasInstance); + BUILTINS_API_TRACE(argv->GetThread(), FunctionPrototype, HasInstance); [[maybe_unused]] EcmaHandleScope handle_scope(argv->GetThread()); // 1. Let F be the this value. JSHandle this_value = builtins_common::GetThis(argv); diff --git a/runtime/builtins/builtins_global.cpp b/runtime/builtins/builtins_global.cpp index 417c9626a71ba4851dbd4ad0693a7349a4f1df90..dc963aba11a627b511c857e57eec391d0acf20a8 100644 --- a/runtime/builtins/builtins_global.cpp +++ b/runtime/builtins/builtins_global.cpp @@ -814,7 +814,7 @@ JSTaggedValue global::Print(EcmaRuntimeCallInfo *argv) } JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); - BUILTINS_API_TRACE(thread, Global, PrintEntryPoint); + BUILTINS_API_TRACE(thread, Global, Print); uint32_t num_args = argv->GetArgsNumber(); for (uint32_t i = 0; i < num_args; i++) { @@ -835,7 +835,7 @@ JSTaggedValue global::Gc(EcmaRuntimeCallInfo *argv) JSThread *thread = argv->GetThread(); ASSERT(thread != nullptr); [[maybe_unused]] EcmaHandleScope handle_scope(thread); - BUILTINS_API_TRACE(thread, Global, GCEntrypoint); + BUILTINS_API_TRACE(thread, Global, Gc); thread->GetEcmaVM()->GetGC()->WaitForGCInManaged(GCTask(GCTaskCause::EXPLICIT_CAUSE)); thread->SafepointPoll(); @@ -881,7 +881,7 @@ JSTaggedValue global::StartGC(EcmaRuntimeCallInfo *argv) JSThread *thread = argv->GetThread(); ASSERT(thread != nullptr); [[maybe_unused]] EcmaHandleScope handle_scope(thread); - BUILTINS_API_TRACE(thread, Global, SpecifiedGCEntrypoint); + BUILTINS_API_TRACE(thread, Global, StartGC); bool run_gc_in_place = Runtime::GetOptions().IsRunGcInPlace("ecmascript"); GCTaskCause reason = GCCauseFromString(thread, builtins_common::GetCallArg(argv, 0)); @@ -961,7 +961,7 @@ JSTaggedValue global::ScheduleGcAfterNthAlloc(EcmaRuntimeCallInfo *argv) { JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); - BUILTINS_API_TRACE(thread, Global, ScheduleGCAfterNthAlloc); + BUILTINS_API_TRACE(thread, Global, ScheduleGcAfterNthAlloc); JSHandle arg = builtins_common::GetCallArg(argv, 0); if (!arg->IsInt()) { JSHandle err = @@ -997,7 +997,7 @@ JSTaggedValue global::ScheduleGcAfterNthAlloc(EcmaRuntimeCallInfo *argv) JSTaggedValue global::IsScheduledGcTriggered(EcmaRuntimeCallInfo *argv) { JSThread *thread = argv->GetThread(); - BUILTINS_API_TRACE(thread, Global, IsScheduledGCTriggered); + BUILTINS_API_TRACE(thread, Global, IsScheduledGcTriggered); EcmaVM *vm = thread->GetEcmaVM(); mem::GCTrigger *trigger = vm->GetGCTrigger(); @@ -1095,7 +1095,7 @@ JSTaggedValue global::ClearMarkQueue(EcmaRuntimeCallInfo *argv) JSTaggedValue gc_marker::MarkObjectRecursively(EcmaRuntimeCallInfo *argv) { JSThread *thread = argv->GetThread(); - BUILTINS_API_TRACE(thread, Global, MarkObjectRecursively); + BUILTINS_API_TRACE(thread, GCMarker, MarkObjectRecursively); mem::GC *gc = thread->GetEcmaVM()->GetGC(); JSHandle arg = builtins_common::GetCallArg(argv, 0); if (!arg->IsHeapObject()) { @@ -1125,7 +1125,7 @@ JSTaggedValue global::GetObjectSpaceType(EcmaRuntimeCallInfo *argv) ASSERT(argv != nullptr); JSThread *thread = argv->GetThread(); ASSERT(thread != nullptr); - BUILTINS_API_TRACE(thread, Global, GCObjectSpaceType); + BUILTINS_API_TRACE(thread, Global, GetObjectSpaceType); JSHandle obj_handle = builtins_common::GetCallArg(argv, 0); auto global_constants = thread->GlobalConstants(); diff --git a/runtime/builtins/builtins_iterator.cpp b/runtime/builtins/builtins_iterator.cpp index c2a3d7ce0b10d3538a74d2e55426d5b770ace69d..8da6a8972a82163ffc22464d5bf1531523f99af1 100644 --- a/runtime/builtins/builtins_iterator.cpp +++ b/runtime/builtins/builtins_iterator.cpp @@ -32,7 +32,7 @@ JSTaggedValue iterator::proto::Throw([[maybe_unused]] EcmaRuntimeCallInfo *argv) JSTaggedValue iterator::proto::Return(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Iterator, Return); + BUILTINS_API_TRACE(argv->GetThread(), IteratorPrototype, Return); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle value = builtins_common::GetCallArg(argv, 0); diff --git a/runtime/builtins/builtins_map.cpp b/runtime/builtins/builtins_map.cpp index 96e1720d68fcc98dcf80d5118743fac607f79fdb..fc4125458ab423dba898d6fdf945f92c42e00376 100644 --- a/runtime/builtins/builtins_map.cpp +++ b/runtime/builtins/builtins_map.cpp @@ -28,7 +28,7 @@ namespace panda::ecmascript::builtins { // 23.1.1.1 JSTaggedValue map::MapConstructor(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Map, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), Map, MapConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -73,7 +73,7 @@ JSTaggedValue map::MapConstructor(EcmaRuntimeCallInfo *argv) // 23.1.3.9 JSTaggedValue map::proto::Set(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Map, Set); + BUILTINS_API_TRACE(argv->GetThread(), MapPrototype, Set); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -95,7 +95,7 @@ JSTaggedValue map::proto::Set(EcmaRuntimeCallInfo *argv) // 23.1.3.1 JSTaggedValue map::proto::Clear(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Map, Clear); + BUILTINS_API_TRACE(argv->GetThread(), MapPrototype, Clear); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -114,7 +114,7 @@ JSTaggedValue map::proto::Clear(EcmaRuntimeCallInfo *argv) // 23.1.3.3 JSTaggedValue map::proto::Delete(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Map, Delete); + BUILTINS_API_TRACE(argv->GetThread(), MapPrototype, Delete); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -133,7 +133,7 @@ JSTaggedValue map::proto::Delete(EcmaRuntimeCallInfo *argv) // 23.1.3.7 JSTaggedValue map::proto::Has(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Map, Has); + BUILTINS_API_TRACE(argv->GetThread(), MapPrototype, Has); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self(builtins_common::GetThis(argv)); @@ -155,7 +155,7 @@ JSTaggedValue map::proto::Has(EcmaRuntimeCallInfo *argv) // 23.1.3.6 JSTaggedValue map::proto::Get(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Map, Get); + BUILTINS_API_TRACE(argv->GetThread(), MapPrototype, Get); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self(builtins_common::GetThis(argv)); @@ -228,7 +228,7 @@ JSTaggedValue map::GetSpecies([[maybe_unused]] EcmaRuntimeCallInfo *argv) // 23.1.3.10 JSTaggedValue map::proto::GetSize(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Map, GetSize); + BUILTINS_API_TRACE(argv->GetThread(), MapPrototype, GetSize); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self(builtins_common::GetThis(argv)); @@ -245,7 +245,7 @@ JSTaggedValue map::proto::GetSize(EcmaRuntimeCallInfo *argv) // 23.1.3.4 JSTaggedValue map::proto::Entries(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Map, Entries); + BUILTINS_API_TRACE(argv->GetThread(), MapPrototype, Entries); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -256,7 +256,7 @@ JSTaggedValue map::proto::Entries(EcmaRuntimeCallInfo *argv) // 23.1.3.8 JSTaggedValue map::proto::Keys(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Map, Keys); + BUILTINS_API_TRACE(argv->GetThread(), MapPrototype, Keys); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -267,7 +267,7 @@ JSTaggedValue map::proto::Keys(EcmaRuntimeCallInfo *argv) // 23.1.3.11 JSTaggedValue map::proto::Values(EcmaRuntimeCallInfo *argv) { - BUILTINS_API_TRACE(argv->GetThread(), Map, Values); + BUILTINS_API_TRACE(argv->GetThread(), MapPrototype, Values); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); diff --git a/runtime/builtins/builtins_number.cpp b/runtime/builtins/builtins_number.cpp index 92c0d9581593eedacf577df9f8a738ce4eb2f459..57e6bf594b0f2366d057426e8cd604c85e03a0f4 100644 --- a/runtime/builtins/builtins_number.cpp +++ b/runtime/builtins/builtins_number.cpp @@ -42,7 +42,7 @@ static JSTaggedNumber ThisNumberValue(EcmaRuntimeCallInfo *argv); JSTaggedValue number::NumberConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Number, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), Number, NumberConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle new_target = builtins_common::GetNewTarget(argv); @@ -228,7 +228,7 @@ JSTaggedValue builtins::number::ParseInt(EcmaRuntimeCallInfo *argv) JSTaggedValue number::proto::ToExponential(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Number, ToExponential); + BUILTINS_API_TRACE(argv->GetThread(), NumberPrototype, ToExponential); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let x be ? thisNumberValue(this value). @@ -276,7 +276,7 @@ JSTaggedValue number::proto::ToExponential(EcmaRuntimeCallInfo *argv) JSTaggedValue number::proto::ToFixed(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Number, ToFixed); + BUILTINS_API_TRACE(argv->GetThread(), NumberPrototype, ToFixed); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let x be ? thisNumberValue(this value). @@ -317,7 +317,7 @@ JSTaggedValue number::proto::ToLocaleString(EcmaRuntimeCallInfo *argv) { ASSERT(argv); JSThread *thread = argv->GetThread(); - BUILTINS_API_TRACE(thread, Number, ToLocaleString); + BUILTINS_API_TRACE(thread, NumberPrototype, ToLocaleString); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let x be ? thisNumberValue(this value). JSTaggedNumber x = ThisNumberValue(argv); @@ -342,7 +342,7 @@ JSTaggedValue number::proto::ToLocaleString(EcmaRuntimeCallInfo *argv) JSTaggedValue number::proto::ToPrecision(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Number, ToPrecision); + BUILTINS_API_TRACE(argv->GetThread(), NumberPrototype, ToPrecision); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let x be ? thisNumberValue(this value). @@ -386,7 +386,7 @@ JSTaggedValue number::proto::ToPrecision(EcmaRuntimeCallInfo *argv) JSTaggedValue number::proto::ToString(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Number, ToString); + BUILTINS_API_TRACE(argv->GetThread(), NumberPrototype, ToString); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let x be ? thisNumberValue(this value). @@ -435,7 +435,7 @@ JSTaggedValue number::proto::ToString(EcmaRuntimeCallInfo *argv) JSTaggedValue number::proto::ValueOf(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Number, ValueOf); + BUILTINS_API_TRACE(argv->GetThread(), NumberPrototype, ValueOf); // 1. Let x be ? thisNumberValue(this value). JSTaggedValue x = ThisNumberValue(argv); JSThread *thread = argv->GetThread(); diff --git a/runtime/builtins/builtins_object.cpp b/runtime/builtins/builtins_object.cpp index d3c956855133c187217bf74c8af7607414c303cd..2ee0b70ea5a35fb79504c35e428ed0dcd4148226 100644 --- a/runtime/builtins/builtins_object.cpp +++ b/runtime/builtins/builtins_object.cpp @@ -42,7 +42,7 @@ JSTaggedValue GetBuiltinTag(JSThread *thread, const JSHandle &object); JSTaggedValue object::ObjectConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), Object, ObjectConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); auto ecma_vm = thread->GetEcmaVM(); @@ -741,7 +741,7 @@ JSTaggedValue object::SetPrototypeOf(EcmaRuntimeCallInfo *argv) JSTaggedValue object::proto::HasOwnProperty(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, HasOwnProperty); + BUILTINS_API_TRACE(argv->GetThread(), ObjectPrototype, HasOwnProperty); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let P be ToPropertyKey(V). @@ -766,7 +766,7 @@ JSTaggedValue object::proto::HasOwnProperty(EcmaRuntimeCallInfo *argv) JSTaggedValue object::proto::IsPrototypeOf(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, IsPrototypeOf); + BUILTINS_API_TRACE(argv->GetThread(), ObjectPrototype, IsPrototypeOf); JSThread *thread = argv->GetThread(); // 1. If Type(V) is not Object, return false. JSHandle msg = builtins_common::GetCallArg(argv, 0); @@ -831,7 +831,7 @@ JSTaggedValue object::proto::PropertyIsEnumerable(EcmaRuntimeCallInfo *argv) JSTaggedValue object::proto::ToLocaleString(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, ToLocaleString); + BUILTINS_API_TRACE(argv->GetThread(), ObjectPrototype, ToLocaleString); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -894,7 +894,7 @@ JSTaggedValue GetBuiltinTag(JSThread *thread, const JSHandle &object) JSTaggedValue object::proto::ToString(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, ToString); + BUILTINS_API_TRACE(argv->GetThread(), ObjectPrototype, ToString); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. If the this value is undefined, return "[object Undefined]". @@ -942,7 +942,7 @@ JSTaggedValue object::proto::ToString(EcmaRuntimeCallInfo *argv) JSTaggedValue object::proto::ValueOf(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, ValueOf); + BUILTINS_API_TRACE(argv->GetThread(), ObjectPrototype, ValueOf); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -956,7 +956,7 @@ JSTaggedValue object::proto::ValueOf(EcmaRuntimeCallInfo *argv) JSTaggedValue object::proto::Get__proto__(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, ProtoGetter); + BUILTINS_API_TRACE(argv->GetThread(), ObjectPrototype, Get__proto__); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -974,7 +974,7 @@ JSTaggedValue object::proto::Get__proto__(EcmaRuntimeCallInfo *argv) JSTaggedValue object::proto::Set__proto__(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, ProtoSetter); + BUILTINS_API_TRACE(argv->GetThread(), ObjectPrototype, Set__proto__); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be RequireObjectCoercible(this value). @@ -1015,7 +1015,7 @@ JSTaggedValue object::proto::Set__proto__(EcmaRuntimeCallInfo *argv) JSTaggedValue object::proto::__defineGetter__(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, DefineGetter); + BUILTINS_API_TRACE(argv->GetThread(), ObjectPrototype, __defineGetter__); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1052,7 +1052,7 @@ JSTaggedValue object::proto::__defineGetter__(EcmaRuntimeCallInfo *argv) JSTaggedValue object::proto::__defineSetter__(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, DefineGetter); + BUILTINS_API_TRACE(argv->GetThread(), ObjectPrototype, __defineSetter__); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1088,7 +1088,7 @@ static JSTaggedValue LookupDesc(EcmaRuntimeCallInfo *argv, const std::function &get_desc) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, DefineGetter); + BUILTINS_API_TRACE(argv->GetThread(), Object, LookupDesc); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1164,7 +1164,7 @@ JSTaggedValue object::proto::CreateRealm(EcmaRuntimeCallInfo *argv) JSTaggedValue object::Entries(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, ToString); + BUILTINS_API_TRACE(argv->GetThread(), Object, Entries); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1185,7 +1185,7 @@ JSTaggedValue object::Entries(EcmaRuntimeCallInfo *argv) JSTaggedValue object::Values(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Object, ToString); + BUILTINS_API_TRACE(argv->GetThread(), Object, Values); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); diff --git a/runtime/builtins/builtins_promise.cpp b/runtime/builtins/builtins_promise.cpp index a3d3190077711a52cfa7bbcb9cc2c27423e457d1..ec72bc7a09719cf7c7a8197f5f07f3ff0eafb33a 100644 --- a/runtime/builtins/builtins_promise.cpp +++ b/runtime/builtins/builtins_promise.cpp @@ -44,7 +44,7 @@ static JSHandle PerformPromiseRace(JSThread *thread, JSTaggedValue promise::PromiseConstructor([[maybe_unused]] EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Promise, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), Promise, PromiseConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); EcmaVM *ecma_vm = thread->GetEcmaVM(); @@ -306,7 +306,7 @@ JSTaggedValue promise::proto::Catch(EcmaRuntimeCallInfo *argv) // 1. Let promise be the this value. // 2. Return Invoke(promise, "then", «undefined, onRejected»). ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Promise, Catch); + BUILTINS_API_TRACE(argv->GetThread(), PromisePrototype, Catch); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); const GlobalEnvConstants *global_const = thread->GlobalConstants(); @@ -323,7 +323,7 @@ JSTaggedValue promise::proto::Catch(EcmaRuntimeCallInfo *argv) JSTaggedValue promise::proto::Then(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Promise, Then); + BUILTINS_API_TRACE(argv->GetThread(), PromisePrototype, Then); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); auto ecma_vm = thread->GetEcmaVM(); diff --git a/runtime/builtins/builtins_promise_job.cpp b/runtime/builtins/builtins_promise_job.cpp index 1bd9ac4fcddb8edc507da60a1471d952e4f21ddb..0db4448c08af0d63f5b7462c4eba082526ba8ce6 100644 --- a/runtime/builtins/builtins_promise_job.cpp +++ b/runtime/builtins/builtins_promise_job.cpp @@ -27,7 +27,7 @@ namespace panda::ecmascript::builtins { JSTaggedValue promise_job::PromiseReactionJob(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), PromiseJob, Reaction); + BUILTINS_API_TRACE(argv->GetThread(), PromiseJob, PromiseReactionJob); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Assert: reaction is a PromiseReaction Record. @@ -84,7 +84,7 @@ JSTaggedValue promise_job::PromiseReactionJob(EcmaRuntimeCallInfo *argv) JSTaggedValue promise_job::PromiseResolveThenableJob(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), PromiseJob, ResolveThenableJob); + BUILTINS_API_TRACE(argv->GetThread(), PromiseJob, PromiseResolveThenableJob); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); const GlobalEnvConstants *global_const = thread->GlobalConstants(); diff --git a/runtime/builtins/builtins_proxy.cpp b/runtime/builtins/builtins_proxy.cpp index 78db8dc833c86304557cbd1c941d0f6ab6496645..f58090c9b9455c794df03c02390cca79b0724da2 100644 --- a/runtime/builtins/builtins_proxy.cpp +++ b/runtime/builtins/builtins_proxy.cpp @@ -28,7 +28,7 @@ static JSTaggedValue InvalidateProxyFunction(EcmaRuntimeCallInfo *argv); JSTaggedValue proxy::ProxyConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Proxy, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), Proxy, ProxyConstructor); [[maybe_unused]] EcmaHandleScope handle_scope(argv->GetThread()); // 1.If NewTarget is undefined, throw a TypeError exception. diff --git a/runtime/builtins/builtins_reflect.cpp b/runtime/builtins/builtins_reflect.cpp index d7974a6d0912413ef1480d3a484a325e21491ff5..ffb41827d29be2df15f4d4fb571a0eaa945ca0f2 100644 --- a/runtime/builtins/builtins_reflect.cpp +++ b/runtime/builtins/builtins_reflect.cpp @@ -52,7 +52,7 @@ JSTaggedValue reflect::Apply(EcmaRuntimeCallInfo *argv) JSTaggedValue reflect::Construct(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Reflect, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), Reflect, Construct); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. If IsConstructor(target) is false, throw a TypeError exception. diff --git a/runtime/builtins/builtins_regexp.cpp b/runtime/builtins/builtins_regexp.cpp index e55ea3a5f5c7ecdd4cc4ada10b349006213de3f7..fcdc8c5ddbb3dfcb3aaac7fc486408a23424ff0a 100644 --- a/runtime/builtins/builtins_regexp.cpp +++ b/runtime/builtins/builtins_regexp.cpp @@ -62,7 +62,7 @@ static JSTaggedValue RegExpReplaceFast(JSThread *thread, JSHandle JSTaggedValue reg_exp::RegExpConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), RegExp, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), RegExp, RegExpConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle new_target_temp = builtins_common::GetNewTarget(argv); @@ -181,7 +181,7 @@ static bool ExecCachingAllowed(JSThread *thread, JSHandle &this_v JSTaggedValue reg_exp::proto::Exec(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), RegExp, Exec); + BUILTINS_API_TRACE(argv->GetThread(), RegExpPrototype, Exec); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let R be the this value. @@ -218,7 +218,7 @@ JSTaggedValue reg_exp::proto::Exec(EcmaRuntimeCallInfo *argv) JSTaggedValue reg_exp::proto::Test(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), RegExp, Test); + BUILTINS_API_TRACE(argv->GetThread(), RegExpPrototype, Test); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let R be the this value. @@ -247,7 +247,7 @@ JSTaggedValue reg_exp::proto::Test(EcmaRuntimeCallInfo *argv) JSTaggedValue reg_exp::proto::ToString(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), RegExp, ToString); + BUILTINS_API_TRACE(argv->GetThread(), RegExpPrototype, ToString); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let R be the this value. @@ -282,7 +282,7 @@ JSTaggedValue reg_exp::proto::ToString(EcmaRuntimeCallInfo *argv) JSTaggedValue reg_exp::proto::GetFlags(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), RegExp, GetFlags); + BUILTINS_API_TRACE(argv->GetThread(), RegExpPrototype, GetFlags); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let R be the this value. @@ -433,7 +433,7 @@ JSTaggedValue reg_exp::GetSpecies(EcmaRuntimeCallInfo *argv) JSTaggedValue reg_exp::proto::Match(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), RegExp, Match); + BUILTINS_API_TRACE(argv->GetThread(), RegExpPrototype, Match); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let rx be the this value. @@ -569,7 +569,7 @@ JSTaggedValue reg_exp::proto::MatchAll(EcmaRuntimeCallInfo *argv) { ASSERT(argv); JSThread *thread = argv->GetThread(); - BUILTINS_API_TRACE(thread, RegExp, MatchAll); + BUILTINS_API_TRACE(thread, RegExpPrototype, MatchAll); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let R be the this value. @@ -766,7 +766,7 @@ JSTaggedValue RegExpReplaceFast(JSThread *thread, JSHandle ®ex JSTaggedValue reg_exp::proto::Replace(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), RegExp, Replace); + BUILTINS_API_TRACE(argv->GetThread(), RegExpPrototype, Replace); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let rx be the this value. @@ -1071,7 +1071,7 @@ JSTaggedValue reg_exp::proto::Replace(EcmaRuntimeCallInfo *argv) JSTaggedValue reg_exp::proto::Search(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), RegExp, Search); + BUILTINS_API_TRACE(argv->GetThread(), RegExpPrototype, Search); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let rx be the this value. @@ -1123,7 +1123,7 @@ JSTaggedValue reg_exp::proto::Search(EcmaRuntimeCallInfo *argv) JSTaggedValue reg_exp::proto::Split(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), RegExp, Split); + BUILTINS_API_TRACE(argv->GetThread(), RegExpPrototype, Split); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); bool use_cache = false; @@ -1782,7 +1782,7 @@ JSTaggedValue RegExpInitialize(JSThread *thread, const JSHandle & JSTaggedValue reg_exp::RegExpCreate(JSThread *thread, const JSHandle &pattern, const JSHandle &flags) { - BUILTINS_API_TRACE(thread, RegExp, Create); + BUILTINS_API_TRACE(thread, RegExp, RegExpCreate); auto ecma_vm = thread->GetEcmaVM(); JSHandle env = ecma_vm->GetGlobalEnv(); JSHandle new_target = env->GetRegExpFunction(); diff --git a/runtime/builtins/builtins_set.cpp b/runtime/builtins/builtins_set.cpp index abe2d158f3cc7b3318bd9383490b885643e27fb7..2327f64c27c274d76af78b4c60a032483054d16b 100644 --- a/runtime/builtins/builtins_set.cpp +++ b/runtime/builtins/builtins_set.cpp @@ -28,7 +28,7 @@ namespace panda::ecmascript::builtins { JSTaggedValue set::SetConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Set, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), Set, SetConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -106,7 +106,7 @@ JSTaggedValue set::SetConstructor(EcmaRuntimeCallInfo *argv) JSTaggedValue set::proto::Add(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Set, Add); + BUILTINS_API_TRACE(argv->GetThread(), SetPrototype, Add); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -127,7 +127,7 @@ JSTaggedValue set::proto::Add(EcmaRuntimeCallInfo *argv) JSTaggedValue set::proto::Clear(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Set, Clear); + BUILTINS_API_TRACE(argv->GetThread(), SetPrototype, Clear); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -145,7 +145,7 @@ JSTaggedValue set::proto::Clear(EcmaRuntimeCallInfo *argv) JSTaggedValue set::proto::Delete(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Set, Delete); + BUILTINS_API_TRACE(argv->GetThread(), SetPrototype, Delete); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -164,7 +164,7 @@ JSTaggedValue set::proto::Delete(EcmaRuntimeCallInfo *argv) JSTaggedValue set::proto::Has(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Set, Has); + BUILTINS_API_TRACE(argv->GetThread(), SetPrototype, Has); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -231,7 +231,7 @@ JSTaggedValue set::GetSpecies([[maybe_unused]] EcmaRuntimeCallInfo *argv) JSTaggedValue set::proto::GetSize(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Set, GetSize); + BUILTINS_API_TRACE(argv->GetThread(), SetPrototype, GetSize); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self(builtins_common::GetThis(argv)); @@ -248,7 +248,7 @@ JSTaggedValue set::proto::GetSize(EcmaRuntimeCallInfo *argv) JSTaggedValue set::proto::Entries(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Set, Entries); + BUILTINS_API_TRACE(argv->GetThread(), SetPrototype, Entries); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -259,7 +259,7 @@ JSTaggedValue set::proto::Entries(EcmaRuntimeCallInfo *argv) JSTaggedValue set::proto::Values(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Set, Values); + BUILTINS_API_TRACE(argv->GetThread(), SetPrototype, Values); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); diff --git a/runtime/builtins/builtins_string.cpp b/runtime/builtins/builtins_string.cpp index a6b955a5155d73b0bed309d82663fca51b57aef7..6b3bc00780db56fef0a67771487a30b6815fb0f6 100644 --- a/runtime/builtins/builtins_string.cpp +++ b/runtime/builtins/builtins_string.cpp @@ -59,7 +59,7 @@ static JSTaggedValue ThisStringValue(JSThread *thread, JSTaggedValue value); JSTaggedValue string::StringConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), String, StringConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -243,7 +243,7 @@ JSTaggedValue string::Raw(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::CharAt(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, CharAt); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, CharAt); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -271,7 +271,7 @@ JSTaggedValue string::proto::CharAt(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::CharCodeAt(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, CharCodeAt); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, CharCodeAt); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle this_tag(JSTaggedValue::RequireObjectCoercible(thread, builtins_common::GetThis(argv))); @@ -298,7 +298,7 @@ JSTaggedValue string::proto::CharCodeAt(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::CodePointAt(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, CodePointAt); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, CodePointAt); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle this_tag(JSTaggedValue::RequireObjectCoercible(thread, builtins_common::GetThis(argv))); @@ -329,7 +329,7 @@ JSTaggedValue string::proto::CodePointAt(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Concat(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Concat); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Concat); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -374,7 +374,7 @@ JSTaggedValue string::proto::Concat(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::EndsWith(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, EndsWith); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, EndsWith); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle this_tag(JSTaggedValue::RequireObjectCoercible(thread, builtins_common::GetThis(argv))); @@ -428,7 +428,7 @@ JSTaggedValue string::proto::EndsWith(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Includes(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Includes); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Includes); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle search_tag = builtins_common::GetCallArg(argv, 0); @@ -478,7 +478,7 @@ JSTaggedValue string::proto::Includes(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::IndexOf(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, IndexOf); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, IndexOf); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle search_tag = builtins_common::GetCallArg(argv, 0); @@ -511,7 +511,7 @@ JSTaggedValue string::proto::IndexOf(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::LastIndexOf(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, LastIndexOf); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, LastIndexOf); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle search_tag = builtins_common::GetCallArg(argv, 0); @@ -562,7 +562,7 @@ JSTaggedValue string::proto::LastIndexOf(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::LocaleCompare(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, LocaleCompare); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, LocaleCompare); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle that_tag = builtins_common::GetCallArg(argv, 0); @@ -579,7 +579,7 @@ JSTaggedValue string::proto::LocaleCompare(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Match(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Match); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Match); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); const GlobalEnvConstants *global_const = thread->GlobalConstants(); @@ -624,7 +624,7 @@ JSTaggedValue string::proto::Match(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::MatchAll(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, MatchAll); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, MatchAll); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); const GlobalEnvConstants *global_const = thread->GlobalConstants(); @@ -688,7 +688,7 @@ JSTaggedValue string::proto::MatchAll(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Normalize(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Normalize); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Normalize); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -776,7 +776,7 @@ JSTaggedValue string::proto::PadStart(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Repeat(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Repeat); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Repeat); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle this_tag(JSTaggedValue::RequireObjectCoercible(thread, builtins_common::GetThis(argv))); @@ -815,7 +815,7 @@ JSTaggedValue string::proto::Repeat(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Replace(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Replace); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Replace); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle this_tag = JSTaggedValue::RequireObjectCoercible(thread, builtins_common::GetThis(argv)); @@ -921,7 +921,7 @@ JSTaggedValue string::proto::ReplaceAll(EcmaRuntimeCallInfo *argv) { ASSERT(argv); JSThread *thread = argv->GetThread(); - BUILTINS_API_TRACE(thread, String, ReplaceAll); + BUILTINS_API_TRACE(thread, StringPrototype, ReplaceAll); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle this_tag = JSTaggedValue::RequireObjectCoercible(thread, builtins_common::GetThis(argv)); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); @@ -1290,7 +1290,7 @@ JSTaggedValue string::GetSubstitution(JSThread *thread, const JSHandleGetThread(), String, Search); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Search); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); const GlobalEnvConstants *global_const = thread->GlobalConstants(); @@ -1325,7 +1325,7 @@ JSTaggedValue string::proto::Search(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Slice(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Slice); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Slice); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1366,7 +1366,7 @@ JSTaggedValue string::proto::Slice(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Split(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Split); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Split); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); auto ecma_vm = thread->GetEcmaVM(); @@ -1472,7 +1472,7 @@ JSTaggedValue string::proto::Split(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::StartsWith(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, StartsWith); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, StartsWith); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle search_tag = builtins_common::GetCallArg(argv, 0); @@ -1527,7 +1527,7 @@ JSTaggedValue string::proto::StartsWith(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Substring(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Substring); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Substring); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1560,7 +1560,7 @@ JSTaggedValue string::proto::Substring(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::ToLocaleLowerCase(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, ToLocaleLowerCase); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, ToLocaleLowerCase); JSThread *thread = argv->GetThread(); EcmaVM *ecma_vm = thread->GetEcmaVM(); ObjectFactory *factory = ecma_vm->GetFactory(); @@ -1629,7 +1629,7 @@ JSTaggedValue string::proto::ToLocaleLowerCase(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::ToLocaleUpperCase(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, ToLocaleLowerCase); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, ToLocaleUpperCase); JSThread *thread = argv->GetThread(); EcmaVM *ecma_vm = thread->GetEcmaVM(); ObjectFactory *factory = ecma_vm->GetFactory(); @@ -1718,7 +1718,7 @@ static std::u16string ToU16String(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::ToLowerCase(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, ToLowerCase); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, ToLowerCase); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); std::u16string u16str_this = ToU16String(argv); @@ -1737,7 +1737,7 @@ JSTaggedValue string::proto::ToString(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::ToUpperCase(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, ToUpperCase); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, ToUpperCase); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); std::u16string u16str_this = ToU16String(argv); @@ -1749,7 +1749,7 @@ JSTaggedValue string::proto::ToUpperCase(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Trim(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Trim); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Trim); JSThread *thread = argv->GetThread(); std::u16string u16str_this = ToU16String(argv); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); @@ -1761,7 +1761,7 @@ JSTaggedValue string::proto::Trim(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::TrimEnd(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Trim); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, TrimEnd); JSThread *thread = argv->GetThread(); std::u16string u16str_this = ToU16String(argv); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); @@ -1773,7 +1773,7 @@ JSTaggedValue string::proto::TrimEnd(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::TrimStart(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, Trim); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, TrimStart); JSThread *thread = argv->GetThread(); std::u16string u16str_this = ToU16String(argv); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); @@ -1792,7 +1792,7 @@ JSTaggedValue string::proto::ValueOf(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Iterator(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, GetStringIterator); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Iterator); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be RequireObjectCoercible(this value). @@ -1809,7 +1809,7 @@ JSTaggedValue string::proto::Iterator(EcmaRuntimeCallInfo *argv) JSTaggedValue string::proto::Substr(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), String, SubStr); + BUILTINS_API_TRACE(argv->GetThread(), StringPrototype, Substr); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); diff --git a/runtime/builtins/builtins_string_iterator.cpp b/runtime/builtins/builtins_string_iterator.cpp index 839d5cc07f075ddd4e87da2162e697dda6b75a0e..9b8f3c591b981807d2170dc8a283bcf550035a67 100644 --- a/runtime/builtins/builtins_string_iterator.cpp +++ b/runtime/builtins/builtins_string_iterator.cpp @@ -27,7 +27,7 @@ namespace panda::ecmascript::builtins { JSTaggedValue string_iterator::proto::Next(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), StringIterator, Next); + BUILTINS_API_TRACE(argv->GetThread(), StringIteratorPrototype, Next); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. diff --git a/runtime/builtins/builtins_symbol.cpp b/runtime/builtins/builtins_symbol.cpp index 14b62ef188993fd481dd10ac8deb9d806dc64312..dd13db1add2883cfe80d6841daadc29aaa1d3dd2 100644 --- a/runtime/builtins/builtins_symbol.cpp +++ b/runtime/builtins/builtins_symbol.cpp @@ -34,7 +34,7 @@ static JSTaggedValue ThisSymbolValue(JSThread *thread, const JSHandleGetThread(), Symbol, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), Symbol, SymbolConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1.If NewTarget is not undefined, throw a TypeError exception. @@ -63,7 +63,7 @@ JSTaggedValue symbol::SymbolConstructor(EcmaRuntimeCallInfo *argv) JSTaggedValue symbol::proto::ToString(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Symbol, ToString); + BUILTINS_API_TRACE(argv->GetThread(), SymbolPrototype, ToString); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1.Let s be the this value. @@ -124,7 +124,7 @@ JSTaggedValue symbol::SymbolDescriptiveString(JSThread *thread, JSTaggedValue sy JSTaggedValue symbol::proto::ValueOf(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Symbol, ValueOf); + BUILTINS_API_TRACE(argv->GetThread(), SymbolPrototype, ValueOf); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // Let s be the this value. @@ -204,7 +204,7 @@ JSTaggedValue symbol::proto::ToPrimitive(EcmaRuntimeCallInfo *argv) { // The allowed values for hint are "default", "number", and "string". ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Symbol, ToPrimitive); + BUILTINS_API_TRACE(argv->GetThread(), SymbolPrototype, ToPrimitive); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1.Let s be the this value. @@ -235,7 +235,7 @@ JSTaggedValue symbol::proto::ToPrimitive(EcmaRuntimeCallInfo *argv) JSTaggedValue symbol::proto::GetDescription(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), Symbol, DescriptionGetter); + BUILTINS_API_TRACE(argv->GetThread(), SymbolPrototype, GetDescription); // 1.Let s be the this value. JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); diff --git a/runtime/builtins/builtins_typedarray.cpp b/runtime/builtins/builtins_typedarray.cpp index b2df033b3664cad70b4a4c080eac5af70a762738..994df1f994dde5cf9ce9ce1c477697cc1c2c646d 100644 --- a/runtime/builtins/builtins_typedarray.cpp +++ b/runtime/builtins/builtins_typedarray.cpp @@ -38,7 +38,7 @@ using TypedArrayHelper = ecmascript::base::TypedArrayHelper; JSTaggedValue typed_array::TypedArrayBaseConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, BaseConstructor); + BUILTINS_API_TRACE(argv->GetThread(), TypedArray, TypedArrayBaseConstructor); THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "TypedArray Constructor cannot be called.", JSTaggedValue::Exception()); } @@ -326,7 +326,7 @@ JSTaggedValue typed_array::GetSpecies(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::GetBuffer(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, GetBuffer); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, GetBuffer); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -350,7 +350,7 @@ JSTaggedValue typed_array::proto::GetBuffer(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::GetByteLength(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, GetByteLength); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, GetByteLength); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -379,7 +379,7 @@ JSTaggedValue typed_array::proto::GetByteLength(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::GetByteOffset(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, GetByteOffset); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, GetByteOffset); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -409,7 +409,7 @@ JSTaggedValue typed_array::proto::GetByteOffset(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::CopyWithin(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, CopyWithin); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, CopyWithin); if (!builtins_common::GetThis(argv)->IsTypedArray()) { THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "This is not a TypedArray.", JSTaggedValue::Exception()); } @@ -420,7 +420,7 @@ JSTaggedValue typed_array::proto::CopyWithin(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::Entries(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, Entries); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, Entries); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -440,7 +440,7 @@ JSTaggedValue typed_array::proto::Entries(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::Every(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, Every); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, Every); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -517,7 +517,7 @@ JSTaggedValue typed_array::proto::Fill(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::Filter(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, Filter); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, Filter); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -620,7 +620,7 @@ JSTaggedValue typed_array::proto::FindIndex(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::ForEach(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, ForEach); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, ForEach); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -681,7 +681,7 @@ JSTaggedValue typed_array::proto::ForEach(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::Includes(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, Includes); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, Includes); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -777,7 +777,7 @@ JSTaggedValue typed_array::proto::Join(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::Keys(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, Keys); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, Keys); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -807,7 +807,7 @@ JSTaggedValue typed_array::proto::LastIndexOf(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::GetLength(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, GetLength); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, GetLength); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -838,7 +838,7 @@ JSTaggedValue typed_array::proto::GetLength(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::Map(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, Map); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, Map); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -930,7 +930,7 @@ JSTaggedValue typed_array::proto::Reverse(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::Set(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, Set); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, Set); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); @@ -1138,7 +1138,7 @@ JSTaggedValue typed_array::proto::Set(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::Slice(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, Slice); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, Slice); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -1278,7 +1278,7 @@ JSTaggedValue typed_array::proto::Some(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::Sort(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, Sort); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, Sort); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); @@ -1327,7 +1327,7 @@ JSTaggedValue typed_array::proto::Sort(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::Subarray(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, Subarray); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, Subarray); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -1414,7 +1414,7 @@ JSTaggedValue typed_array::proto::ToLocaleString(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::Values(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, Values); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, Values); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. @@ -1434,7 +1434,7 @@ JSTaggedValue typed_array::proto::Values(EcmaRuntimeCallInfo *argv) JSTaggedValue typed_array::proto::GetToStringTag(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), TypedArray, ToStringTag); + BUILTINS_API_TRACE(argv->GetThread(), TypedArrayPrototype, GetToStringTag); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); // 1. Let O be the this value. diff --git a/runtime/builtins/builtins_weak_map.cpp b/runtime/builtins/builtins_weak_map.cpp index 1a8bdd844edd4feb99fe84800e20dbe6bcd72365..89b2d02321ccf428131ad1c3f43606b44135203c 100644 --- a/runtime/builtins/builtins_weak_map.cpp +++ b/runtime/builtins/builtins_weak_map.cpp @@ -27,7 +27,7 @@ namespace panda::ecmascript::builtins { JSTaggedValue weak_map::WeakMapConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), WeakMap, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), WeakMap, WeakMapConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -129,7 +129,7 @@ JSTaggedValue weak_map::WeakMapConstructor(EcmaRuntimeCallInfo *argv) JSTaggedValue weak_map::proto::Delete(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), WeakMap, Delete); + BUILTINS_API_TRACE(argv->GetThread(), WeakMapPrototype, Delete); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -151,7 +151,7 @@ JSTaggedValue weak_map::proto::Delete(EcmaRuntimeCallInfo *argv) JSTaggedValue weak_map::proto::Has(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), WeakMap, Has); + BUILTINS_API_TRACE(argv->GetThread(), WeakMapPrototype, Has); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self(builtins_common::GetThis(argv)); @@ -173,7 +173,7 @@ JSTaggedValue weak_map::proto::Has(EcmaRuntimeCallInfo *argv) JSTaggedValue weak_map::proto::Get(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), WeakMap, Get); + BUILTINS_API_TRACE(argv->GetThread(), WeakMapPrototype, Get); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self(builtins_common::GetThis(argv)); @@ -194,7 +194,7 @@ JSTaggedValue weak_map::proto::Get(EcmaRuntimeCallInfo *argv) JSTaggedValue weak_map::proto::Set(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), WeakMap, Set); + BUILTINS_API_TRACE(argv->GetThread(), WeakMapPrototype, Set); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); diff --git a/runtime/builtins/builtins_weak_ref.cpp b/runtime/builtins/builtins_weak_ref.cpp index 5e1ca14ca09154ebf7e6ebf7f5cb925f8d4690b4..297a9108228d11e2c004a0acecbeda0fa62e0373 100644 --- a/runtime/builtins/builtins_weak_ref.cpp +++ b/runtime/builtins/builtins_weak_ref.cpp @@ -54,7 +54,7 @@ JSTaggedValue weak_ref::Constructor(EcmaRuntimeCallInfo *argv) JSTaggedValue weak_ref::proto::Deref(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), WeakRef, Deref); + BUILTINS_API_TRACE(argv->GetThread(), WeakRefPrototype, Deref); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); diff --git a/runtime/builtins/builtins_weak_set.cpp b/runtime/builtins/builtins_weak_set.cpp index 84c446a3bcc377cfb35db386a3c0bbc892b39c4b..c08ef9019efb6c51b247fa5d3cdfdc66286ff7bf 100644 --- a/runtime/builtins/builtins_weak_set.cpp +++ b/runtime/builtins/builtins_weak_set.cpp @@ -27,7 +27,7 @@ namespace panda::ecmascript::builtins { JSTaggedValue weak_set::WeakSetConstructor(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), WeakSet, Constructor); + BUILTINS_API_TRACE(argv->GetThread(), WeakSet, WeakSetConstructor); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -108,7 +108,7 @@ JSTaggedValue weak_set::WeakSetConstructor(EcmaRuntimeCallInfo *argv) JSTaggedValue weak_set::proto::Add(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), WeakSet, Add); + BUILTINS_API_TRACE(argv->GetThread(), WeakSetPrototype, Add); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -136,7 +136,7 @@ JSTaggedValue weak_set::proto::Add(EcmaRuntimeCallInfo *argv) JSTaggedValue weak_set::proto::Delete(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), WeakSet, Delete); + BUILTINS_API_TRACE(argv->GetThread(), WeakSetPrototype, Delete); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); @@ -157,7 +157,7 @@ JSTaggedValue weak_set::proto::Delete(EcmaRuntimeCallInfo *argv) JSTaggedValue weak_set::proto::Has(EcmaRuntimeCallInfo *argv) { ASSERT(argv); - BUILTINS_API_TRACE(argv->GetThread(), WeakSet, Has); + BUILTINS_API_TRACE(argv->GetThread(), WeakSetPrototype, Has); JSThread *thread = argv->GetThread(); [[maybe_unused]] EcmaHandleScope handle_scope(thread); JSHandle self = builtins_common::GetThis(argv); diff --git a/runtime/builtins/templates/builtins.rb b/runtime/builtins/templates/builtins.rb index d12c71bf2930763d07ac45f279c94391a1c6906c..c6aa9ce481b87d09c37485ed985e664a7a492a5e 100644 --- a/runtime/builtins/templates/builtins.rb +++ b/runtime/builtins/templates/builtins.rb @@ -162,6 +162,89 @@ class CtorDescr def argc() @argc end end +class InlinableDescr + def initialize(ostr, argc) + raise "Not OpenStruct" if !ostr.kind_of?(OpenStruct) + raise "Not Integer" if !argc.kind_of?(Integer) + ostr.each_pair do |key, value| + case key.to_s + when "intrinsic" + @intrinsic = Runtime.intrinsics.find { |i| i.name == value } + warn "[Builtins] Warning: Intrinsic `#{value}` not found" if @intrinsic == nil + when "instruction" + @instruction = IR.instructions.find { |i| i.opcode == value } + warn "[Builtins] Warning: Instruction `#{value}` not found" if @instruction == nil + when "args_type" + raise "`args_type` should be an array" if !value.kind_of?(Array) + raise "`args_type` size should be equal to argc" if value.size != argc + @args_type = value + when "res_type" + @res_type = value + else + raise "Unknown field: " + key.to_s + end + end + # check created struct: + raise "Missing `args_type` field" if @args_type == nil + raise "Missing `res_type` field" if @res_type == nil + raise "Invalid `intrinsic` and `instruction` field" if (@intrinsic != nil) && (@instruction != nil) + end + + def GetIRArgType(idx) + "AnyBaseTypeToDataType(AnyBaseType::#{@args_type[idx]})" + end + def GetIRDstType() + "AnyBaseTypeToDataType(AnyBaseType::#{@res_type})" + end + + + def do_inline + str = "" + if @instruction + raise if @intrinsic + str += "auto inlined = + GetGraph()->CreateInst#{@instruction.opcode}(#{GetIRDstType()}, call_inst->GetPc());\n " + @args_type.each_with_index do |arg_type, idx| + str += "inlined->SetInput(#{idx}, saved_inputs_[#{idx}]);\n " + end + else + raise if @instruction + str += "auto inlined = + GetGraph()->CreateInstIntrinsic(#{GetIRDstType()}, call_inst->GetPc(), RuntimeInterface::IntrinsicId::INTRINSIC_#{@intrinsic.enum_name});\n " + if @intrinsic.clear_flags.include? "require_state" + str += "inlined->ReserveInputs(#{@args_type.size}); + inlined->AllocateInputTypes(GetGraph()->GetAllocator(), #{@args_type.size});\n " + else + str += "inlined->ReserveInputs(#{@args_type.size + 1}); + inlined->AllocateInputTypes(GetGraph()->GetAllocator(), #{@args_type.size + 1});\n " + end + @args_type.each_with_index do |arg_type, idx| + str += "inlined->AppendInput(saved_inputs_[#{idx}]);\n " + str += "inlined->AddInputType(#{IR.get_ir_type(@intrinsic.signature.args[idx])});\n " + end + if !@intrinsic.clear_flags.include? "require_state" + str += "inlined->AppendInput(call_inst->GetSaveState());\n " + str += "inlined->AddInputType(DataType::NO_TYPE);\n " + end + end + + str += " + call_inst->InsertAfter(inlined); + auto cast_to_any_inst = GetGraph()->CreateInstCastValueToAnyType(DataType::ANY, call_inst->GetPc()); + cast_to_any_inst->SetAnyType(AnyBaseType::#{@res_type}); + cast_to_any_inst->SetInput(0, inlined); + call_inst->ReplaceUsers(cast_to_any_inst); + inlined->InsertAfter(cast_to_any_inst); + call_inst->GetBasicBlock()->RemoveInst(call_inst); + " + end + + def intrinsic() @intrinsic end + def instruction() @instruction end + def args_type() @args_type end + def res_type() @res_type end +end + class MethodDescr def initialize(ostr) raise "Not OpenStruct" if !ostr.kind_of?(OpenStruct) @@ -184,6 +267,15 @@ class MethodDescr when "ifdef" raise if !value.kind_of?(String) @ifdef_flag = value + when "inline_info" + begin + @inline_info = convert_to_array_of_descr(InlinableDescr, value, @argc) + @inline_info.delete_if {|info| (info.intrinsic == nil && info.instruction == nil)} + @inline_info = nil if @inline_info.size == 0 + rescue RuntimeError => e + raise "`#{@id.raw}`\n#{e.to_s}" + end + when "description" else raise "Unknown field: " + key.to_s end @@ -193,7 +285,7 @@ class MethodDescr raise "Missing `argc` field" if (@argc == nil) && (@impl == nil) raise "`argc` should be of `Numeric`" if (@impl.kind_of?(CPPImpl) || @impl == nil) && !@argc.kind_of?(Numeric) end - + def gen_cpp_id raise "`impl` is redefined" if @impl != nil id.raw[0].upcase + id.raw[1..-1] @@ -224,10 +316,46 @@ class MethodDescr res += "\n#endif // #{@ifdef_flag}" if @ifdef_flag res end + + def trivial_inline_overloads? + raise if !@inline_info + argc = @inline_info[0].args_type.size + @inline_info.each do |info| + if (info.args_type.size != argc) || (info.args_type.uniq.size > 1) + return false + end + end + return true + end + + def get_integer_overload + @inline_info.each do |info| + if (info.args_type.uniq[0] == 'ECMASCRIPT_INT_TYPE') + return info + end + end + return nil + end + + def get_double_overload + @inline_info.each do |info| + if (info.args_type.uniq[0] == 'ECMASCRIPT_DOUBLE_TYPE') + return info + end + end + return nil + end + + def get_zero_overload + raise if @inline_info.size != 1 + raise if @inline_info[0].args_type.size != 0 + return @inline_info[0] + end def id() @id end def argc() @argc end def impl() @impl end + def inline_info() @inline_info end end class GetDescr @@ -410,6 +538,10 @@ class AbstractOpDescr def decl @raw + ';' end + + def id + @raw[/[^A-Za-z0-9_][A-Za-z0-9_]*/,0][1..-1] + end end @@ -465,15 +597,36 @@ class Builtin raise "Prototype should not have `prototype` field" if @prototype && is_proto end - def convert_to_array_of_descr(descr_class, array) - raise if !array.kind_of?(Array) - res = [] - array.each do |elem| - res.append(descr_class.new(elem)) + def inlinable_methods + methods = [] + # currenlty, only `methods` can be inlined: + @methods.each do |method| + methods.append(method) if method.inline_info end - res + methods end - + + def cpp_ids + ids = [] + if @ctor + ids.append(@ctor.gen_cpp_id) + end + @methods.each do |method| + ids.append(method.gen_cpp_id) if !method.impl + end + @getters.each do |getter| + ids.append(getter.gen_cpp_id) + ids.append(getter.setter.gen_cpp_id) if getter.setter + end + @setters.each do |setter| + ids.append(setter.gen_cpp_id) + end + @abstract_ops.each do |abstract_op| + ids.append(abstract_op.id) + end + ids +end + def gen_cpp_decl(cpp_id) "JSTaggedValue #{cpp_id}(EcmaRuntimeCallInfo *argv);" end @@ -489,7 +642,6 @@ class Builtin @getters.each do |getter| decls.append(gen_cpp_decl(getter.gen_cpp_id)) decls.append(gen_cpp_decl(getter.setter.gen_cpp_id)) if getter.setter - end @setters.each do |setter| decls.append(gen_cpp_decl(setter.gen_cpp_id)) @@ -509,8 +661,17 @@ class Builtin def prototype() @prototype end end -class Builtins < SimpleDelegator +class Builtins def self.wrap_data(data) + # Preload intrinsics as they may be used in `methods` construction: + data_intrinsics = YAML.load_file(ARGV[0]) + data_intrinsics = JSON.parse(data_intrinsics.to_json, object_class: OpenStruct).freeze + Runtime.wrap_data(data_intrinsics) + # Preload intrinsics as they may be used in `methods` construction: + data_instructions = YAML.load_file(ARGV[1]) + data_instructions = JSON.parse(data_instructions.to_json, object_class: OpenStruct).freeze + IR.wrap_data(data_instructions) + @builtins = [] data.builtins.each do |space| @builtins.append Builtin.new space @@ -519,6 +680,7 @@ class Builtins < SimpleDelegator data.builtins_internal.each do |name| @builtins_internal.append Builtin.new name end + end def self.spaces() @builtins end def self.internal_spaces() @builtins_internal end @@ -527,4 +689,16 @@ end def Gen.on_require(data) Builtins.wrap_data(data) end - \ No newline at end of file + +def convert_to_array_of_descr(descr_class, array, opt_arg = nil) + raise if !array.kind_of?(Array) + res = [] + array.each do |elem| + if (opt_arg != nil) + res.append(descr_class.new(elem, opt_arg)) + else + res.append(descr_class.new(elem)) + end + end + res +end diff --git a/runtime/builtins/templates/builtins.yaml b/runtime/builtins/templates/builtins.yaml index 2f93215fde9a3a7adc22e75ca70557ff218a8d52..82d127ef7723010dbcad80e3e37a23632dd61c75 100644 --- a/runtime/builtins/templates/builtins.yaml +++ b/runtime/builtins/templates/builtins.yaml @@ -787,44 +787,107 @@ builtins: methods: - name: abs argc: 1 + inline_info: + - instruction: Abs + args_type: [ ECMASCRIPT_INT_TYPE ] + res_type: ECMASCRIPT_INT_TYPE + - instruction: Abs + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: acos argc: 1 + inline_info: + - intrinsic: StdMathAcos + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: acosh argc: 1 + inline_info: + - intrinsic: StdMathAcosh + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: asin argc: 1 + inline_info: + - intrinsic: StdMathAsin + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: asinh argc: 1 + inline_info: + - intrinsic: StdMathAsinh + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: atan argc: 1 + inline_info: + - intrinsic: StdMathAtan + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: atanh argc: 1 + inline_info: + - intrinsic: StdMathAtanh + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: atan2 argc: 2 + inline_info: + - intrinsic: StdMathAtan2 + args_type: [ ECMASCRIPT_DOUBLE_TYPE, ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: cbrt argc: 1 - name: ceil argc: 1 + inline_info: + - intrinsic: StdMathCeil + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: clz32 argc: 1 + inline_info: + - intrinsic: StdMathClz32 + args_type: [ ECMASCRIPT_INT_TYPE ] + res_type: ECMASCRIPT_INT_TYPE - name: cos argc: 1 + inline_info: + - intrinsic: MathCosF64 + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: cosh argc: 1 + inline_info: + - intrinsic: StdMathCosh + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: exp argc: 1 - name: expm1 argc: 1 - name: floor argc: 1 + inline_info: + - intrinsic: StdMathFloor + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: fround argc: 1 + inline_info: + - intrinsic: StdMathFround + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: hypot argc: 2 - name: imul argc: 2 - name: log argc: 1 + inline_info: + - intrinsic: StdMathLog + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: log1p argc: 1 - name: log10 @@ -833,28 +896,66 @@ builtins: argc: 1 - name: max argc: 2 + inline_info: + - instruction: Max + args_type: [ ECMASCRIPT_INT_TYPE, ECMASCRIPT_INT_TYPE ] + res_type: ECMASCRIPT_INT_TYPE + - instruction: Max + args_type: [ ECMASCRIPT_DOUBLE_TYPE, ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: min argc: 2 + inline_info: + - instruction: Min + args_type: [ ECMASCRIPT_INT_TYPE, ECMASCRIPT_INT_TYPE ] + res_type: ECMASCRIPT_INT_TYPE + - instruction: Min + args_type: [ ECMASCRIPT_DOUBLE_TYPE, ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: pow argc: 2 + inline_info: + - intrinsic: MathPowF64 + args_type: [ ECMASCRIPT_DOUBLE_TYPE, ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: random argc: 0 - name: round argc: 1 + inline_info: + - intrinsic: StdMathRound + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: sign argc: 1 - name: sin argc: 1 + inline_info: + - intrinsic: MathSinF64 + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: sinh argc: 1 + inline_info: + - intrinsic: StdMathSinh + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: sqrt argc: 1 + inline_info: + - instruction: Sqrt + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: tan argc: 1 - name: tanh argc: 1 - name: trunc argc: 1 + inline_info: + - intrinsic: StdMathTrunc + args_type: [ ECMASCRIPT_DOUBLE_TYPE ] + res_type: ECMASCRIPT_DOUBLE_TYPE - name: NumberFormat ctor: @@ -1135,10 +1236,20 @@ builtins: methods: - name: GetOptimizationStatus argc: 1 + description: >- + Performs a series of environment and function object checks with regard to compilation status + (e.g. whether function has a compiled code or not) and returns ECMASCRIPT_INT_TYPE containing flags. + See `OptimizationStatus` for more info. - name: PrepareFunctionForOptimization argc: 1 + description: >- + Ensures the function has profiling vector and initializes one if it hasn't. It is expected that + the function later will be called in interpreter (i.e. before call to `OptimizeFunctionOnNextCall`) - name: OptimizeFunctionOnNextCall argc: 2 + description: >- + Checks if function has compiled code and starts synchronous compilation if it hasn't. + On next call of a function its compiled code will be executed. - name: Exit argc: 1 - name: IsBeingInterpreted diff --git a/runtime/builtins/templates/builtins_ids_gen.inl.erb b/runtime/builtins/templates/builtins_ids_gen.inl.erb new file mode 100644 index 0000000000000000000000000000000000000000..1ed45f5ee6277fc6fb756ad28dae5d37b1062c94 --- /dev/null +++ b/runtime/builtins/templates/builtins_ids_gen.inl.erb @@ -0,0 +1,38 @@ +/* + * 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. + */ + +% Builtins.spaces.each do |space| +% space.cpp_ids.each do |cpp_id| + BUILTINS_MACRO_GEN_V(<%= space.name %>, <%= cpp_id %>) +% end +% if space.prototype +% space.prototype.cpp_ids.each do |cpp_id| + BUILTINS_MACRO_GEN_V(<%= space.name %>Prototype, <%= cpp_id %>) +% end +% end + +% end + +% Builtins.internal_spaces.each do |ispace| +% ispace.cpp_ids.each do |cpp_id| + BUILTINS_MACRO_GEN_V(<%= ispace.name %>, <%= cpp_id %>) +% end +% if ispace.prototype +% ispace.prototype.cpp_ids.each do |cpp_id| + BUILTINS_MACRO_GEN_V(<%= ispace.name %>Prototype, <%= cpp_id %>) +% end +% end + +% end diff --git a/runtime/builtins/templates/builtins_inline_intrinsics_decls_gen.inl.erb b/runtime/builtins/templates/builtins_inline_intrinsics_decls_gen.inl.erb new file mode 100644 index 0000000000000000000000000000000000000000..5f7e0385e575daf8a2e62a6cd8c5188814b977ca --- /dev/null +++ b/runtime/builtins/templates/builtins_inline_intrinsics_decls_gen.inl.erb @@ -0,0 +1,26 @@ +/* + * 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. + */ + +AnyBaseType FetchInputs(CallInst *call_inst); + +void ResolveInputs(AnyBaseType type, CallInst *call_inst); + +% Builtins.spaces.each do |space| +% space.inlinable_methods.each do |method| +bool TryInline<%= space.name %><%= method.gen_cpp_id %>Gen(CallInst *call_inst); +% end +% end + +bool TryInlineNativeMethodGenECMASCRIPT(CallInst *call_inst); diff --git a/runtime/builtins/templates/builtins_inline_intrinsics_gen.inl.erb b/runtime/builtins/templates/builtins_inline_intrinsics_gen.inl.erb new file mode 100644 index 0000000000000000000000000000000000000000..c611280239989cd2180c5fa6d9ec70961adc8cb7 --- /dev/null +++ b/runtime/builtins/templates/builtins_inline_intrinsics_gen.inl.erb @@ -0,0 +1,165 @@ +/* + * 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. + */ + +#include "plugins/ecmascript/compiler/optimizer/optimizations/ecma_inlining.h" + +namespace panda::compiler { + +AnyBaseType InlineIntrinsics::FetchInputs(CallInst *call_inst) +{ + types_.clear(); + saved_inputs_.clear(); + AnyBaseType type = AnyBaseType::ECMASCRIPT_INT_TYPE; + for (auto &input : call_inst->GetInputs().SubSpan(GetGraph()->GetRuntime()->GetDynamicNumFixedArgs())) { + auto input_inst = input.GetInst(); + if (input_inst->IsSaveState()) { + continue; + } + auto input_type = GetAssumedAnyType(input_inst); + + if (input_type != AnyBaseType::ECMASCRIPT_INT_TYPE) { + type = input_type; + } + types_.emplace_back(input_type); + saved_inputs_.emplace_back(input_inst); + } + // last input is SaveState + ASSERT(GetGraph()->GetRuntime()->GetDynamicNumFixedArgs() + types_.size() + 1 == call_inst->GetInputsCount()); + if (type == AnyBaseType::UNDEFINED_TYPE) { + type = AnyBaseType::ECMASCRIPT_DOUBLE_TYPE; + } + ASSERT((type == AnyBaseType::ECMASCRIPT_INT_TYPE) || (type == AnyBaseType::ECMASCRIPT_DOUBLE_TYPE)); + return type; +} + +void InlineIntrinsics::ResolveInputs(AnyBaseType type, CallInst *call_inst) +{ + if (type == AnyBaseType::ECMASCRIPT_DOUBLE_TYPE) { + for (size_t i = 0; i < types_.size(); i++) { + if (types_[i] == AnyBaseType::ECMASCRIPT_INT_TYPE) { + auto any_check = GetGraph()->CreateInstAnyTypeCheck(DataType::ANY, call_inst->GetPc()); + any_check->SetInput(0, saved_inputs_[i]); + any_check->SetInput(1, call_inst->GetSaveState()); + any_check->SetAnyType(AnyBaseType::ECMASCRIPT_INT_TYPE); + call_inst->InsertBefore(any_check); + + auto cati = GetGraph()->CreateInstCastAnyTypeValue(AnyBaseTypeToDataType(AnyBaseType::ECMASCRIPT_INT_TYPE), call_inst->GetPc()); + cati->SetInput(0, any_check); + cati->SetAnyType(AnyBaseType::ECMASCRIPT_INT_TYPE); + call_inst->InsertBefore(cati); + + auto cast = GetGraph()->CreateInstCast(AnyBaseTypeToDataType(AnyBaseType::ECMASCRIPT_DOUBLE_TYPE), call_inst->GetPc()); + cast->SetInput(0, cati); + call_inst->InsertBefore(cast); + saved_inputs_[i] = cast; + } else if ((types_[i] == AnyBaseType::ECMASCRIPT_DOUBLE_TYPE) || (types_[i] == AnyBaseType::UNDEFINED_TYPE)) { + auto any_check = GetGraph()->CreateInstAnyTypeCheck(DataType::ANY, call_inst->GetPc()); + any_check->SetInput(0, saved_inputs_[i]); + any_check->SetInput(1, call_inst->GetSaveState()); + any_check->SetAnyType(AnyBaseType::ECMASCRIPT_DOUBLE_TYPE); + if (saved_inputs_[i]->GetOpcode() == Opcode::AnyTypeCheck) { + any_check->SetAllowedInputType(saved_inputs_[i]->CastToAnyTypeCheck()->GetAllowedInputType()); + any_check->SetIsIntegerWasSeen(saved_inputs_[i]->CastToAnyTypeCheck()->IsIntegerWasSeen()); + } + call_inst->InsertBefore(any_check); + + auto cati = GetGraph()->CreateInstCastAnyTypeValue(AnyBaseTypeToDataType(AnyBaseType::ECMASCRIPT_DOUBLE_TYPE), call_inst->GetPc()); + cati->SetInput(0, any_check); + cati->SetAnyType(AnyBaseType::ECMASCRIPT_DOUBLE_TYPE); + call_inst->InsertBefore(cati); + saved_inputs_[i] = cati; + } else { + UNREACHABLE(); + } + } + } else if (type == AnyBaseType::ECMASCRIPT_INT_TYPE) { + for (size_t i = 0; i < types_.size(); i++) { + if ((types_[i] == AnyBaseType::ECMASCRIPT_INT_TYPE) || (types_[i] == AnyBaseType::UNDEFINED_TYPE)) { + auto any_check = GetGraph()->CreateInstAnyTypeCheck(DataType::ANY, call_inst->GetPc()); + any_check->SetInput(0, saved_inputs_[i]); + any_check->SetInput(1, call_inst->GetSaveState()); + any_check->SetAnyType(AnyBaseType::ECMASCRIPT_INT_TYPE); + call_inst->InsertBefore(any_check); + + auto cati = GetGraph()->CreateInstCastAnyTypeValue(AnyBaseTypeToDataType(AnyBaseType::ECMASCRIPT_INT_TYPE), call_inst->GetPc()); + cati->SetInput(0, any_check); + cati->SetAnyType(AnyBaseType::ECMASCRIPT_INT_TYPE); + call_inst->InsertBefore(cati); + saved_inputs_[i] = cati; + } else { + UNREACHABLE(); + } + } + } +} + +% Builtins.spaces.each do |space| +% space.inlinable_methods.each do |method| +bool InlineIntrinsics::TryInline<%= space.name %><%= method.gen_cpp_id %>Gen(CallInst *call_inst) +{ +% raise "Only trivial overloads are currently supported" if !method.trivial_inline_overloads? + [[maybe_unused]] auto resolved_type = FetchInputs(call_inst); + +% if method.inline_info[0].args_type.size != 0 + if (types_.size() != <%= method.inline_info[0].args_type.size %>) { + return false; + } + +% if method.get_integer_overload + if (resolved_type == AnyBaseType::ECMASCRIPT_INT_TYPE) { + ecmascript::EcmaInlining::BuildGuard(call_inst, call_inst->GetCallMethod()); + ResolveInputs(AnyBaseType::ECMASCRIPT_INT_TYPE, call_inst); + <%= method.get_integer_overload.do_inline %> + return true; + } +% end +% if method.get_double_overload + if ((resolved_type == AnyBaseType::ECMASCRIPT_DOUBLE_TYPE) || (resolved_type == AnyBaseType::ECMASCRIPT_INT_TYPE)) { + ecmascript::EcmaInlining::BuildGuard(call_inst, call_inst->GetCallMethod()); + ResolveInputs(AnyBaseType::ECMASCRIPT_DOUBLE_TYPE, call_inst); + <%= method.get_double_overload.do_inline %> + return true; + } +% end + return false; +% else + if (!types_.empty()) { + return false; + } + ecmascript::EcmaInlining::BuildGuard(call_inst, call_inst->GetCallMethod()); + <%= method.get_zero_overload.do_inline -%> + return true; +% end +} + +% end +% end + +bool InlineIntrinsics::TryInlineNativeMethodGenECMASCRIPT(CallInst *call_inst) +{ + ASSERT(call_inst->GetCallMethod() != nullptr); + switch(GetGraph()->GetRuntime()->ResolveInlinableNativeMethod(call_inst->GetCallMethod())) { +% Builtins.spaces.each do |space| +% space.inlinable_methods.each do |method| + case panda::ecmascript::EcmaRuntimeCallerId::BUILTINS_ID_<%= space.name %>_<%= method.gen_cpp_id %>: + return TryInline<%= space.name %><%= method.gen_cpp_id %>Gen(call_inst); +% end +% end + default: + return false; + } +} + +} // namespace panda::compiler diff --git a/runtime/builtins/templates/builtins_resolve_inlinable_gen.inl.erb b/runtime/builtins/templates/builtins_resolve_inlinable_gen.inl.erb new file mode 100644 index 0000000000000000000000000000000000000000..fd8a17437fa6dbc86503e578ffcd06ed92e635db --- /dev/null +++ b/runtime/builtins/templates/builtins_resolve_inlinable_gen.inl.erb @@ -0,0 +1,50 @@ +/* + * 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. + */ + + + size_t EcmaRuntimeInterface::ResolveInlinableNativeMethod(MethodPtr method) const + { + if (JsMethodCast(method)->IsNative()) { + static const std::unordered_map INLINABLE_BUILTINS { +% Builtins.spaces.each do |space| +% space.inlinable_methods.each do |method| + {reinterpret_cast(builtins::<%= space.name.snakecase %>::<%= method.gen_cpp_id %>), EcmaRuntimeCallerId::BUILTINS_ID_<%= space.name %>_<%= method.gen_cpp_id %>}, +% end +% if space.prototype +% space.prototype.inlinable_methods.each do |method| + {reinterpret_cast(builtins::<%= space.name.snakecase %>::proto::<%= method.gen_cpp_id %>), EcmaRuntimeCallerId::BUILTINS_ID_<%= space.name %>Prototype_<%= method.gen_cpp_id %>}, +% end +% end +% end +% Builtins.internal_spaces.each do |ispace| +% ispace.inlinable_methods.each do |method| + {reinterpret_cast(builtins::<%= ispace.name.snakecase %>::<%= method.gen_cpp_id %>), EcmaRuntimeCallerId::BUILTINS_ID_<%= ispace.name %>_<%= method.gen_cpp_id %>}, +% end +% if ispace.prototype +% ispace.prototype.inlinable_methods.each do |method| + {reinterpret_cast(builtins::<%= ispace.name.snakecase %>::proto::<%= method.gen_cpp_id %>), EcmaRuntimeCallerId::BUILTINS_ID_<%= ispace.name %>Prototype_<%= method.gen_cpp_id %>}, +% end +% end +% end + }; + auto it = INLINABLE_BUILTINS.find(JsMethodCast(method)->GetNativePointer()); + if (it == INLINABLE_BUILTINS.end()) { + return RUNTIME_CALLER_NUMBER; + } + return it->second; + } + + return RUNTIME_CALLER_NUMBER; + } diff --git a/runtime/compiler/ecmascript_runtime_interface.cpp b/runtime/compiler/ecmascript_runtime_interface.cpp index bfefae349415da5a8ab7fb14c67a46fee0d55d71..24e8745051d6b777e982c1c21e0c614a02ef673b 100644 --- a/runtime/compiler/ecmascript_runtime_interface.cpp +++ b/runtime/compiler/ecmascript_runtime_interface.cpp @@ -94,6 +94,8 @@ uintptr_t EcmaRuntimeInterface::GetGlobalVarAddress(MethodPtr method, size_t id) return reinterpret_cast(res.GetHeapObject()); } +#include "plugins/ecmascript/runtime/builtins/generated/builtins_resolve_inlinable_gen.inl" + EcmaRuntimeInterface::MethodProfile EcmaRuntimeInterface::GetMethodProfile(MethodPtr method, bool from_vector) const { if (from_vector) { diff --git a/runtime/compiler/ecmascript_runtime_interface.h b/runtime/compiler/ecmascript_runtime_interface.h index 49b3b509e92713e3684d7bcf3b39036a1108613b..33c871cde2e9c443146b7f9f78f4578d9808171e 100644 --- a/runtime/compiler/ecmascript_runtime_interface.h +++ b/runtime/compiler/ecmascript_runtime_interface.h @@ -16,6 +16,7 @@ #define PANDA_RUNTIME_ECMASCRIPT_RUNTIME_INTERFACE_H #include "runtime/compiler.h" +#include "plugins/ecmascript/runtime/base/builtins_base.h" #include "plugins/ecmascript/runtime/js_method.h" #include "plugins/ecmascript/runtime/js_object.h" #include "plugins/ecmascript/runtime/js_tagged_value.h" @@ -129,9 +130,16 @@ public: return EntrypointId::GET_GLOBAL_VAR_ADDRESS; } + size_t ResolveInlinableNativeMethod(MethodPtr method) const override; + + bool IsInlinableNativeMethod(MethodPtr method) const override + { + return ResolveInlinableNativeMethod(method) != EcmaRuntimeCallerId::RUNTIME_CALLER_NUMBER; + } + bool IsMethodCanBeInlined([[maybe_unused]] MethodPtr method) const override { - return true; + return !JsMethodCast(method)->IsNative(); } size_t GetMethodCodeSize(MethodPtr method) const override diff --git a/runtime/ecma_profiling.cpp b/runtime/ecma_profiling.cpp index 1ff10733862d6252e0775f44326f2a3c3029a106..903add134c785d039decab5fbd5599274fffa36a 100644 --- a/runtime/ecma_profiling.cpp +++ b/runtime/ecma_profiling.cpp @@ -23,7 +23,7 @@ void CallProfile::Update(ECMAObject *js_func, EcmaCallProfilingTable *table) if (callees_idx_[0] == MEGAMORPHIC) { return; } - auto method = JSFunction::Cast(js_func)->GetCallTarget(); + auto method = js_func->GetCallTarget(); for (size_t i = 0; i < MAX_FUNC_NUMBER; ++i) { if (callees_idx_[i] == UNKNOWN) { auto idx = table->InsertNewObject(js_func); @@ -34,7 +34,7 @@ void CallProfile::Update(ECMAObject *js_func, EcmaCallProfilingTable *table) return; } ASSERT(callees_idx_[i] > 0 && callees_idx_[i] <= std::numeric_limits::max() - 1U); - if (JSFunction::Cast(table->GetObject(callees_idx_[i]))->GetCallTarget() == method) { + if (table->GetObject(callees_idx_[i])->GetCallTarget() == method) { return; } } diff --git a/runtime/ecma_vm.cpp b/runtime/ecma_vm.cpp index 03dfdf359b05c1ced19838c012b4e3a44c270968..ee911c9300b7a03ed6229637a5d0e74ee557fe62 100644 --- a/runtime/ecma_vm.cpp +++ b/runtime/ecma_vm.cpp @@ -298,7 +298,10 @@ void EcmaVM::InitializeEcmaScriptRunStat() #undef INTERPRETER_CALLER_NAME // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define BUILTINS_API_NAME(class, name) "BuiltinsApi::" #class "_" #name, - BUITINS_API_LIST(BUILTINS_API_NAME) +#define BUILTINS_MACRO_GEN_V BUILTINS_API_NAME +#include "plugins/ecmascript/runtime/builtins/generated/builtins_ids_gen.inl" +#undef BUILTINS_MACRO_GEN_V + BUILTINS_API_LIST(BUILTINS_API_NAME) #undef BUILTINS_API_NAME // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define ABSTRACT_OPERATION_NAME(class, name) "AbstractOperation::" #class "_" #name, diff --git a/runtime/interpreter/ecma-interpreter-inl.h b/runtime/interpreter/ecma-interpreter-inl.h index 42aeb1092949e262d80ae5e49a71a6a60dc1c681..0879ad42bba81fc933bf721e5b888e451142915c 100644 --- a/runtime/interpreter/ecma-interpreter-inl.h +++ b/runtime/interpreter/ecma-interpreter-inl.h @@ -375,6 +375,7 @@ public: if (method->IsNative()) { // Native ASSERT(method->GetNumVregs() == 0); + UPDATE_CALL_PROFILE(this_func); uint32_t num_actual_args = JSGetNumberActualArgsDyn(this->GetInst()); uint32_t num_args = std::max(method->GetNumArgs(), num_actual_args); diff --git a/runtime/runtime_call_id.h b/runtime/runtime_call_id.h index 1a7a9a0dfae2bd786a05ac9162048074fb25eaf0..f5f78b9f5761b8a5e7198cc4786564d4ccb24dcc 100644 --- a/runtime/runtime_call_id.h +++ b/runtime/runtime_call_id.h @@ -243,386 +243,19 @@ 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, GetOwnPropertyDescriptor) \ - V(Object, GetOwnPropertyDescriptors) \ - 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) +#define BUILTINS_API_LIST(V) \ + V(ArrayList, Constructor) \ + V(ArrayList, Add) \ + V(ArrayList, Iterator) \ + V(Boolean, ThisBooleanValue) \ + V(Proxy, InvalidateProxyFunction) \ + V(DataView, GetViewValue) \ + V(DataView, SetViewValue) \ + V(Symbol, ThisSymbolValue) \ + V(Number, ThisNumberValue) \ + V(Object, GetOwnPropertyKeys) \ + V(Object, LookupDesc) \ + V(Object, GetBuiltinTag) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define ABSTRACT_OPERATION_LIST(V) V(JSTaggedValue, ToString) @@ -637,8 +270,11 @@ namespace panda::ecmascript { #define ABSTRACT_OPERATION_ID(class, name) ABSTRACT_ID_##class##_##name, enum EcmaRuntimeCallerId { - INTERPRETER_CALLER_LIST(INTERPRETER_CALLER_ID) BUITINS_API_LIST(BUILTINS_API_ID) - ABSTRACT_OPERATION_LIST(ABSTRACT_OPERATION_ID) RUNTIME_CALLER_NUMBER, + INTERPRETER_CALLER_LIST(INTERPRETER_CALLER_ID) +#define BUILTINS_MACRO_GEN_V BUILTINS_API_ID +#include "plugins/ecmascript/runtime/builtins/generated/builtins_ids_gen.inl" +#undef BUILTINS_MACRO_GEN_V + BUILTINS_API_LIST(BUILTINS_API_ID) ABSTRACT_OPERATION_LIST(ABSTRACT_OPERATION_ID) RUNTIME_CALLER_NUMBER, }; #if ECMASCRIPT_ENABLE_RUNTIME_STAT diff --git a/subproject_sources.gn b/subproject_sources.gn index 820ff03229bee041083120e507582c91c83e4c2b..c2424dd465611a77dd10aa278f968b96b223e4ba 100644 --- a/subproject_sources.gn +++ b/subproject_sources.gn @@ -25,6 +25,8 @@ srcs_compiler = [ "compiler/inline_intrinsics_ecmascript.cpp", "compiler/codegen_intrinsics_ecmascript.cpp", "compiler/optimizer/ir_builder/ecmascript_inst_builder.cpp", + "compiler/optimizer/optimizations/ecma_inlining.cpp", + "compiler/optimizer/optimizations/inline_call_intrinsics.cpp", ] option_yaml_path = "ecmascript_plugin_options.yaml" @@ -43,7 +45,11 @@ irtoc_plugins = [ arkruntime_header_sub_deps = [ "$_plugin_dir:ecma_intrinsics_gen_arkruntime", "$_plugin_dir:ecma_builtins_gen_builtins_declaration_gen_h", + "$_plugin_dir:ecma_builtins_gen_builtins_ids_gen_inl", "$_plugin_dir:ecma_builtins_gen_builtins_initializers_gen_h", + "$_plugin_dir:ecma_builtins_gen_builtins_inline_intrinsics_decls_gen_inl", + "$_plugin_dir:ecma_builtins_gen_builtins_inline_intrinsics_gen_inl", + "$_plugin_dir:ecma_builtins_gen_builtins_resolve_inlinable_gen_inl", ] arkruntime_stdlib_sub_deps = [ "$_plugin_dir:ecmastdlib_inline_h", diff --git a/tests/checked/CMakeLists.txt b/tests/checked/CMakeLists.txt index a427cbe6334df6551a891e0190835434d53896f4..63ee6cab4d247071a2382a6e19b98bfc5d926097 100644 --- a/tests/checked/CMakeLists.txt +++ b/tests/checked/CMakeLists.txt @@ -107,6 +107,13 @@ if (NOT PANDA_TARGET_ARM32) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/obj_by_index.js SUPPORT_RELEASE true) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/obj_by_name.js SUPPORT_RELEASE true) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/obj_by_value.js SUPPORT_RELEASE true) + if (PANDA_WITH_ETS) + panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inline_builtins_intrinsic_double_with_int.js SUPPORT_RELEASE true) + panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inline_builtins_intrinsic_int_with_double.js SUPPORT_RELEASE true) + endif() + panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inline_builtins_instruction_int_with_double.js SUPPORT_RELEASE true) + panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inline_builtins_instruction_double_with_int.js SUPPORT_RELEASE true) + panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inline_builtins_speculation_fail.js SUPPORT_RELEASE true) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inlining_deoptimize.js SUPPORT_RELEASE true) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inlining_megamorphic.js SUPPORT_RELEASE true) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inlining_polymorphic.js SUPPORT_RELEASE true) diff --git a/tests/checked/ecma_inline_builtins_instruction_double_with_int.js b/tests/checked/ecma_inline_builtins_instruction_double_with_int.js new file mode 100644 index 0000000000000000000000000000000000000000..cc6b1c8cf2e9a2e8a8953962a95a87e500006c2f --- /dev/null +++ b/tests/checked/ecma_inline_builtins_instruction_double_with_int.js @@ -0,0 +1,72 @@ +/* + * 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. + */ + +//! CHECKER Ecma builtins inlining. Speculations should be the following: (DOUBLE + Instruction) --deopt--> (DOUBLE/INT + Instruction). +//! RUN options: "--compiler-regex=_GLOBAL::profiling_abs", entry: "_GLOBAL::func_main_0" +//! METHOD "profiling_abs" +//! EVENT /Compilation,.*profiling_abs.*COMPILED/ +//! PASS_AFTER "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT "AnyTypeCheck ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT "CastAnyTypeValue ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT_NOT "Cast " +//! INST_NEXT "Abs" +//! EVENT_NEXT /DeoptimizationReason,.*,DOUBLE_WITH_INT/ +//! EVENT_NEXT /Compilation,.*profiling_abs.*COMPILED/ +//! PASS_AFTER_NEXT "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT "AnyTypeCheck ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT "CastAnyTypeValue ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT_NOT "Cast " +//! INST_NEXT "Abs" +//! EVENT_NEXT_NOT /Deoptimization/ +//! EVENT_NEXT_NOT /Compilation/ + +function profiling_abs(arg) +{ + let saved_arg = arg; + // Increment is necessary to profile the type: + let res = Math.abs(arg++); + arg = saved_arg; + return res; +} + +function check(arg) +{ + let lhs = Math.abs(arg); + let rhs = profiling_abs(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } + RuntimeTesting.OptimizeFunctionOnNextCall(profiling_abs); + lhs = Math.abs(arg); + rhs = profiling_abs(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } + +}; + +RuntimeTesting.PrepareFunctionForOptimization(profiling_abs); + +// Profile as double: +check(3.1); +// Deopt, profile as double with int +check(3); +// No deoptimization +check(3); +check(3.1); +check(3); +check(3.1); diff --git a/tests/checked/ecma_inline_builtins_instruction_int_with_double.js b/tests/checked/ecma_inline_builtins_instruction_int_with_double.js new file mode 100644 index 0000000000000000000000000000000000000000..3bb93757ad8d40b5bc57f677253ed9f6bf75b4fc --- /dev/null +++ b/tests/checked/ecma_inline_builtins_instruction_int_with_double.js @@ -0,0 +1,82 @@ +/* + * 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. + */ + +//! CHECKER Ecma builtins inlining. Speculations should be the following: (INT + Instruction) --deopt--> (DOUBLE/INT + Instruction). +//! RUN options: "--compiler-regex=_GLOBAL::profiling_abs", entry: "_GLOBAL::func_main_0" +//! METHOD "profiling_abs" +//! EVENT /Compilation,.*profiling_abs.*COMPILED/ +//! PASS_AFTER "InlineIntrinsics" +//! INST "HclassCheck" +//! INST "HclassCheck" +//! INST_NEXT "LoadImmediate" +//! INST_NEXT "LoadObject" +//! INST_NEXT "Compare NE" +//! INST_NEXT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT "AnyTypeCheck ECMASCRIPT_INT_TYPE" +//! INST_NEXT "CastAnyTypeValue ECMASCRIPT_INT_TYPE" +//! INST_NEXT_NOT "Cast " +//! INST_NEXT "Abs" +//! EVENT_NEXT /DeoptimizationReason,.*,NOT_SMALL_INT/ +//! EVENT_NEXT /Compilation,.*profiling_abs.*COMPILED/ +//! PASS_AFTER_NEXT "InlineIntrinsics" +//! INST "HclassCheck" +//! INST "HclassCheck" +//! INST_NEXT "LoadImmediate" +//! INST_NEXT "LoadObject" +//! INST_NEXT "Compare NE" +//! INST_NEXT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT "AnyTypeCheck ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT "CastAnyTypeValue ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT_NOT "Cast " +//! INST_NEXT "Abs" +//! EVENT_NEXT_NOT /Deoptimization/ +//! EVENT_NEXT_NOT /Compilation/ + +function profiling_abs(arg) +{ + let saved_arg = arg; + // Increment is necessary to profile the type: + let res = Math.abs(arg++); + arg = saved_arg; + return res; +} + +function check(arg) +{ + let lhs = Math.abs(arg); + let rhs = profiling_abs(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } + RuntimeTesting.OptimizeFunctionOnNextCall(profiling_abs); + lhs = Math.abs(arg); + rhs = profiling_abs(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } + +}; + +RuntimeTesting.PrepareFunctionForOptimization(profiling_abs); + +// Profile as integer: +check(3); +// Deopt, profile as double with int +check(3.1); +// No deoptimization +check(3); +check(3.1); +check(3); +check(3.1); diff --git a/tests/checked/ecma_inline_builtins_intrinsic_double_with_int.js b/tests/checked/ecma_inline_builtins_intrinsic_double_with_int.js new file mode 100644 index 0000000000000000000000000000000000000000..ee25072c0bf0e672082bb890ea3cd75ac5aa0c2b --- /dev/null +++ b/tests/checked/ecma_inline_builtins_intrinsic_double_with_int.js @@ -0,0 +1,132 @@ +/* + * 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. + */ + +//! CHECKER Ecma builtins inlining. Speculations should be the following: (DOUBLE + Intrinsic) --deopt--> (DOUBLE/INT + Intrinsic). +//! RUN options: "--compiler-regex=\"_GLOBAL::profiling_(clz32|sin)\"", entry: "_GLOBAL::func_main_0" +//! METHOD "profiling_sin" +//! EVENT /Compilation.*profiling_sin.*COMPILED/ +//! PASS_AFTER "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT "LoadImmediate" +//! INST_NEXT "LoadObject" +//! INST_NEXT "Compare NE" +//! INST_NEXT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT "AnyTypeCheck ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT "CastAnyTypeValue ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT "Intrinsic.MathSinF64" +//! EVENT_NEXT /DeoptimizationReason,.*profiling_sin.*,DOUBLE_WITH_INT/ +//! EVENT_NEXT /Compilation.*profiling_sin.*COMPILED/ +//! PASS_AFTER_NEXT "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT "LoadImmediate" +//! INST_NEXT "LoadObject" +//! INST_NEXT "Compare NE" +//! INST_NEXT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT "AnyTypeCheck ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT "CastAnyTypeValue ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT "Intrinsic.MathSinF64" +//! EVENT_NEXT_NOT /Deoptimization.*profiling_sin/ +//! EVENT_NEXT_NOT /Compilation.*profiling_sin/ + +//! CHECKER Ecma builtins inlining. Check for intrinsics that accepts only ECMASCRIPT_INT_TYPE. Speculations should be the following: (CallDynamic) --deopt--> (CallDynamic). +//! RUN options: "--compiler-regex=\"_GLOBAL::profiling_(clz32|sin)\"", entry: "_GLOBAL::func_main_0" +//! METHOD "profiling_clz32" +//! EVENT /Compilation.*profiling_clz32.*COMPILED/ +//! PASS_AFTER "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT_NOT "LoadImmediate" +//! INST_NEXT_NOT "LoadObject" +//! INST_NEXT_NOT "Compare NE" +//! INST_NEXT_NOT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT_NOT "Intrinsic.StdMathClz32" +//! INST_NEXT "CallDynamic" +//! EVENT_NEXT /DeoptimizationReason,.*profiling_clz32.*,DOUBLE_WITH_INT/ +//! EVENT_NEXT /Compilation.*profiling_clz32.*COMPILED/ +//! PASS_AFTER_NEXT "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT_NOT "LoadImmediate" +//! INST_NEXT_NOT "LoadObject" +//! INST_NEXT_NOT "Compare NE" +//! INST_NEXT_NOT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT_NOT "Intrinsic.StdMathClz32" +//! INST_NEXT "CallDynamic" +//! EVENT_NEXT_NOT /Deoptimization.*profiling_clz32/ +//! EVENT_NEXT_NOT /Compilation.*profiling_clz32/ + + +function profiling_sin(arg) +{ + let saved_arg = arg; + // Increment is necessary to profile the type: + let res = Math.sin(arg++); + arg = saved_arg; + return res; +} + +function profiling_clz32(arg) +{ + let saved_arg = arg; + // Increment is necessary to profile the type. + // clz32 is inlined only for integers + let res = Math.clz32(arg++); + arg = saved_arg; + return res; +} + +function check(arg) +{ + let lhs; + let rhs; + + lhs = Math.sin(arg); + rhs = profiling_sin(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } + + lhs = Math.clz32(arg); + rhs = profiling_clz32(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } + + RuntimeTesting.OptimizeFunctionOnNextCall(profiling_sin); + RuntimeTesting.OptimizeFunctionOnNextCall(profiling_clz32); + + lhs = Math.sin(arg); + rhs = profiling_sin(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } + + lhs = Math.clz32(arg); + rhs = profiling_clz32(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } +}; + +RuntimeTesting.PrepareFunctionForOptimization(profiling_sin); +RuntimeTesting.PrepareFunctionForOptimization(profiling_clz32); + +// Profile as double: +check(3.1); +// Deopt, profile as double_with_int: +check(3); +// No deoptimization: +check(3.1); +check(3); +check(3.1); +check(3); diff --git a/tests/checked/ecma_inline_builtins_intrinsic_int_with_double.js b/tests/checked/ecma_inline_builtins_intrinsic_int_with_double.js new file mode 100644 index 0000000000000000000000000000000000000000..b63339592b670bb7db57bf6982c056d67b6c4203 --- /dev/null +++ b/tests/checked/ecma_inline_builtins_intrinsic_int_with_double.js @@ -0,0 +1,133 @@ +/* + * 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. + */ + +//! CHECKER Ecma builtins inlining. Speculations should be the following: (INTEGER + Intrinsic) --deopt--> (DOUBLE/INT + Intrinsic). +//! RUN options: "--compiler-regex=\"_GLOBAL::profiling_(clz32|sin)\"", entry: "_GLOBAL::func_main_0" +//! METHOD "profiling_sin" +//! EVENT /Compilation.*profiling_sin.*COMPILED/ +//! PASS_AFTER "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT "LoadImmediate" +//! INST_NEXT "LoadObject" +//! INST_NEXT "Compare NE" +//! INST_NEXT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT "AnyTypeCheck ECMASCRIPT_INT_TYPE" +//! INST_NEXT "CastAnyTypeValue ECMASCRIPT_INT_TYPE" +//! INST_NEXT "Cast " +//! INST_NEXT "Intrinsic.MathSinF64" +//! EVENT_NEXT /DeoptimizationReason,.*profiling_sin.*,NOT_SMALL_INT/ +//! EVENT_NEXT /Compilation.*profiling_sin.*COMPILED/ +//! PASS_AFTER_NEXT "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT "LoadImmediate" +//! INST_NEXT "LoadObject" +//! INST_NEXT "Compare NE" +//! INST_NEXT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT "AnyTypeCheck ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT "CastAnyTypeValue ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT "Intrinsic.MathSinF64" +//! EVENT_NEXT_NOT /Deoptimization.*profiling_sin/ +//! EVENT_NEXT_NOT /Compilation.*profiling_sin/ + +//! CHECKER Ecma builtins inlining. Check for intrinsics that accepts only ECMASCRIPT_INT_TYPE. Speculations should be the following: (INTEGER + Intrinsic) --deopt--> (CallDynamic). +//! RUN options: "--compiler-regex=\"_GLOBAL::profiling_(clz32|sin)\"", entry: "_GLOBAL::func_main_0" +//! METHOD "profiling_clz32" +//! EVENT /Compilation.*profiling_clz32.*COMPILED/ +//! PASS_AFTER "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT "LoadImmediate" +//! INST_NEXT "LoadObject" +//! INST_NEXT "Compare NE" +//! INST_NEXT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT "AnyTypeCheck ECMASCRIPT_INT_TYPE" +//! INST_NEXT "CastAnyTypeValue ECMASCRIPT_INT_TYPE" +//! INST_NEXT_NOT "Cast " +//! INST_NEXT "Intrinsic.StdMathClz32" +//! EVENT_NEXT /DeoptimizationReason,.*profiling_clz32.*,NOT_SMALL_INT/ +//! EVENT_NEXT /Compilation.*profiling_clz32.*COMPILED/ +//! PASS_AFTER_NEXT "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT_NOT "LoadImmediate" +//! INST_NEXT_NOT "LoadObject" +//! INST_NEXT_NOT "Compare NE" +//! INST_NEXT_NOT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT "CallDynamic" +//! EVENT_NEXT_NOT /Deoptimization.*profiling_clz32/ +//! EVENT_NEXT_NOT /Compilation.*profiling_clz32/ + +function profiling_sin(arg) +{ + let saved_arg = arg; + // Increment is necessary to profile the type: + let res = Math.sin(arg++); + arg = saved_arg; + return res; +} + +function profiling_clz32(arg) +{ + let saved_arg = arg; + // Increment is necessary to profile the type. + // clz32 is inlined only for integers + let res = Math.clz32(arg++); + arg = saved_arg; + return res; +} + +function check(arg) +{ + let lhs; + let rhs; + + lhs = Math.sin(arg); + rhs = profiling_sin(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } + + lhs = Math.clz32(arg); + rhs = profiling_clz32(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } + + RuntimeTesting.OptimizeFunctionOnNextCall(profiling_sin); + RuntimeTesting.OptimizeFunctionOnNextCall(profiling_clz32); + + lhs = Math.sin(arg); + rhs = profiling_sin(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } + + lhs = Math.clz32(arg); + rhs = profiling_clz32(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } +}; + +RuntimeTesting.PrepareFunctionForOptimization(profiling_sin); +RuntimeTesting.PrepareFunctionForOptimization(profiling_clz32); + +// Profile as integer: +check(3); +// Deopt, profile as double with int +check(3.1); +// No deoptimization +check(3); +check(3.1); +check(3); +check(3.1); diff --git a/tests/checked/ecma_inline_builtins_speculation_fail.js b/tests/checked/ecma_inline_builtins_speculation_fail.js new file mode 100644 index 0000000000000000000000000000000000000000..ee60925baebb8ea34f8fd3763f61e0589d3e49bb --- /dev/null +++ b/tests/checked/ecma_inline_builtins_speculation_fail.js @@ -0,0 +1,92 @@ +/* + * 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. + */ + +//! CHECKER Ecma builtins inlining. Must deoptimize if actual was function changed. +//! RUN options: "--compiler-regex=_GLOBAL::profiling_sin", entry: "_GLOBAL::func_main_0" +//! METHOD "profiling_sin" +//! EVENT /Compilation.*profiling_sin.*COMPILED/ +//! PASS_AFTER "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT "LoadImmediate" +//! INST_NEXT "LoadObject" +//! INST_NEXT "Compare NE" +//! INST_NEXT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT "AnyTypeCheck ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT "CastAnyTypeValue ECMASCRIPT_DOUBLE_TYPE" +//! INST_NEXT_NOT "Cast " +//! INST_NEXT "Intrinsic.MathSinF64" +//! EVENT_NEXT_NOT /DeoptimizationReason,.*,DOUBLE_WITH_INT/ +//! EVENT_NEXT_NOT /DeoptimizationReason,.*,NOT_SMALL_INT/ +//! EVENT_NEXT /DeoptimizationReason,.*,INLINE_DYN/ +//! EVENT_NEXT /Compilation.*profiling_sin.*COMPILED/ +//! PASS_AFTER_NEXT "InlineIntrinsics" +//! INST "HclassCheck" +//! INST_NEXT_NOT "LoadImmediate" +//! INST_NEXT_NOT "LoadObject" +//! INST_NEXT_NOT "Compare NE" +//! INST_NEXT_NOT "DeoptimizeIf INLINE_DYN" +//! INST_NEXT_NOT "Intrinsic.MathSinF64" +//! INST_NEXT "CallDynamic" +//! EVENT_NEXT_NOT /Deoptimization/ +//! EVENT_NEXT_NOT /Compilation/ + + +var func_holder = Math.sin; + +function profiling_sin(arg) +{ + let saved_arg = arg; + // Increment is necessary to profile the type: + let res = func_holder(arg++); + arg = saved_arg; + return res; +} + +function profile(arg) +{ + let lhs = func_holder(arg); + let rhs = profiling_sin(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } +}; + +function check(arg) +{ + let lhs = func_holder(arg); + let rhs = profiling_sin(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } + RuntimeTesting.OptimizeFunctionOnNextCall(profiling_sin); + lhs = func_holder(arg); + rhs = profiling_sin(arg); + if (lhs != rhs) { + throw "Wrong result " + lhs + " " + rhs; + } +}; + +RuntimeTesting.PrepareFunctionForOptimization(profiling_sin); + +// Profile as double_with_int: +profile(3.1); +profile(3); +// Optimization: +check(3.1); +check(3); +// Deoptimization: +func_holder = Math.cos;; +check(3.1); +check(3);