From 702f2378ac314ec131a5250b0e1a21cc3f6a6a0c Mon Sep 17 00:00:00 2001 From: wengchangcheng Date: Wed, 5 Jun 2024 09:52:53 +0800 Subject: [PATCH] shared function dont support bind https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I9V2LF Signed-off-by: wengchangcheng Change-Id: I38ac3d789ecd4ad9baa2e0a661f56f52564fa67d --- .../builtins/builtins_shared_function.cpp | 9 ++++ .../builtins/builtins_shared_function.h | 1 + ecmascript/builtins/shared_builtins.cpp | 3 +- .../expect_output.txt | 46 +------------------ .../sharedcollectionsexception.ts | 17 ++++--- 5 files changed, 25 insertions(+), 51 deletions(-) diff --git a/ecmascript/builtins/builtins_shared_function.cpp b/ecmascript/builtins/builtins_shared_function.cpp index b1486f41e9..0e6dcc75d8 100644 --- a/ecmascript/builtins/builtins_shared_function.cpp +++ b/ecmascript/builtins/builtins_shared_function.cpp @@ -25,4 +25,13 @@ JSTaggedValue BuiltinsSharedFunction::SharedFunctionConstructor(EcmaRuntimeCallI THROW_TYPE_ERROR_AND_RETURN(thread, "Not support eval. Forbidden using new SharedFuction()/SharedFuction().", JSTaggedValue::Exception()); } + +JSTaggedValue BuiltinsSharedFunction::SharedFunctionPrototypeBind(EcmaRuntimeCallInfo *argv) +{ + // not support + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, Function, PrototypeBind); + [[maybe_unused]] EcmaHandleScope handleScope(thread); + THROW_TYPE_ERROR_AND_RETURN(thread, "Sendable function not support bind.", JSTaggedValue::Exception()); +} } // namespace panda::ecmascript::builtins \ No newline at end of file diff --git a/ecmascript/builtins/builtins_shared_function.h b/ecmascript/builtins/builtins_shared_function.h index b7cb9b2f9a..b57a905977 100644 --- a/ecmascript/builtins/builtins_shared_function.h +++ b/ecmascript/builtins/builtins_shared_function.h @@ -23,6 +23,7 @@ namespace panda::ecmascript::builtins { class BuiltinsSharedFunction : public base::BuiltinsBase { public: static JSTaggedValue SharedFunctionConstructor(EcmaRuntimeCallInfo *argv); + static JSTaggedValue SharedFunctionPrototypeBind(EcmaRuntimeCallInfo *argv); }; } // namespace panda::ecmascript::builtins #endif // ECMASCRIPT_BUILTINS_BUILTINS_SHARED_FUNCTION_H diff --git a/ecmascript/builtins/shared_builtins.cpp b/ecmascript/builtins/shared_builtins.cpp index 51becefdf7..17ff70001f 100644 --- a/ecmascript/builtins/shared_builtins.cpp +++ b/ecmascript/builtins/shared_builtins.cpp @@ -374,7 +374,8 @@ void Builtins::InitializeSFunction(const JSHandle &env, SetSFunction(env, sFuncPrototypeObj, "apply", Function::FunctionPrototypeApply, fieldIndex++, FunctionLength::TWO, BUILTINS_STUB_ID(FunctionPrototypeApply)); // 19.2.3.2 Function.prototype.bind ( thisArg , ...args) - SetSFunction(env, sFuncPrototypeObj, "bind", Function::FunctionPrototypeBind, fieldIndex++, FunctionLength::ONE); + SetSFunction(env, sFuncPrototypeObj, "bind", BuiltinsSharedFunction::SharedFunctionPrototypeBind, + fieldIndex++, FunctionLength::ONE); // 19.2.3.3 Function.prototype.call (thisArg , ...args) SetSFunction(env, sFuncPrototypeObj, "call", Function::FunctionPrototypeCall, fieldIndex++, FunctionLength::ONE); // 19.2.3.5 Function.prototype.toString ( ) diff --git a/test/sharedtest/sharedcollectionsexception/expect_output.txt b/test/sharedtest/sharedcollectionsexception/expect_output.txt index ca0c925844..258b39a364 100644 --- a/test/sharedtest/sharedcollectionsexception/expect_output.txt +++ b/test/sharedtest/sharedcollectionsexception/expect_output.txt @@ -11,51 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +Start Test SharedArray Start bindErrorTest -call boundAt fail. err: BusinessError: The at method cannot be bound., errCode: 10200011 -Call boundConcat fail. err: BusinessError: The concat method cannot be bound., errCode: 10200011 -Call boundEntries failed. err: BusinessError: The entries method cannot be bound., errCode: 10200011 -Call boundFill failed. err: BusinessError: The fill method cannot be bound., errCode: 10200011 -Call boundFilter failed. err: BusinessError: The filter method cannot be bound., errCode: 10200011 -Call boundFind failed. err: BusinessError: The find method cannot be bound., errCode: 10200011 -Call boundFindIndex failed. err: BusinessError: The findIndex method cannot be bound., errCode: 10200011 -Call boundForEach failed. err: BusinessError: The forEach method cannot be bound., errCode: 10200011 -Call boundIndexOf failed. err: BusinessError: The indexOf method cannot be bound., errCode: 10200011 -Call boundJoin failed. err: BusinessError: The join method cannot be bound., errCode: 10200011 -Call boundKeys failed. err: BusinessError: The keys method cannot be bound., errCode: 10200011 -Call boundMap failed. err: BusinessError: The map method cannot be bound., errCode: 10200011 -Call boundPop failed. err: BusinessError: The pop method cannot be bound., errCode: 10200011 -Call boundPush failed. err: BusinessError: The push method cannot be bound., errCode: 10200011 -Call boundReduce failed. err: BusinessError: The reduce method cannot be bound., errCode: 10200011 -Call boundShift failed. err: BusinessError: The shift method cannot be bound., errCode: 10200011 -Call boundSlice failed. err: BusinessError: The slice method cannot be bound., errCode: 10200011 -Call boundSort failed. err: BusinessError: The sort method cannot be bound., errCode: 10200011 -Call boundToString failed. err: BusinessError: The toString method cannot be bound., errCode: 10200011 -Call boundUnshift failed. err: BusinessError: The unshift method cannot be bound., errCode: 10200011 -Call boundValues failed. err: BusinessError: The values method cannot be bound., errCode: 10200011 -Call boundIncludes failed. err: BusinessError: The includes method cannot be bound., errCode: 10200011 -Call boundShrinkTo failed. err: BusinessError: Parameter error.Not enough parameter., errCode: 401 -Call boundExtendTo failed. err: BusinessError: Parameter error.Not enough parameters., errCode: 401 -Start Test SharedMap -Start map bindErrorTest -Call boundClear failed. err: BusinessError: The clear method cannot be bound., errCode: 10200011 -Call boundDelete failed. err: BusinessError: The delete method cannot be bound., errCode: 10200011 -Call boundEntries failed. err: BusinessError: The entries method cannot be bound., errCode: 10200011 -Call boundForEach failed. err: BusinessError: The forEach method cannot be bound., errCode: 10200011 -Call boundGet failed. err: BusinessError: The get method cannot be bound., errCode: 10200011 -Call boundHas failed. err: BusinessError: The has method cannot be bound., errCode: 10200011 -Call boundKeys failed. err: BusinessError: The keys method cannot be bound., errCode: 10200011 -Call boundSet failed. err: BusinessError: The set method cannot be bound., errCode: 10200011 -Call boundValues failed. err: BusinessError: The values method cannot be bound., errCode: 10200011 -Start Test SharedSet -Start set bindErrorTest -Call boundAdd failed. err: BusinessError: The add method cannot be bound., errCode: 10200011 -Call boundClear failed. err: BusinessError: The clear method cannot be bound., errCode: 10200011 -Call boundDelete failed. err: BusinessError: The delete method cannot be bound., errCode: 10200011 -Call boundEntries failed. err: BusinessError: The entries method cannot be bound., errCode: 10200011 -Call boundForEach failed. err: BusinessError: The forEach method cannot be bound., errCode: 10200011 -Call boundHas failed. err: BusinessError: The has method cannot be bound., errCode: 10200011 -Call boundValues failed. err: BusinessError: The values method cannot be bound., errCode: 10200011 +Bind error. err: TypeError: Sendable function not support bind. Start Test SharedArray Start createErrorTest Init with small first element: -1 success. diff --git a/test/sharedtest/sharedcollectionsexception/sharedcollectionsexception.ts b/test/sharedtest/sharedcollectionsexception/sharedcollectionsexception.ts index 7a249da689..b7f804e7a2 100644 --- a/test/sharedtest/sharedcollectionsexception/sharedcollectionsexception.ts +++ b/test/sharedtest/sharedcollectionsexception/sharedcollectionsexception.ts @@ -682,12 +682,17 @@ function concurrencyErrorTest() { } // common bindTest -bindErrorTest(); -print("Start Test SharedMap") -bindErrorTestMap(); - -print("Start Test SharedSet") -bindErrorTestSet(); +try { + print("Start Test SharedArray") + bindErrorTest(); + print("Start Test SharedMap") + bindErrorTestMap(); + + print("Start Test SharedSet") + bindErrorTestSet(); +} catch (err) { + print("Bind error. err: " + err); +} print("Start Test SharedArray") createErrorTest(); -- Gitee