• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14function(add_test_file_ecma)
15    set(prefix ARG)
16    set(noValues DISABLE_LIMIT_STD_ALLOC SKIP_AOT SKIP_OSR SKIP_VERIFICATION VERIFIER_FAIL_TEST)
17    set(singleValues FILE DEBUG_LOG_MESSAGE DEBUG_LOG_MESSAGE_ENFORCED_JIT GC_OPTIONS)
18    set(multiValues EXPECTED_STDOUT VERIFIER_EXPECTED_STDOUT VERIFIER_SEARCH_STDERR ARGUMENTS RUNTIME_OPTIONS COMPILER_OPTIONS PRLIMIT_OPTIONS)
19    cmake_parse_arguments(${prefix}
20                          "${noValues}"
21                          "${singleValues}"
22                          "${multiValues}"
23                          ${ARGN})
24
25
26    if (NOT DEFINED ARG_FILE)
27        message(FATAL_ERROR "Mandatory FILE argument is not defined.")
28    endif()
29
30    get_filename_component(target "${ARG_FILE}" NAME)
31    get_filename_component(path "${ARG_FILE}" DIRECTORY)
32    get_filename_component(suite ${path} NAME)
33
34    if (NOT ARG_DISABLE_LIMIT_STD_ALLOC)
35        set(ARG_RUNTIME_OPTIONS "${ARG_RUNTIME_OPTIONS} --limit-standard-alloc=true")
36    endif()
37
38    if(DEFINED ARG_GC_OPTIONS)
39        set(ARG_RUNTIME_OPTIONS "${ARG_RUNTIME_OPTIONS}" "${ARG_GC_OPTIONS}")
40    endif()
41
42    if (PANDA_ENABLE_EVENTS)
43        set(ARG_RUNTIME_OPTIONS "${ARG_RUNTIME_OPTIONS} --events-output=csv")
44    endif()
45
46    #TODO: add test suite to check with PANDA_COMPILER_TARGET
47    if (((PANDA_TARGET_ARM64) OR (PANDA_TARGET_ARM32) OR (PANDA_TARGET_AMD64)) AND DEFINED ARG_DEBUG_LOG_MESSAGE_ENFORCED_JIT)
48      set(CUR_RUNTIME_OPTIONS "${ARG_RUNTIME_OPTIONS}" "--log-level=debug")
49      set(CUR_JIT_DEBUG_LOG_MESSAGE "${ARG_DEBUG_LOG_MESSAGE_ENFORCED_JIT}")
50    elseif(DEFINED ARG_DEBUG_LOG_MESSAGE)
51      set(CUR_RUNTIME_OPTIONS "${ARG_RUNTIME_OPTIONS}" "--log-level=debug")
52      set(CUR_JIT_DEBUG_LOG_MESSAGE "${ARG_DEBUG_LOG_MESSAGE}")
53      set(CUR_DEBUG_LOG_MESSAGE "${ARG_DEBUG_LOG_MESSAGE}")
54    else()
55      set(CUR_RUNTIME_OPTIONS "${ARG_RUNTIME_OPTIONS}")
56    endif()
57
58    set(language_context "ecmascript")
59    set(ARG_SKIP_AOT TRUE) # aot mode is not supported yet
60    set(ARG_SKIP_VERIFICATION TRUE) #verification is not supported yet
61    set(ARG_SKIP_OSR TRUE) #osr is not supported yet
62    set(CUR_RUNTIME_OPTIONS "${ARG_RUNTIME_OPTIONS}" "--run-gc-in-place=true") # ecma vm doesn't support concurrent GC
63
64    if (ARG_VERIFIER_FAIL_TEST)
65        set(VERIFIER_FAIL_TEST VERIFIER_FAIL_TEST)
66    else()
67        set(VERIFIER_FAIL_TEST)
68    endif()
69
70    if (NOT ARG_SKIP_VERIFICATION)
71        verifier_add_test_run(
72            FILE "${ARG_FILE}"
73            TARGET ${target}-verifier
74            SUBDIR ${suite}-verifier
75            ${VERIFIER_FAIL_TEST}
76            EXPECTED_STDOUT "${ARG_VERIFIER_EXPECTED_STDOUT}"
77            SEARCH_STDERR "${ARG_VERIFIER_SEARCH_STDERR}"
78            LANGUAGE_CONTEXT "${language_context}"
79        )
80        add_dependencies(${suite} ${target}-verifier)
81    endif()
82
83    panda_add_test_run(
84        FILE "${ARG_FILE}"
85        TARGET ${target}-stw
86        SUBDIR ${suite}-stw
87        EXPECTED_STDOUT "${ARG_EXPECTED_STDOUT}"
88        SEARCH_DEBUG_STDERR ${CUR_DEBUG_LOG_MESSAGE}
89        RUNTIME_OPTIONS "${CUR_RUNTIME_OPTIONS}" "--compiler-enable-jit=false --gc-type=stw"
90        COMPILER_OPTIONS "${ARG_COMPILER_OPTIONS}"
91        ARGUMENTS "${ARG_ARGUMENTS}"
92        LANGUAGE_CONTEXT "${language_context}"
93        AOT_MODE FALSE
94        PRLIMIT_OPTIONS "${ARG_PRLIMIT_OPTIONS}"
95    )
96    add_dependencies(${suite} ${target}-stw)
97
98
99    panda_add_test_run(
100        FILE "${ARG_FILE}"
101        TARGET ${target}-gengc
102        SUBDIR ${suite}-gengc
103        EXPECTED_STDOUT "${ARG_EXPECTED_STDOUT}"
104        SEARCH_DEBUG_STDERR ${CUR_DEBUG_LOG_MESSAGE}
105        RUNTIME_OPTIONS "${CUR_RUNTIME_OPTIONS}" "--compiler-enable-jit=false --gc-type=gen-gc"
106        COMPILER_OPTIONS "${ARG_COMPILER_OPTIONS}"
107        ARGUMENTS "${ARG_ARGUMENTS}"
108        LANGUAGE_CONTEXT "${language_context}"
109        AOT_MODE FALSE
110        PRLIMIT_OPTIONS "${ARG_PRLIMIT_OPTIONS}"
111    )
112    add_dependencies(${suite} ${target}-gengc)
113
114    # TODO(dtrubenkov): remove this if after enabling G1GC
115    if (PANDA_ENABLE_G1GC_TESTS)
116    panda_add_test_run(
117            FILE "${ARG_FILE}"
118            TARGET ${target}-g1gc
119            SUBDIR ${suite}-g1gc
120            EXPECTED_STDOUT "${ARG_EXPECTED_STDOUT}"
121            SEARCH_DEBUG_STDERR ${CUR_DEBUG_LOG_MESSAGE}
122            RUNTIME_OPTIONS "${CUR_RUNTIME_OPTIONS}" "--compiler-enable-jit=false --gc-type=g1-gc"
123            COMPILER_OPTIONS "${ARG_COMPILER_OPTIONS}"
124            ARGUMENTS "${ARG_ARGUMENTS}"
125            LANGUAGE_CONTEXT "${language_context}"
126            AOT_MODE FALSE
127            PRLIMIT_OPTIONS "${ARG_PRLIMIT_OPTIONS}"
128    )
129    add_dependencies(${suite} ${target}-g1gc)
130    endif()
131
132    # Check if JIT-compilation wasn't turned off explicitly:
133    if (PANDA_COMPILER_ENABLE AND NOT CUR_RUNTIME_OPTIONS MATCHES "^.*--compiler-enable-jit=false.*$")
134        panda_add_test_run(
135            FILE "${ARG_FILE}"
136            TARGET ${target}-enforce-jit-compiler
137            SUBDIR ${suite}-enforce-jit-compiler
138            EXPECTED_STDOUT "${ARG_EXPECTED_STDOUT}"
139            SEARCH_DEBUG_STDERR ${CUR_JIT_DEBUG_LOG_MESSAGE}
140            RUNTIME_OPTIONS "${CUR_RUNTIME_OPTIONS}" "--compiler-enable-jit=true --compiler-hotness-threshold=0 --no-async-jit=true"
141            COMPILER_OPTIONS "${ARG_COMPILER_OPTIONS}"
142            ARGUMENTS "${ARG_ARGUMENTS}"
143            LANGUAGE_CONTEXT "${language_context}"
144            AOT_MODE FALSE
145            PRLIMIT_OPTIONS "${ARG_PRLIMIT_OPTIONS}"
146        )
147        add_dependencies(${suite} ${target}-enforce-jit-compiler)
148        add_dependencies(cts-jit-tests ${target}-enforce-jit-compiler)
149
150        if (PANDA_TARGET_ARM64 AND NOT ARG_SKIP_OSR)
151            panda_add_test_run(
152                FILE "${ARG_FILE}"
153                TARGET ${target}-osr-jit
154                SUBDIR ${suite}-osr-jit
155                EXPECTED_STDOUT "${ARG_EXPECTED_STDOUT}"
156                RUNTIME_OPTIONS "${CUR_RUNTIME_OPTIONS}" "--compiler-enable-jit=true --compiler-hotness-threshold=2 --compiler-enable-osr=true"
157                COMPILER_OPTIONS "${ARG_COMPILER_OPTIONS}"
158                ARGUMENTS "${ARG_ARGUMENTS}"
159                LANGUAGE_CONTEXT "${language_context}"
160                AOT_MODE FALSE
161                PRLIMIT_OPTIONS "${ARG_PRLIMIT_OPTIONS}"
162            )
163            add_dependencies(${suite} ${target}-osr-jit)
164            add_dependencies(cts-jit-tests ${target}-osr-jit)
165        endif()
166    endif()
167
168    if (PANDA_TARGET_AMD64 AND PANDA_CI_TESTING_MODE STREQUAL "Nightly")
169        panda_add_test_run(
170            FILE "${ARG_FILE}"
171            TARGET ${target}-arm32
172            SUBDIR ${suite}-arm32
173            EXPECTED_STDOUT "${ARG_EXPECTED_STDOUT}"
174            SEARCH_DEBUG_STDERR ${CUR_DEBUG_LOG_MESSAGE}
175            RUNTIME_OPTIONS "${CUR_RUNTIME_OPTIONS}" "--compiler-cross-arch=arm"
176            COMPILER_OPTIONS "${ARG_COMPILER_OPTIONS}"
177            ARGUMENTS "${ARG_ARGUMENTS}"
178            LANGUAGE_CONTEXT "${language_context}"
179            AOT_MODE FALSE
180            PRLIMIT_OPTIONS "${ARG_PRLIMIT_OPTIONS}"
181        )
182        add_dependencies(${suite} ${target}-arm32)
183
184        panda_add_test_run(
185            FILE "${ARG_FILE}"
186            TARGET ${target}-arm32-enforce-jit-compiler
187            SUBDIR ${suite}-arm32-enforce-jit-compiler
188            EXPECTED_STDOUT "${ARG_EXPECTED_STDOUT}"
189            SEARCH_DEBUG_STDERR ${CUR_JIT_DEBUG_LOG_MESSAGE}
190            RUNTIME_OPTIONS "${CUR_RUNTIME_OPTIONS}" "--compiler-hotness-threshold=0 --no-async-jit=true --compiler-cross-arch=arm"
191            COMPILER_OPTIONS "${ARG_COMPILER_OPTIONS}"
192            ARGUMENTS "${ARG_ARGUMENTS}"
193            LANGUAGE_CONTEXT "${language_context}"
194            AOT_MODE FALSE
195            PRLIMIT_OPTIONS "${ARG_PRLIMIT_OPTIONS}"
196        )
197        add_dependencies(${suite} ${target}-arm32-enforce-jit-compiler)
198
199        panda_add_test_run(
200            FILE "${ARG_FILE}"
201            TARGET ${target}-arm64
202            SUBDIR ${suite}-arm64
203            EXPECTED_STDOUT "${ARG_EXPECTED_STDOUT}"
204            SEARCH_DEBUG_STDERR ${CUR_DEBUG_LOG_MESSAGE}
205            RUNTIME_OPTIONS "${CUR_RUNTIME_OPTIONS}" "--compiler-cross-arch=arm64"
206            COMPILER_OPTIONS "${ARG_COMPILER_OPTIONS}"
207            ARGUMENTS "${ARG_ARGUMENTS}"
208            LANGUAGE_CONTEXT "${language_context}"
209            AOT_MODE FALSE
210            PRLIMIT_OPTIONS "${ARG_PRLIMIT_OPTIONS}"
211        )
212        add_dependencies(${suite} ${target}-arm64)
213
214        panda_add_test_run(
215            FILE "${ARG_FILE}"
216            TARGET ${target}-arm64-enforce-jit-compiler
217            SUBDIR ${suite}-arm64-enforce-jit-compiler
218            EXPECTED_STDOUT "${ARG_EXPECTED_STDOUT}"
219            SEARCH_DEBUG_STDERR ${CUR_JIT_DEBUG_LOG_MESSAGE}
220            RUNTIME_OPTIONS "${CUR_RUNTIME_OPTIONS}" "--compiler-hotness-threshold=0 --no-async-jit=true --compiler-cross-arch=arm64"
221            COMPILER_OPTIONS "${ARG_COMPILER_OPTIONS}"
222            ARGUMENTS "${ARG_ARGUMENTS}"
223            LANGUAGE_CONTEXT "${language_context}"
224            AOT_MODE FALSE
225            PRLIMIT_OPTIONS "${ARG_PRLIMIT_OPTIONS}"
226        )
227        add_dependencies(${suite} ${target}-arm64-enforce-jit-compiler)
228    endif()
229
230    if ((PANDA_TARGET_ARM64 OR PANDA_TARGET_AMD64) AND NOT ARG_SKIP_AOT)
231        panda_add_test_run(
232            FILE "${ARG_FILE}"
233            TARGET ${target}-aot
234            SUBDIR ${suite}-aot
235            EXPECTED_STDOUT "${ARG_EXPECTED_STDOUT}"
236            RUNTIME_OPTIONS "${CUR_RUNTIME_OPTIONS}"
237            COMPILER_OPTIONS "${ARG_COMPILER_OPTIONS}"
238            GC_OPTIONS "${ARG_GC_OPTIONS}"
239            ARGUMENTS "${ARG_ARGUMENTS}"
240            LANGUAGE_CONTEXT "${language_context}"
241            AOT_MODE TRUE
242            PRLIMIT_OPTIONS "${ARG_PRLIMIT_OPTIONS}"
243        )
244        add_dependencies(${suite} ${target}-aot)
245        add_dependencies(cts-aot-tests ${target}-aot)
246    endif()
247
248endfunction()
249
250if(CMAKE_CROSSCOMPILING)
251    ExternalProject_Get_Property(panda_host_tools binary_dir)
252    set(es2panda_target build_host_tools)
253    set(es2panda_bin    "${binary_dir}/plugins/ecmascript/es2panda/aot/es2panda")
254else()
255    set(es2panda_target es2panda)
256    set(es2panda_bin    $<TARGET_FILE:${es2panda_target}>)
257endif()
258
259if (CMAKE_CROSSCOMPILING AND PANDA_TARGET_ARM64)
260# ecmascript tests
261# add_test_file_ecma(FILE "${CMAKE_CURRENT_SOURCE_DIR}/ecmascript-tests/js-bitops-bitwise-and.pa" COMPILER_OPTIONS --compiler-hotness-threshold=0)
262endif()
263
264add_subdirectory(runtime)
265
266if(PANDA_WITH_COMPILER)
267    add_subdirectory(compiler)
268    add_subdirectory(bytecode_optimizer)
269endif()
270
271add_subdirectory(checked)
272add_subdirectory(assembler)
273add_subdirectory(disassembler)
274