From f453d943d8a29ba95d8f99d893d6934837c3a977 Mon Sep 17 00:00:00 2001 From: Maxim Bolshov Date: Fri, 1 Sep 2023 18:33:56 +0300 Subject: [PATCH] Support calli.dyn/return.dyn removal from core Signed-off-by: Maxim Bolshov --- isa/isa.yaml | 2 +- runtime/interpreter/ecma-interpreter-inl.h | 4 +- tests/assembler/CMakeLists.txt | 1 - tests/assembler/emitter_test_ecmascript.cpp | 35 ---------------- tests/assembler/parser_test_ecmascript.cpp | 44 --------------------- 5 files changed, 3 insertions(+), 83 deletions(-) delete mode 100644 tests/assembler/parser_test_ecmascript.cpp diff --git a/isa/isa.yaml b/isa/isa.yaml index 0cc550b5a..35db8de6e 100644 --- a/isa/isa.yaml +++ b/isa/isa.yaml @@ -40,7 +40,7 @@ properties: namespaces: - namespace: ecmascript - used_instructions: [nop, lda.str, call.short, call, call.range, call.acc.short, call.acc, mov.dyn, lda.dyn, sta.dyn, ldai.dyn, fldai.dyn, return.dyn, calli.dyn.short, calli.dyn, calli.dyn.range, jmp] + used_instructions: [nop, lda.str, call.short, call, call.range, call.acc.short, call.acc, mov.dyn, lda.dyn, sta.dyn, ldai.dyn, fldai.dyn, jmp] quickening: true profiles_schema: diff --git a/runtime/interpreter/ecma-interpreter-inl.h b/runtime/interpreter/ecma-interpreter-inl.h index ba8a9e3e1..7c1c4f0a5 100644 --- a/runtime/interpreter/ecma-interpreter-inl.h +++ b/runtime/interpreter/ecma-interpreter-inl.h @@ -321,7 +321,7 @@ public: return; } } - this->template DoReturnDyn(); + this->GetFrame()->SetAcc((this->GetAcc())); } template @@ -348,7 +348,7 @@ public: } else { SetAccFromTaggedValue(JSTaggedValue::Undefined()); } - this->template DoReturnDyn(); + this->GetFrame()->SetAcc((this->GetAcc())); } // Redefine method from base class diff --git a/tests/assembler/CMakeLists.txt b/tests/assembler/CMakeLists.txt index a82335500..0fbf93792 100644 --- a/tests/assembler/CMakeLists.txt +++ b/tests/assembler/CMakeLists.txt @@ -14,7 +14,6 @@ panda_ecmascript_add_gtest( NAME assembler_tests_ecma SOURCES - parser_test_ecmascript.cpp emitter_test_ecmascript.cpp INCLUDE_DIRS ${PANDA_ROOT}/assembler diff --git a/tests/assembler/emitter_test_ecmascript.cpp b/tests/assembler/emitter_test_ecmascript.cpp index fc7d5306e..cabc2be17 100644 --- a/tests/assembler/emitter_test_ecmascript.cpp +++ b/tests/assembler/emitter_test_ecmascript.cpp @@ -42,41 +42,6 @@ using panda::pandasm::AsmEmitter; using panda::pandasm::Error; using panda::pandasm::Parser; -static const uint8_t *GetTypeDescriptor(const std::string &name, std::string *storage) -{ - *storage = "L" + name + ";"; - std::replace(storage->begin(), storage->end(), '.', '/'); - return utf::CStringAsMutf8(storage->c_str()); -} - -TEST(emittertests, get_GLOBAL_lang_for_JS_func) -{ - Parser p; - auto source = R"( - .language ECMAScript - - .function any main() { - return.dyn - } - )"; - - auto res = p.Parse(source); - ASSERT_EQ(p.ShowError().err, Error::ErrorType::ERR_NONE); - - auto pf = AsmEmitter::Emit(res.Value()); - ASSERT_NE(pf, nullptr); - - std::string descriptor; - - auto class_id = pf->GetClassId(GetTypeDescriptor("_GLOBAL", &descriptor)); - ASSERT_TRUE(class_id.IsValid()); - - panda_file::ClassDataAccessor cda(*pf, class_id); - - ASSERT_TRUE(cda.GetSourceLang().has_value()); - ASSERT_EQ(cda.GetSourceLang(), panda_file::SourceLang::ECMASCRIPT); -} - TEST(emittertests, ecmascript_debuginfo) { Parser p; diff --git a/tests/assembler/parser_test_ecmascript.cpp b/tests/assembler/parser_test_ecmascript.cpp deleted file mode 100644 index 3f30e4d7e..000000000 --- a/tests/assembler/parser_test_ecmascript.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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 "operand_types_print.h" - -#include -#include - -using panda::pandasm::Error; -using panda::pandasm::Parser; - -TEST(parsertests, calli_dyn_3args) -{ - { - Parser p; - std::string source = R"( - .language ECMAScript - - # a0 - function, a1 - this - .function any main(any a0, any a1) { - calli.dyn.short 1, a0, a1 - return.dyn - } - )"; - - auto res = p.Parse(source); - - Error e = p.ShowError(); - - ASSERT_EQ(e.err, Error::ErrorType::ERR_NONE); - } -} \ No newline at end of file -- Gitee