mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-27 12:10:47 +00:00
Modify Asm TDD Test and Asm Inter Options
Run moduletest both in C interpreter and asm interpreter. Change asm inter options to --asmInter=true/false. Issue: #I57B6W Signed-off-by: lichenshuai <lichenshuai@huawei.com> Change-Id: I054c1dbd9edd389e25316c66d7a7311cd3be2920
This commit is contained in:
parent
a12b31af5c
commit
09d05dfb05
8
BUILD.gn
8
BUILD.gn
@ -105,16 +105,12 @@ if (defined(ark_independent_build)) {
|
||||
# js bytecode test
|
||||
deps += [ "//ark/js_runtime/test/moduletest:ark_js_moduletest" ]
|
||||
|
||||
# ts aot test
|
||||
# ts aot test and asm test
|
||||
if (is_standard_system) {
|
||||
deps += [ "//ark/js_runtime/test/aottest:ark_aot_test" ]
|
||||
deps += [ "//ark/js_runtime/test/moduletest:ark_asm_test" ]
|
||||
}
|
||||
}
|
||||
|
||||
# asm test
|
||||
if (is_standard_system) {
|
||||
deps += [ "//ark/js_runtime/test/asmtest:ark_asm_test" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,8 @@ public:
|
||||
parser->Add(&arkProperties_);
|
||||
parser->Add(&enableTSAot_);
|
||||
parser->Add(&maxNonmovableSpaceCapacity_);
|
||||
parser->Add(&asmInter_);
|
||||
parser->Add(&enableAsmInterpreter_);
|
||||
parser->Add(&asmOpcodeDisableRange_);
|
||||
parser->Add(&aotOutputFile_);
|
||||
parser->Add(&targetTriple_);
|
||||
parser->Add(&asmOptLevel_);
|
||||
@ -302,51 +303,36 @@ public:
|
||||
return defaultSnapshotSpaceCapacity_.GetValue();
|
||||
}
|
||||
|
||||
void SetAsmInterOption(std::string value)
|
||||
void SetEnableAsmInterpreter(bool value)
|
||||
{
|
||||
asmInter_.SetValue(std::move(value));
|
||||
enableAsmInterpreter_.SetValue(value);
|
||||
}
|
||||
|
||||
void SetAsmOpcodeDisableRange(std::string value)
|
||||
{
|
||||
asmOpcodeDisableRange_.SetValue(std::move(value));
|
||||
}
|
||||
|
||||
void ParseAsmInterOption()
|
||||
{
|
||||
std::string strAsmInterOption = asmInter_.GetValue();
|
||||
if (strAsmInterOption.empty()) {
|
||||
asmInterParsedOption_.enableAsm = enableAsmInterpreter_.GetValue();
|
||||
std::string strAsmOpcodeDisableRange = asmOpcodeDisableRange_.GetValue();
|
||||
if (strAsmOpcodeDisableRange.empty()) {
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> vec;
|
||||
size_t pos = 0;
|
||||
size_t len = strAsmInterOption.length();
|
||||
while (pos < len) {
|
||||
size_t delimPos = strAsmInterOption.find("#", pos);
|
||||
if (delimPos == std::string::npos) {
|
||||
vec.emplace_back(strAsmInterOption.substr(pos));
|
||||
break;
|
||||
}
|
||||
vec.emplace_back(strAsmInterOption.substr(pos, delimPos - pos));
|
||||
pos = delimPos + 1;
|
||||
}
|
||||
|
||||
// enable or not asm interpreter
|
||||
if (vec.size() > 0) {
|
||||
std::string enableAsm = vec[0];
|
||||
asmInterParsedOption_.enableAsm = (enableAsm == "1") ? true : false;
|
||||
}
|
||||
|
||||
// asm interpreter handle disable range
|
||||
if (vec.size() > 1) {
|
||||
std::string handleDisableRange = vec[1];
|
||||
pos = handleDisableRange.find(",");
|
||||
if (pos != std::string::npos) {
|
||||
std::string strStart = handleDisableRange.substr(0, pos);
|
||||
std::string strEnd = handleDisableRange.substr(pos + 1);
|
||||
int start = strStart.empty() ? 0 : std::stoi(strStart);
|
||||
int end = strEnd.empty() ? kungfu::BYTECODE_STUB_END_ID : std::stoi(strEnd);
|
||||
if (start >= 0 && start < kungfu::BytecodeStubCSigns::NUM_OF_ALL_NORMAL_STUBS
|
||||
&& end >= 0 && end < kungfu::BytecodeStubCSigns::NUM_OF_ALL_NORMAL_STUBS
|
||||
&& start <= end) {
|
||||
asmInterParsedOption_.handleStart = start;
|
||||
asmInterParsedOption_.handleEnd = end;
|
||||
}
|
||||
size_t pos = strAsmOpcodeDisableRange.find(",");
|
||||
if (pos != std::string::npos) {
|
||||
std::string strStart = strAsmOpcodeDisableRange.substr(0, pos);
|
||||
std::string strEnd = strAsmOpcodeDisableRange.substr(pos + 1);
|
||||
int start = strStart.empty() ? 0 : std::stoi(strStart);
|
||||
int end = strEnd.empty() ? kungfu::BYTECODE_STUB_END_ID : std::stoi(strEnd);
|
||||
if (start >= 0 && start < kungfu::BytecodeStubCSigns::NUM_OF_ALL_NORMAL_STUBS
|
||||
&& end >= 0 && end < kungfu::BytecodeStubCSigns::NUM_OF_ALL_NORMAL_STUBS
|
||||
&& start <= end) {
|
||||
asmInterParsedOption_.handleStart = start;
|
||||
asmInterParsedOption_.handleEnd = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -560,9 +546,12 @@ private:
|
||||
PandArg<uint32_t> defaultSnapshotSpaceCapacity_ {"defaultSnapshotSpaceCapacity",
|
||||
256 * 1024,
|
||||
R"(set default snapshot space capacity)"};
|
||||
PandArg<std::string> asmInter_ {"asmInter",
|
||||
PandArg<bool> enableAsmInterpreter_ {"asm-interpreter", false,
|
||||
R"(Enable asm interpreter. Default: false)"};
|
||||
PandArg<std::string> asmOpcodeDisableRange_ {"asm-opcode-disable-range",
|
||||
"",
|
||||
R"(set asm interpreter control properties)"};
|
||||
R"(Opcode range when asm interpreter is enabled.)"};
|
||||
AsmInterParsedOption asmInterParsedOption_;
|
||||
PandArg<uint64_t> internal_memory_size_limit_ {"internal-memory-size-limit", INTERNAL_MEMORY_SIZE_LIMIT_DEFAULT,
|
||||
R"(Max internal memory used by the VM. Default: 2147483648)"};
|
||||
PandArg<uint32_t> heap_size_limit_ {"heap-size-limit", 512 * 1024 * 1024,
|
||||
@ -579,7 +568,6 @@ private:
|
||||
PandArg<std::string> icu_data_path_ {"icu-data-path", R"(default)",
|
||||
R"(Path to generated icu data file. Default: "default")"};
|
||||
PandArg<bool> startup_time_ {"startup-time", false, R"(Print the start time of command execution. Default: false)"};
|
||||
AsmInterParsedOption asmInterParsedOption_;
|
||||
PandArg<std::string> logCompiledMethods {"log-compiled-methods",
|
||||
R"(none)",
|
||||
R"(print stub or aot logs in units of method, "none": no log, "all": every method)"};
|
||||
|
@ -790,9 +790,14 @@ public:
|
||||
arkProperties_ = prop;
|
||||
}
|
||||
|
||||
void SetAsmInterOption(const std::string &value)
|
||||
void SetEnableAsmInterpreter(bool value)
|
||||
{
|
||||
asmInterOption_ = value;
|
||||
enableAsmInterpreter_ = value;
|
||||
}
|
||||
|
||||
void SetAsmOpcodeDisableRange(const std::string &value)
|
||||
{
|
||||
asmOpcodeDisableRange_ = value;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -870,9 +875,14 @@ private:
|
||||
return arkProperties_;
|
||||
}
|
||||
|
||||
std::string GetAsmInterOption() const
|
||||
bool GetEnableAsmInterpreter() const
|
||||
{
|
||||
return asmInterOption_;
|
||||
return enableAsmInterpreter_;
|
||||
}
|
||||
|
||||
std::string GetAsmOpcodeDisableRange() const
|
||||
{
|
||||
return asmOpcodeDisableRange_;
|
||||
}
|
||||
|
||||
GC_TYPE gcType_ = GC_TYPE::EPSILON;
|
||||
@ -885,7 +895,8 @@ private:
|
||||
bool enableCpuprofiler_ {false};
|
||||
#endif
|
||||
int arkProperties_ {-1};
|
||||
std::string asmInterOption_ {""};
|
||||
bool enableAsmInterpreter_ {false};
|
||||
std::string asmOpcodeDisableRange_ {""};
|
||||
friend JSNApi;
|
||||
};
|
||||
|
||||
|
@ -130,7 +130,8 @@ EcmaVM *JSNApi::CreateJSVM(const RuntimeOption &option)
|
||||
// Mem
|
||||
runtimeOptions.SetHeapSizeLimit(option.GetGcPoolSize());
|
||||
// asmInterpreter
|
||||
runtimeOptions.SetAsmInterOption(option.GetAsmInterOption());
|
||||
runtimeOptions.SetEnableAsmInterpreter(option.GetEnableAsmInterpreter());
|
||||
runtimeOptions.SetAsmOpcodeDisableRange(option.GetAsmOpcodeDisableRange());
|
||||
|
||||
// Dfx
|
||||
base_options::Options baseOptions("");
|
||||
|
@ -37,7 +37,7 @@ ts2abc=$(root_dir)/out/hi3516dv300/clang_x64/obj/ark/ts2abc/ts2panda/build/src/i
|
||||
test_dir=$(root_dir)/ark/js_runtime/test/aottest
|
||||
out_dir=$(root_dir)/out/hi3516dv300/clang_x64/aottest
|
||||
case_dir=$(out_dir)/$(test_name)
|
||||
com_stub_args=--enable-stub-aot=1 --asmInter=1 --bc-stub-out=$(out_dir)/bc_stub.m --com-stub-out=$(out_dir)/com_stub.m
|
||||
com_stub_args=--enable-stub-aot=1 --asm-interpreter=true --bc-stub-out=$(out_dir)/bc_stub.m --com-stub-out=$(out_dir)/com_stub.m
|
||||
|
||||
abc:
|
||||
mkdir -p $(case_dir)
|
||||
|
@ -1,20 +0,0 @@
|
||||
# Copyright (c) 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.
|
||||
|
||||
group("ark_asm_test") {
|
||||
testonly = true
|
||||
deps = [
|
||||
"helloworld:helloworldAsmAction",
|
||||
"trycatch:trycatchAsmAction",
|
||||
]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 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.
|
||||
|
||||
Hello, world!
|
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
print("Hello, world!");
|
@ -1,18 +0,0 @@
|
||||
# Copyright (c) 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.
|
||||
|
||||
import("//ark/js_runtime/test/test_helper.gni")
|
||||
|
||||
host_asm_test_action("trycatch") {
|
||||
deps = []
|
||||
}
|
@ -40,6 +40,7 @@ group("ark_js_moduletest") {
|
||||
"spreadoperator:spreadoperatorAction",
|
||||
"stackoverflow:stackoverflowAction",
|
||||
"throwdyn:throwdynAction",
|
||||
"trycatch:trycatchAction",
|
||||
"watch:watchAction",
|
||||
"yieldstar:yieldstarAction",
|
||||
]
|
||||
@ -47,3 +48,46 @@ group("ark_js_moduletest") {
|
||||
deps += [ "weaktransitions:weaktransitionsAction" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("ark_asm_test") {
|
||||
testonly = true
|
||||
deps = [
|
||||
"allocatearraybuffer:allocatearraybufferAsmAction",
|
||||
|
||||
# "async:asyncAsmAction",
|
||||
"bindfunction:bindfunctionAsmAction",
|
||||
"bitwiseop:bitwiseopAsmAction",
|
||||
"callframe:callframeAsmAction",
|
||||
"class:classAsmAction",
|
||||
"compareobjecthclass:compareobjecthclassAsmAction",
|
||||
|
||||
# "container:containerAsmAction",
|
||||
"dyninstruction:dyninstructionAsmAction",
|
||||
"ecmastringtable:ecmastringtableAsmAction",
|
||||
"fortest:fortestAsmAction",
|
||||
"generator:generatorAsmAction",
|
||||
"getunmappedargs:getunmappedargsAsmAction",
|
||||
"globalaccessor:globalaccessorAsmAction",
|
||||
"globalrecord:globalrecordAsmAction",
|
||||
"globalthis:globalthisAsmAction",
|
||||
"helloworld:helloworldAsmAction",
|
||||
"lexicalenv:lexicalenvAsmAction",
|
||||
"module:moduleAsmAction",
|
||||
"multiargs:multiargsAsmAction",
|
||||
"newobjdynrange:newobjdynrangeAsmAction",
|
||||
"throwdyn:throwdynAsmAction",
|
||||
"trycatch:trycatchAsmAction",
|
||||
"watch:watchAsmAction",
|
||||
]
|
||||
if (!is_debug) {
|
||||
deps += [
|
||||
"objectcloneproperties:objectclonepropertiesAsmAction",
|
||||
"promise:promiseAsmAction",
|
||||
"spreadoperator:spreadoperatorAsmAction",
|
||||
"stackoverflow:stackoverflowAsmAction",
|
||||
|
||||
# "weaktransitions:weaktransitionsAsmAction",
|
||||
"yieldstar:yieldstarAsmAction",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,6 @@
|
||||
|
||||
import("//ark/js_runtime/test/test_helper.gni")
|
||||
|
||||
host_asm_test_action("helloworld") {
|
||||
host_moduletest_action("trycatch") {
|
||||
deps = []
|
||||
}
|
@ -156,6 +156,54 @@ template("host_moduletest_action") {
|
||||
|
||||
outputs = [ "$target_out_dir/${_target_name_}/" ]
|
||||
}
|
||||
|
||||
action("${_target_name_}AsmAction") {
|
||||
testonly = true
|
||||
|
||||
_host_jsvm_target_ =
|
||||
"//ark/js_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
|
||||
_root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
|
||||
deps = [
|
||||
":gen_${_target_name_}_abc",
|
||||
"//ark/js_runtime/ecmascript/compiler:gen_stub_file(${host_toolchain})",
|
||||
_host_jsvm_target_,
|
||||
]
|
||||
deps += _deps_
|
||||
|
||||
script = "//ark/js_runtime/script/run_ark_executable.py"
|
||||
|
||||
_asm_run_options_ = " --enable-stub-aot=true" + " --asm-interpreter=true"
|
||||
if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
|
||||
invoker.is_set_maxNonmovableSpaceCapacity) {
|
||||
_asm_run_options_ += " --maxNonmovableSpaceCapacity=524288" # 0.5M
|
||||
}
|
||||
|
||||
if (defined(invoker.is_enable_enableArkTools) &&
|
||||
invoker.is_enable_enableArkTools) {
|
||||
_asm_run_options_ += " --enable-ark-tools=true"
|
||||
}
|
||||
|
||||
args = [
|
||||
"--script-file",
|
||||
rebase_path(_root_out_dir_) + "/ark/ark_js_runtime/ark_js_vm",
|
||||
"--script-options",
|
||||
_asm_run_options_,
|
||||
"--script-args",
|
||||
_script_args_,
|
||||
"--expect-file",
|
||||
rebase_path(_test_expect_path_),
|
||||
"--env-path",
|
||||
rebase_path(_root_out_dir_) + "/ark/ark:" + rebase_path(_root_out_dir_) +
|
||||
"/ark/ark_js_runtime:" + rebase_path(_root_out_dir_) +
|
||||
"/${_icu_path_}:" + rebase_path(_root_out_dir_) +
|
||||
rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
|
||||
]
|
||||
|
||||
inputs = [ _test_abc_path_ ]
|
||||
inputs += _extra_modules_
|
||||
|
||||
outputs = [ "$target_out_dir/${_target_name_}Asm/" ]
|
||||
}
|
||||
}
|
||||
|
||||
template("host_aot_test_action") {
|
||||
@ -197,9 +245,10 @@ template("host_aot_test_action") {
|
||||
|
||||
script = "//ark/js_runtime/script/run_ark_executable.py"
|
||||
|
||||
_aot_compile_options_ = " --aot-output-file=" + rebase_path(_test_m_path_) +
|
||||
" --snapshot-output-file=" +
|
||||
rebase_path(_test_snapshot_path_) + " --asmInter=1"
|
||||
_aot_compile_options_ =
|
||||
" --aot-output-file=" + rebase_path(_test_m_path_) +
|
||||
" --snapshot-output-file=" + rebase_path(_test_snapshot_path_) +
|
||||
" --asm-interpreter=true"
|
||||
|
||||
args = [
|
||||
"--script-file",
|
||||
@ -245,7 +294,8 @@ template("host_aot_test_action") {
|
||||
_aot_run_options_ =
|
||||
" --aot-output-file=" + rebase_path(_test_m_path_) +
|
||||
" --snapshot-output-file=" + rebase_path(_test_snapshot_path_) +
|
||||
" --enable-ts-aot=true" + " --enable-stub-aot=true" + " --asmInter=1"
|
||||
" --enable-ts-aot=true" + " --enable-stub-aot=true" +
|
||||
" --asm-interpreter=true"
|
||||
|
||||
args = [
|
||||
"--script-file",
|
||||
@ -268,67 +318,3 @@ template("host_aot_test_action") {
|
||||
outputs = [ "$target_out_dir/${_target_name_}/" ]
|
||||
}
|
||||
}
|
||||
|
||||
template("host_asm_test_action") {
|
||||
_target_name_ = "${target_name}"
|
||||
_deps_ = invoker.deps
|
||||
|
||||
_test_js_path_ = "./${_target_name_}.js"
|
||||
_test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
|
||||
_test_expect_path_ = "./expect_output.txt"
|
||||
|
||||
ts2abc_gen_abc("gen_${_target_name_}_abc") {
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
extra_dependencies = _deps_
|
||||
src_js = rebase_path(_test_js_path_)
|
||||
dst_file = rebase_path(_test_abc_path_)
|
||||
extra_args = [ "--debug" ]
|
||||
|
||||
in_puts = [
|
||||
_test_js_path_,
|
||||
_test_expect_path_,
|
||||
]
|
||||
out_puts = [ _test_abc_path_ ]
|
||||
}
|
||||
|
||||
_script_args_ = rebase_path(_test_abc_path_)
|
||||
|
||||
action("${_target_name_}AsmAction") {
|
||||
testonly = true
|
||||
|
||||
_host_jsvm_target_ =
|
||||
"//ark/js_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
|
||||
_root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
|
||||
|
||||
deps = [
|
||||
":gen_${_target_name_}_abc",
|
||||
"//ark/js_runtime/ecmascript/compiler:gen_stub_file(${host_toolchain})",
|
||||
_host_jsvm_target_,
|
||||
]
|
||||
deps += _deps_
|
||||
|
||||
script = "//ark/js_runtime/script/run_ark_executable.py"
|
||||
|
||||
_asm_run_options_ = " --enable-stub-aot=true" + " --asmInter=1"
|
||||
|
||||
args = [
|
||||
"--script-file",
|
||||
rebase_path(_root_out_dir_) + "/ark/ark_js_runtime/ark_js_vm",
|
||||
"--script-options",
|
||||
_asm_run_options_,
|
||||
"--script-args",
|
||||
_script_args_,
|
||||
"--expect-file",
|
||||
rebase_path(_test_expect_path_),
|
||||
"--env-path",
|
||||
rebase_path(_root_out_dir_) + "/ark/ark:" + rebase_path(_root_out_dir_) +
|
||||
"/ark/ark_js_runtime:" + rebase_path(_root_out_dir_) +
|
||||
"/${_icu_path_}:" +
|
||||
rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
|
||||
]
|
||||
|
||||
inputs = [ _test_abc_path_ ]
|
||||
|
||||
outputs = [ "$target_out_dir/${_target_name_}/" ]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user