diff --git a/ecmascript/compiler/builtins/builtins_stubs.cpp b/ecmascript/compiler/builtins/builtins_stubs.cpp index ab8e23aa641d715e95b81c78d336c8dcd2240121..7c16cc493354f0f2fcd8df7fc996be79b72cf42d 100644 --- a/ecmascript/compiler/builtins/builtins_stubs.cpp +++ b/ecmascript/compiler/builtins/builtins_stubs.cpp @@ -521,7 +521,6 @@ DECLARE_BUILTINS(DateConstructor) Label newTargetIsHeapObject(env); Label newTargetIsJSFunction(env); Label slowPath(env); - Label slowPath1(env); Label exit(env); BRANCH(TaggedIsHeapObject(newTarget), &newTargetIsHeapObject, &slowPath); @@ -532,7 +531,7 @@ DECLARE_BUILTINS(DateConstructor) Label intialHClassIsHClass(env); GateRef intialHClass = Load(VariableType::JS_ANY(), glue, newTarget, IntPtr(JSFunction::PROTO_OR_DYNCLASS_OFFSET)); - BRANCH(IsJSHClass(glue, intialHClass), &intialHClassIsHClass, &slowPath1); + BRANCH(IsJSHClass(glue, intialHClass), &intialHClassIsHClass, &slowPath); Bind(&intialHClassIsHClass); { Label oneArg(env); @@ -587,18 +586,11 @@ DECLARE_BUILTINS(DateConstructor) } } } - Bind(&slowPath1); - { - GateRef argv = GetArgv(); - res = CallBuiltinRuntimeWithNewTarget(glue, - { glue, nativeCode, func, thisValue, numArgs, argv, newTarget }); - Jump(&exit); - } } Bind(&slowPath); { GateRef argv = GetArgv(); - res = CallBuiltinRuntime(glue, { glue, nativeCode, func, thisValue, numArgs, argv }, true); + res = CallBuiltinRuntimeWithNewTarget(glue, {glue, nativeCode, func, thisValue, numArgs, argv, newTarget}); Jump(&exit); } Bind(&exit); diff --git a/test/jittest/date_constructor/BUILD.gn b/test/jittest/date_constructor/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..93946b9c258110ecf5195a1241e9738df651c642 --- /dev/null +++ b/test/jittest/date_constructor/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2025 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. + +import("//arkcompiler/ets_runtime/test/test_helper.gni") + +host_jit_test_action("date_constructor") { + deps = [] +} diff --git a/test/jittest/date_constructor/date_constructor.ts b/test/jittest/date_constructor/date_constructor.ts new file mode 100644 index 0000000000000000000000000000000000000000..f741662e7e66eb20b34ad1c471297d58f87ca928 --- /dev/null +++ b/test/jittest/date_constructor/date_constructor.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 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. + */ + +class D extends Date {} +function Test() { + let d = new D(); + if (!(d instanceof D)) { + throw "d has incorrect prototype chain"; + } else { + print("success"); + } +} + +Test(); + +ArkTools.jitCompileAsync(Test); +print(ArkTools.waitJitCompileFinish(Test)); + +for (let i = 0; i < 2; i++) { + Test(); +} diff --git a/test/jittest/date_constructor/expect_output.txt b/test/jittest/date_constructor/expect_output.txt new file mode 100644 index 0000000000000000000000000000000000000000..78e3118538ef0b4988afcf544a42d10d5b7dbf5f --- /dev/null +++ b/test/jittest/date_constructor/expect_output.txt @@ -0,0 +1,16 @@ +# Copyright (c) 2025 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. + +true +success +success